Git Product home page Git Product logo

compiler_minijava's Introduction

Compiler-MiniJava

An Implementation of a compiler for an object-oriented language called MiniJava into LLVM assembly/IR. The project is adapted from materials kindly provided by the staff of the compiler classes at the University of Athens and the University of Washington.

MiniJava Programming language

MiniJava is (almost exactly) a subset of Java, defined in the Appendix of Appel and Palsberg's Modern Compiler Implementation in Java, 2nd edition and described on the MiniJava web site http://www.cambridge.org/resources/052182060X/ .

LLVM assembly/IR

The LLVM language is documented in the LLVM Language Reference Manual, although you will use only a subset of the instructions, which is described below.

Project Structure

Our project Consists of 3 stages of the compilation process :

1. Lexing & Parsing.

Generates ASTs from textual representations of MiniJava programs.

Usage: java -jar mjavac.jar parse marshal inputProg.java out.xml will write to out.xml a valid XML representation (per the schema) of the AST that corresponds to the input MiniJava program.

2. Semantic Checking.

In this part of the project we will validate a MiniJava AST to ensure that it conforms to the MiniJava specification, and in particular satisfies all the assumptions we have utilized for code generation. Nevertheless, these checks are part of the language, and they must be enforced even if your compiler can generate code for programs that don't satisfy some of the restrictions.

Usage: java -jar mjavac.jar unmarshal semantic inputProg.xml out.txt. will write to out.txt either "OK\n" if the input program passes all the semantic checks, or "ERROR\n" if any of the rules is violated.

3. Code Generation into LLVM assembly/IR:

In this part of the project we will translate a MiniJava AST into equivalent code in the intermediate representation used by the LLVM compiler project.

Usage: java -jar mjavac.jar unmarshal compile inputProg.xml out.ll will write to out.ll a translation of program represented by inputProg.xml into the textual format of LLVM IR.

Other Tools:

=== Compiling the project === ant

=== Cleaning === ant clean

=== From AST XML to Java program === java -jar mjavac.jar unmarshal print examples/BinaryTree.xml res.java

=== From AST XML to... AST XML === java -jar mjavac.jar unmarshal marshal examples/BinaryTree.xml res.xm

compiler_minijava's People

Contributors

ofekmula avatar rickben avatar shirlyrl avatar

Stargazers

 avatar

Watchers

 avatar

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.