Rust implementation of compiler project in mit 6.035 computer language engineering (Spring 2010)
cargo build
cargo test
cargo run
-
Scanner and Parser (Front End)
- use lalrpop
- scanner: splits source file input to tokens
- tokens can be operator, keyword, literal, string, or identifier
- non-tokens such as white spaces are discarded in this phase
- malformed tokens are reported and aborts compilation process
- parser: reads tokens and check if it conforms to the language spec
- matching braces
- semicolons
- not verified: type, function/variable name
- outputs AST
-
Semantic Checker (Front End)
- checks various non-context-free constraints: e.g. type compatibility
- builds symbol table that keeps user-defined types and location of each identifier
- outputs IR
-
Code Generation (Back-end) [todo]
- generate unoptimized x86-64 assembly
- object code conforming to ABI (Application Binary Interface)
-
Data Flow Analysis (Back-end) [todo]
- optimization pass
-
Optimizer (Back-end) [todo]
- multiple data flow optimization pass