My project of the compiler course.
See grammers.pdf.
$ make
mkdir -p bin
clang++ -Iinclude -DDEBUG -c -o bin/gencode.o src/gencode.cpp
clang++ -Iinclude -DDEBUG -c -o bin/symtable.o src/symtable.cpp
clang++ -Iinclude -DDEBUG -c -o bin/optimize.o src/optimize.cpp
clang++ -Iinclude -DDEBUG -c -o bin/lexer.o src/lexer.cpp
clang++ -Iinclude -DDEBUG -c -o bin/compiler.o src/compiler.cpp
clang++ -Iinclude -DDEBUG -c -o bin/mips.o src/mips.cpp
clang++ -Iinclude -DDEBUG -c -o bin/parser.o src/parser.cpp
clang++ -o bin/compiler bin/gencode.o bin/symtable.o bin/optimize.o bin/lexer.o bin/compiler.o bin/mips.o bin/parser.o
$ ./bin/compiler ./test/in/fact.txt
fact spill_s: 0 spill_t: 0 spill_a: 0
main spill_s: 0 spill_t: 0 spill_a: 0
Of course, you may want to modify Makefile
to adjust your toolchains.
There will several txt files to be generated.
file name | description |
---|---|
token.txt | The tokens which are generated by the lexer |
syntaxtree.txt | The parse process of the parser |
code.text | The intermediate codes. |
data.txt | The global data. |
code_token.txt | The tokens related with code.txt |
data_toekn.txt | The tokens related with data.txt |
code_area.txt | The mips instruments which depict the code area |
data_area.txt | The mips instruments which depict the data area |
mips.txt | The mips instruments which could be executed by the MIPS simulator Mars |
To do ~