Skip to content

vsakkas/minijava-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MiniJava Compiler

A compiler for MiniJava, a fully object-oriented language and a subset of the language Java. MiniJava is designed so that its programs can be compiled by a full Java compiler like javac. The BNF version of MiniJava can be found here. The MiniJava compiler converts the MiniJava code into the intermediate representation used by the LLVM compiler project. It then uses clang (version 4.0 and newer) to generate the executable file.

Getting Started

To get the MiniJava compiler up and running on your local machine, simply follow the following instructions.

Prerequisites

First, you need to download clang (version 4.0 and newer) using the following command:

sudo apt install clang-4.0

Downloading

To download the source code of the MiniJava compiler use the following command:

git clone https://github.com/vsakkas/minijava-compiler.git

And to enter the directory of the downloaded project, simply type:

cd minijava-compiler

Building

To build the compiler, type the command below:

make

Running

Finally, to run the MiniJava compiler, use the following command:

java Minijava <yourfile>.java

The example above will generate 2 new files in the same directory as <yourfile>.java is:

  • <yourfile>.ll which contains the LLVM IR code that was generated by the compiler.
  • <yourfile> which is the executable produced by clang and can be run by using the command ./<yourfile>.

The above example compiles only one file. However, multiple files can be used. In this case, the compiler will generate 2 new files for each of the input files that were given. (Note: the source files do not need to be in the same path as the compiler. Full and relative paths can also be used.)

License

This project is licensed under the MIT License - see the LICENSE file for details

About

A MiniJava compiler, written in Java

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published