Go to file
2018-12-04 02:18:36 +07:00
astgen init 2018-12-04 02:05:06 +07:00
checker init 2018-12-04 02:05:06 +07:00
codegen init 2018-12-04 02:05:06 +07:00
external add jasmin and antlr4 2018-12-04 02:18:36 +07:00
libs init 2018-12-04 02:05:06 +07:00
MP_specifications language specifications 2018-12-04 02:09:33 +07:00
parser init 2018-12-04 02:05:06 +07:00
utils init 2018-12-04 02:05:06 +07:00
.gitignore add jasmin and antlr4 2018-12-04 02:18:36 +07:00
genANTLR4.py init 2018-12-04 02:05:06 +07:00
mpc.py init 2018-12-04 02:05:06 +07:00
README.md init 2018-12-04 02:05:06 +07:00

MP Compiler

From my Principle of Programming Languages assignment, I have created a compiler for the MP language. The assignment phase is divided to 4 phases, from doing Lexer, Parser, AST generation to Static Checker and Jasmin Code generation.

The assignment code structure is quite ugle, so I re-organized the code, adding some more steps to make the code look nicer and compile a *.mp file to a jar file.

Given the mp file as follows:

// hello.mp
procedure main();
begin
    putString("Hello World");
end

Compile and run the file by issuing these commands:

python mpc.py hello.mp
java -jar hello.jar

More documentation is being built.

Notes

Because I was having serious deadlines at the end of the semester, I drop on working on ArrayCell, which will be added later.

Because the lexer and parser are given by the famous ANTLR4 engine, there should exists a path to antlr4.jar on the environment variable ANTLR_LIB or else, the program will use the antlr4 file in the external folder.

Before running mpc.py, you must be sure that you have generate neccessary files from ANTLR4.

python genANTRL4.py