Codes for course design of BUAA Compiler 2019 (the highest challenge). Implemented with C++.
Author: Zinuo You
Course Final Grade: 96
Guide Book: Guide Book (Chinese)
- Compiler: Clang
- Recommended Development Enviroment: Visual Studio 2019+.
- Notice: Due to automatic judgement enviroment, there's not physical directories and all codes are in the same directory. If you want to view the structure of the codes, I strongly recommend you to clone it and use Visual Studio open .vcxproj file (virtual directories will show).
- Input file: testfile.txt
- Output files:
- output.txt: objects codes (can run on MARS)
- log files: log information when running in different steps.(errors, warnings, data flow graph, reference count and etc.)
- Source Code: Persuade C (similar to C, but simplified for teaching purpose.)
- Object Code: MIPS-32
- Pluggable Compiling Optimization
- inline optimization.
- assignment spread optimizing.
- dead code optimization.
- register allocation (global registers: reference count, local registers: FIFO with active analysis on data flow graph).
- seek optimization for object codes generation. (branch, mod and etc.)
- Final Optimization Race: 6/306, please see Optimization Report(Chinese) for details.
- unit2 : Implement lexical parser on FSM.
- unit3 : Implement grammer parser with recursive descent method (from top to bottom). Use peeking (next one/two) to make sure no recall.
- unit4 : Implement error analysis of grammer errors and semantic errors.
- unit5 : Implement object codes generation of generating middle codes and generating MIPS codes. Object codes can run on MARS but do not have any optimization with only three registers being used, so you can almost regard it as a stack symbol machine.
- unit6 : Current version, see "features" for details.