Project for the "Compilers and Interpreters" course of 2nd Cycle Degree in Computer Science of the University of Bologna, a.y. 2021/22.
The aim of the project is to develop both a compiler and an interpreter for the SimpLanPlus language. Its grammar is located at
/src/main/antlr/SimpLanPlus.g4
.
SimpLanPlus is an imperative language that allows recursion and pass-by-reference parameters. It does not allow mutual recursion and nested function declarations.
The main package contains both the antlr package, a placeholder for the .g4 grammars, and the java/it/ghellimanca for the code. Here we have:
- the ast package. Contains all the Abstract Syntax Tree nodes implementations.
- the gen package. Here we can find all the files generated by ANTLR tool, i.e. Lexers and Parsers for both SimpLanPlus grammar and the assembly one.
- the intepreter package, which contains all the interpreter files and eceptions.
- the semanticanalysis package, that contains all the utility classes needed for Semantic Analysis and its Errors (both exceptions and warnings).
TheSimpLanPlus.java
file is the main one and it contains the compile()
and run()
methods. It is located in the main package.
It is possible to compile the project under the command
mvn clean compile assembly:single
Then to run:
java -jar target/SimpLanPlus.jar fileName.simplan
This command runs the interpreter for the given SimpLanPlus file.