Go to MIPS compiler implemented in Go. Made as a course project for CS335 (Compiler Design).
Gopher vector imported from egonelbre/gophers .
Component | Demo | Status |
---|---|---|
Token generation / Lexer | test1.out |
✔️ |
Parser | struct.go ➡️ struct.html |
✔️ |
IR generation | scope.go ➡️ scope.ir |
✔️ |
Code generation | pascalTriangle.ir ➡️ pascalTriangle.asm |
✔️ |
The file main.go contains routines described as follows corresponding to each component -
Routine | Description |
---|---|
GenToken() |
Generates the tokens returned by lexer from the input program |
GenAsmFromIR() |
Generates the assembly code using the IR generated from the input program |
GenHTML() |
Generates the rightmost derivations used in the bottom-up parsing and pretty-prints them in HTML |
GenAsm() |
GenAsm generates the assembly code from the input program |
Run ./scripts/setup.sh
from the root directory of the project to set up the pre-commit git hooks.
The following should generate relevant binaries inside the directory bin
-
make
Alternatively, individual components can be built via -
make deps
make gentoken
make tac
make gogo
The generated binary bin/gogo
can be used to generate (Tokens | Assembly | HTML)
from the corresponding (go | IR | go)
files -
bin/gogo test.go
The tests can be built via -
make test