Code Monkey home page Code Monkey 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

The branch ast_typed has an abstract syntax tree decorated with type information. This tree is produced by the typechecker and it can be useful if you want to augment MiniJava.

minijava's People

Contributors

lascar-pacagi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

minijava's Issues

Missing ocamlbuild and ocamlfind

Hello Sir,

When using your Linux instructions to setup the build env, once we reach the make part, there is an error saying that ocamlbuild is missing. Once installed, there is also an error about ocamlfind.

I fixed it by using opam install -y ocamlbuild ocamlfind before making, is it because I missed a step, or maybe it should be added to the README?

Thanks!

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.