Code Monkey home page Code Monkey logo

minijava-compiler's Introduction

Compiler 
  - for a subset of Java, based on Appel "Modern Compiler Design in Java"

Run with

	runhugs -98 Main.lhs BinaryTree.java

or with

	hugs -98 Main.lhs
	compile "BinaryTree.java"

IMPORTANT: the "-98" flag turns on a few extensions to Hugs - don't omit!

Hugs is the Haskell interpreter, and is widely available in package repos.
You can also use GHC but I've not tested it recently.

NB assumes JS in the current directory, so copy as required etc



This produces some files

 * BinaryTree.c		- resulting C code!!!

 * BinaryTree.1-lex	- lexer output
 * BinaryTree.2-tree	- parsed tree, pretty printed (ie fixed layout)
 * BinaryTree.3-table	- symbol table - info about variables and methods
 * BinaryTree.4-trans   - first basic translation, unpacking the OO details
 * BinaryTree.5-lin	- linearised nested form into simpler sequences
 * BinaryTree.6-traces	- forming basic blocks and removing some inefficient jumps


To compile the .c file, run this

	gcc rts.c BinaryTree.c

This joins the raw C code with a simple run-time system in rts.[ch] - which 
basically just provides a stack for holding fn args and local vars.

And run the executable (assuming Unix/Linux) with

	./a.out

minijava-compiler's People

Contributors

paulcc avatar

Watchers

steven 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.