Project root : MCJavaCompiler/ Project have 5 directories
- Absyn : Node classes for AST
- ErrorMsg : Unused now
- Compile : This directory has 'Main' class for entire compiler execution/
- Parse : Frontend class for Compile.Main class to execute, and lexer/parser classes.
- Symbol : Symbol, symbol table, and its interfaces
- libs : It has library files, JFlex and CUP.
Building the project 'Makefile' contains build sequence. You can build the whole project by 'make' command.
Executing the MiniC parser Execute the main java class with CUP library on root directory of the project. 'libs' directory already contains CUP library, so you just need this command.
java -cp libs/java-cup-11a.jar: Compile/Main
This command execute parser with '/input.txt' as input.
You can pass another file as an argument of the parser.
java -cp libs/java-cup-11a.jar: Compile/Main your_test_file
Replace 'your_test_file' to anything you want.
At the end of parsing, parser generates 2 files as a result. One is "tree.txt", which is miniC code from visiting AST. Another is "table.txt", symbol table for given code.
Type Analysis Compiler does type analysis, and it prints a modified AST when input program is correctly typed. Type analysis prints list of error like following.
[Error/Warning] Line , :
Modified AST's have type conversion, int to float, or float to int. You can see casting expressions like C in a modified AST as result.