Compiles JMinusMinus code to WAT code which can then be run through a WASM interpretor.
WAT stands for WebAssembly Text Format. For more information, see https://developer.mozilla.org/en-US/docs/WebAssembly
This language is basically just a subset of Java. May update this with more details later.
- Make sure you have the correct version of Bison and Flex installed, run make all.
- Run ./compiler.out and pass in a file with JMinusMinus code and redirect the output to another file. For example, ./compiler.out input.txt > output
- The output file should now contain WAT code and can be sent to a WASM interpretor.
The input file goes through a lexical analysis which is implemented in lex.l using the Flex library.
After passing lexical analysis it is sent to the parser which constructs the AST as per the JMinusMinus specs, this is handled in parser.yy.
Driver.cpp handles the semantic checking of the AST. It also annotates the AST and defines data structures which will be referenced during code generation.
code_gen.cpp is where the actual WAT code is generated by traversing the AST and using the data structures previously defined.
runtimeLibrary.txt contains functions which are added in to the final WAT output during code generation.
Ubuntu 18.04
Bison 3.0.4
Flex 2.6.1