Git Product home page Git Product logo

minijava's Introduction

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 ocamlbuild ocamlfind 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 ocamlbuild ocamlfind menhir

Download, Compile and Run

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

git clone --recurse-submodules https://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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.