A compiler for the C-minus language, built using JFlex (lexical analysis) and CUP (parser generation).
- Java
- JFlex
- CUP (
java-cup-0.11b.jar)
- Global variables are not supported; all variable declarations must be within a function scope.
- Array pointers are not supported; array declarations and indexing will not compile correctly.
To compile and generate the CM executable, run:
makeAfter that, you can run the following command to execute the compiled program:
java -cp .:/usr/share/java/java-cup-0.11b.jar CM test.cmThis will compile the test.cm file. You can replace test.cm with any C-minus source file you want to compile. Moreover, you can use the -a flag to perform syntactic analysis and output an abstract syntax tree:
java -cp .:/usr/share/java/java-cup-0.11b.jar CM test.cm -a| Flag | Description |
|---|---|
-a |
Perform syntactic analysis and output an abstract syntax tree (.abs file) |
-s |
Perform type checking and output symbol tables (.sym file) |
-c |
Compile and output TM assembly language code (.tm file) |
To remove all generated files:
make cleanThe CM-Compiler is based directly on the work of Fei Song.