This project is a MiniJava Compiler written in Java that produces code in the LLVM instruction set. The MiniJava language is a subset of the Java language. A script is provided which compiles the LLVM instruction set files to executable programs (with the help of Clang).
The following steps are required in order to set up your enviroment and use the compiler. You can skip the following setup and just use the provided Dockerfile.
At first you will need to install the Java Runtime Environment (JRE) and the Java Development Kit (JDK)
sudo apt-get install default-jre
sudo apt-get install default-jdk
Then you will need to install the Clang 4.0
sudo apt-get install clang-4.0
- Get a copy of the project
git clone https://github.com/v-pap/MiniJava-Compiler.git
- Go into the src directory
cd MiniJava-Compiler/src
- Compile the project
make
In order to compile a MiniJava program you will have to type
java Main file.java
If you have multiple MiniJava programs to compile you can add them as extra arguments. For example if you have 2 MiniJava programs you can compile them this way
java Main file1.java file2.java
The compiler will produce an LLVM file for each MiniJava program.
In the first example it will produce the
file.ll
and on the second example it will produce
file1.ll file2.ll
A script is provided in the scripts directory which when run on the same directory as the LLVM files (.ll) will produce executable code.
Fixing the script permissions (only one time needed)
chmod +x compile_script.sh
Running the script
./compile_script.sh
Note: You may need to copy the script in the directory in which the LLVM files are located.
This project is licensed under the MIT License