After the gruel and suffering of finals week, a ray of hope! My compiler is finished! Still incredibly rudimentary, but it’s not too shabby. It currently supports:
- Basic integral types including:
- Integer
- Float
- Boolean
- Char
- Char * (not really a pointer, but a string type)
- Functions, with return types and parameters
- Comments, both single and multi-line
- Variables
- Local variables that respect the stack
- Global variables (no initialization though)
- Basic binary operators:
- Assignment
- Addition
- Subtraction
- Multiplication
- Division
- Modulo
- Logical And
- Logical Or
- Basic type casting
- Function binding to C++ (so you can set stuff up like printing to console)
The source is still intermingled with the assignment drivers, so I’m cleaning that up. In the meantime, if you’re interested you can give it a try! A source file and the executable for the compiler is available below. It covers the basic syntax and stuff. The compiler also has basic compiler errors, so sticking in bad code should (hopefully) not crash, and it will tell you where it found a mistake.