Turtle Compiler
Ok, so I need to finish the Dragon book before I get too far into this.
Micro Pass Compiler
I need several syntaxes that are related. A compiler node operates on one syntax and outputs one syntax (often the same).
This makes it easy to test compiler nodes - run the compiler without the node and run the tests against the output, then re-run the compiler with the node and make sure all the tests still pass. Also it makes it easy to benchmark, same operation.
Top Level Steps
This is standard, but I'm learning so I need notes.
- Determine imports graph
- lex and parse files to AST
- High level AST optimizations
- Convert down to mid level AST
- Mid level optimizations
- Covert down to byte code
- Byte code optimizations
High level optimizations
- Remove unused symbols
- Replacing constants
- determine pure functions
- any pure function called with constants can be replaced
- Inline functions