Repository for the course "Compilatori e interpreti" (Compilers and Interpreters) at the University of Bologna, A.Y. 2020/21.
Feel free to take a cue from this project. The evaluation was good but this project is not without errors (i.e. some edge cases are not considerated).
mvn clean compile assembly:single
java -jar target/SimpLanPlus.jar fileName.ext [additional args]
with fileName.ext
the name of a source code file written in SimpLanPlus language or in the SVM Assembly language (read the next section for more information).
The file name cannot start with a dash (-
).
One might add different arguments to print out additional information or change the behaviour of the program while compiling or interpreting:
--ast
prints out the information available in the nodes of the Abstract Syntax Tree (AST) after the semantic and type checks. This will be skipped if argument -mode=run
is present;--mode=compile
only compiles the code and saves it in a file named fileName.asm
;--mode=run
only runs the Assembly code for the SimpLanPlus Virtual Machine (SVM) which is present in the file given as parameter;--mode=all
compiles the code and runs it;--debugcpu
shows the content of the memory and registers of the SVM at each instruction available in the compiled (or read) Assembly code. This will be skipped if argument -mode=compile
is present;--codesize=c
requires the memory size for hosting the code to be of size c (i.e. c Assembly instructions can be processed). c must be a positive integer otherwise 1000 is set. This will be skipped if argument -mode=compile
is present;--memsize=m
requires the memory size for executing the program to be of size m (both stack and heap). m must be a positive integer otherwise 1000 is set. This will be skipped if argument -mode=compile
is present;By default:
codesize
and memsize
are set to 1000.Available registers in the SVM:
Activation Record | |
---|---|
Dec M | |
Dec M-1 | |
... | |
Dec 1 | |
Par N | $sp |
Par N-1 | |
... | |
Par 1 | |
AL (Access Link) | $fp |
RA (Return Address) | |
Previous SP (Stack Pointer) | $bsp |
Previous FP (Frame Pointer) |