- Building: Run build.xml with ant.
- Testing: Run the AllTests.java suite with junit.
- (optional) JastAdd Syntax Highlighting in Eclipse: JastAdd Eclipse Plugin.
Then in Preferences under File->Editors->FileAssociations associate "*.beaver" with "JastAdd Parser Editor"
- Scan the input via JFlex
- Parse the token stream via Beaver
- Annotate the Abstract Syntax Tree (AST) via JastAdd
- Transform MiniJava AST to Piglet AST
- Transform Piglet AST to Simplified Piglet AST
- Transform SPiglet AST to Kanga AST
- Transform Kanga AST to MIPS AST
- Prettyprint MIPS AST
MJFile file = new MJFile("tests/Factorial.java");
minijava.Program program = file.parse();
for (SemanticError e : program.errors()) {
System.err.println(e.getMessage());
}
MJFile file = new MJFile("tests/Factorial.java");
mips.Program mips = file.parse().toPiglet().toSpiglet().toKanga().toMips();
String mipsCode = mips.print().getString();
It is possible to interpret Piglet, Spiglet, Kanga and Mips.
MJFile file = new MJFile("tests/Factorial.java");
spiglet.Program spiglet = file.parse().toPiglet().toSpiglet();
System.out.println(spiglet.interpret());