Brainlite
Brainlite is a new language that is used to write brainfuck programs. The core philosophy of brainlite is to provide an easy to remember syntax and a readable form of code for writing brainfuck.
As mentioned, this project was made in my first semester with minimal understanding of compilers and interpreters. The assumptions made back then are left intact as a reflection of my development and because I find some of it funny.
This documentation is written to be accurate to my assumptions and code rather than being technically accurate.
- The syntax, keywords and language assumptions can be found here.
- Compiler documentation can be found here.
- Interpreter documentation can be found here.
This document provides a briefing about the language.
Definitions
For understanding any term used here, refer to definitions.
Compiler assumptions
- The compiler will ignore any lines starting with ‘#’ as comments. There is no way to write multi-line comments.
- A string is considered a token if it is followed by a space, End of line, or if a semicolon is encountered.
- Empty lines are ignored.
- The compiler then generates code by invoking a function within the compiler class that corresponds to the keyword encountered. This is done using unordered map.
- The compiler assumes any string that is available in validTokens set as a valid token.
Interpreter assumptions
- Stores the entire source code into a std::vector.
- The parser then assumes each character as a token and validates it. If invalid token is encountered, it prints an error.
- The interpreter maintains a 38000 Bytes array with itself as the memory for brainlite program.
- The interpreter uses an integer variable called runtime_pointer to keep track of current memory address in access.
- ValidTokens set is used to verify if a token is valid.
- An unordered map is used to dispatch function responsible for each token.
License
Refer to License.