Skip to content
This repository has been archived by the owner on Apr 21, 2024. It is now read-only.

Yorkyer/minicompiler

Repository files navigation

minicompiler

My project of the compiler course.

Grammar

See grammers.pdf.

How to compile and run

$ 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.

What you will get

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

The format of intermediate code

To do ~

About

My project of the compiler course.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages