A simple compiler aim at C-minus language and TM vitrual machine.
-
main.c -- main code file
-
globals.h -- define data structures and macros
-
raw/scan.l raw/parse.y -- lex and yacc source code for quick scanning & parsing
-
AST.c -- define routine functions for parsing a syntax tree, making type-check and error-handling at meanwhile.
-
symtab.c -- define data structures for symbol tables (for variables & functions)
-
codegen.c -- code generator, which recursively generates TM-machine code by syntax tree travesal.
-
To compile the compiler:
make clean
make
-
To compile for C-minus code:
main [filepath]
e.g.main test1.cm
-
To run TM codes:
tm [filepath]
e.g.tm test1.cm.tm