Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
83 lines (61 sloc) 1.92 KB

MiniJava Transpiler

mini-java is an educational transpiler from MiniJava, which is a subset of Java, to C.
The construction of this transpiler is documented on www.mrcoder.org.

Install Dependencies

Linux (Ubuntu)

sudo apt-get install ocaml opam
opam init -a -y
eval `opam config env`
opam switch -y 4.07.0
eval `opam config env`
opam install -y menhir

Mac OS X

brew install gpatch m4 ocaml opam
opam init -a -y
eval `opam config env`
opam switch -y 4.07.0
eval `opam config env`
opam install -y menhir

Download, Compile and Run

Once you have the dependencies (see above), run the following commands in your terminal.

git clone --recurse-submodules git@github.com:lascar-pacagi/MiniJava.git
make
./mini-java file.java
./file

The default C compiler is cc. if you want to use another compiler, you should give the name of the compiler as follow.

./mini-java --c-compiler clang file.java

If you want to launch mini-java from any directory, you should give the path to the tgc directory.

./mini-java --tgc-path "path to tgc directory" file.java

If you want to use mini-java without a garbage collector, and so without dependencies to tgc, you can checkout the version 1.0. In this version, the transpiler doesn't use a garbage collector and only produces the generated C file.

git checkout v1.0
make
./mini-java file.java
gcc file.c -o file
./file

If you want to modify the version 1.0, you can create a new branch from version 1.0 (for example from_v1.0).

git checkout -b from_v1.0 v1.0

to go back to the version with a garbage collector do the following.

git checkout master
make
You can’t perform that action at this time.