Java-- Compiler

Nicholas Cameron

 

CV

Portfolio

Contact

Site Map

Copyright 2004 Nicholas Cameron
 
 

Second year mini-project 2

For my second second year mini-project I created a compiler that compiles a subset of the Java language (with some minor modifications) to Java byte codes executable on a Java Virtual Machine. The catch is that it only uses a procedural subset of the byte codes so that it is similar to compiling to assembly code with no classes, objects, method calls etc. This means that the compiler must compile object oriented features such as polymorphism and virtual method dispatch into simple instructions.

The compiler uses the JFlex and CUP tools to lex and parse the input respectively and the Jasmin assembler to assemble Jasmin assembly code to JVM byte code.

Project report
Download source, classes and docs (437k)
Download command line compiler (194k)

Grammar
Language explaination

Try the Java-- compiler

Enter code:

 

 

Class file name:

or upload file:

or compile one of the samples:

Dynamic binding demo

Diagonalise

Linked list

Tree

Visitor

 

 

Output

Download class file (run using 'java <classname>')

 

Download .j file (Jasmin assembly code)

 

 

Found a bug? Please me know via the contact page (any comments also appreciated).