This is a programming language I created using C++.
I am creating this language to sharpen my core Computer Science understanding. It can also be considered as my take on the subject of "Compiler Design", which I have for this semester. At this point, when I start, I have no idea how compilers or interpreters work. But, let's just hit it.
- Tokenizer and Program Elements are now a big bunch of files.
- Created Custom std::cerr statements for each exception thrown to better locate the source of error.
- Modulaization resolved all dependency based issues, but something broke for loop.
- Implmented while blocks run() method.
- Function calls implemented, had to modularize a lot of code in order to resolve dependencies.
- Further - need to modularize code and implement error reporting/traceback.
- Changed ForBlock structure and constructor to maintain conditional expression, loop variable update statement
- Implemented run() method, which checks for condition being true --> executes all statements in the block --> updates the loop variable and repeats.
- evaluate() method implemented for all sub types of ExpressionAST.
- ExpressionSatatement, VariableDeclarationStatement, VariableAssignmentStatement, OutputStatament and IfBlock run() method implemented.
- Simple programs can be executed now!! Yay! :) 🎉🤩
- ForBlock, WhileBlock, InputStatement and Function Calls implementation to go.
- Each program element has its own semantic checker.
- Type checking based on variable type, operator type and possible conversions between them.
- Type checking rules: integer and decimal can be used with any operator
- strings are supported by +, == and !=
- booleans are supported by and, or, not, == and !=.
- Still has scope of improvement in error reporting
- Function calls and Expressions can be recursively nested. Yay!.
- Like this: decimal some_var = x + 7 - add2( x+y/var, add1(x, add1(var+y/5, n+n%4)) ) % 5 -10/x
- Still need a better regular expression for recognizing correct expression, but this is a small one.
Each block stores its own functions in the symbol table itself. In case of name-clash between functions (or Symbols in general), one closest in the nesting is used.
- Each block has its own symbol table.
- Symbol Table is now updated everytime a Variable Declaration Statement or Variable Assignment Statement is encountered.
- Variables are searched in the most closely nested block.
- Arithmetic
- Relational
- Logical
- Simple Expression Statements
- Variable Declaration Statements
- Variable Assignment Statements