Menu
Navigation
Home
Forum
Search
Links
Fun Stuff
Comical Banners
Downloads
Jokes
Uselessfacts
Weird Laws
Pics
Claim to fame
USA 2004
Edinburgh 2005
Bristol 2005
Italy 2005
Lugano 2005
Minneapolis 2006
Lugano 2006
London 2006
Longleat House 2006
Paris 2006
Nashville 2007
The Peak District 2007
New Mexico 2007
Silverstone 2007
Geneva 2007
Silverstone 2008
Florida 2008
Projects
Adding Custom Songs to Guitar Hero III
BOINC FAQ Service
BOINC Stats Services
Cancer Stats Service
Fractal Applet
JDBC-ODBC Tutorial
MC68000 IDE
Maze Applet
NetSend
PCF FAQ
SAAS
Seti Graph
Seti Stats Service
TLL Compiler Applet
Wii GH3 Guitar with PC version

TLL Compiler Applet

The following applet demonstrates a compiler I had to write as part of my Advanced Compilers coursework in November-December 2002. My write-up can be seen here in PDF format (note that I have removed the source code from the write-up).

The compiler compiles the LISP like language TLL (This Little Language) into three-address code (TAC). The TAC is of my own design and in hindsight it could have been designed in a more regular format (see the conclusion of my write-up for further details).

The compiler uses a top-down recursive descent parser written using JavaCC to perform the parsing and to generate an abstract syntax tree (AST). A visitor is then used to walk the AST to generate the TAC.

The second part of the coursework involved generating zero-address code (ZAC) from the TAC for a byte-code interpreter. I have not created an applet for this because unless you know the syntax and semantics of the byte-code interpreter, the generated code would probably not make much sense to you. However, details and testing of my implementation can be see in my write-up above.

The applet below was programmed using SWING. In order to view this applet, you need at least the Java 1.2 plug-in.

Below are some examples you can try for yourself (copy and paste into the applet):

Recursive Factorial: (rec f (n) (if (= n 0) 1 (* n (f (- n 1 )))))

Factorial(10): (let fact (rec f (n) (if (= n 0) 1 (* n (f (- n 1 ))))) (fact 10 ))

Recursive Fibonacci: (rec f (n) (if (= n 0) 1 (if (= n 1) 1 (+ (f (- n 1)) (f (- n 2))))))

</comment> No support for JDK 1.2 applets found!

Copyright © Neil Munday 2003