CS 214: Programming Languages
Spring 2009

Home|Syllabus|Schedule
<<|>>|ANTLR API|ANTLR Testing API|CITkit API

Setup
FrontEnd, Iteration 0

It might help to read Sections 2.1–2.2 from our textbook before starting on this front end.

While one can build a front end from scratch, I wouldn't recommend it (unless you really want to see what one is like). Most people use a generator which takes a language grammar and translates it into code.

You'll be using ANTLR for this. While there is an ANTLR IDE for Eclipse, it's seems to be impossible to install in our lab. (I've had to fight to get it onto my MacBook, too.) So I'm going to recommend that you use ANTLRWorks.

Running ANTLRWorks in Our Lab

On the command line, you should be able to run ANTLRWorks with this command:

unix-%  antlrworks

This is a shell script that I wrote which runs the ANTLRWorks program (which is just simple a JAR file).

  1. In Eclipse, create a new package ...interpreters.hobbes.frontend in both the src and tests folders.
  2. In ANTLRWorks...
    1. Open File -> Preferences....
    2. Open the General tab.
    3. Set the Output path to be the ...interpreters/hobbes/frontend folder.
    4. Apply the changes, and exit ANTLRWorks.

Using ANTLR in Your Project

Yeah... I wrote the ANTLR Testing library, too. Unlike CITkit, there are a couple of people actually using ANTLR Testing in the wild. Unlike my Hobbes front end, it's not getting new features daily.

You need the ANTLR runtime library as well as an ANTLR testing library. The testing library is needed only when writing and running unit tests. The ANTLR runtime library is needed (as one might suspect) at runtime to support the code that is generated from the ANTLR grammars that you write.

Since the Hobbes frontend that I've provided all along has used ANTLR, you already have the ANTLR runtime installed. You just need to get the ANTLR Testing library.

Go to the ANTLR Testing website, and download the latest version (another JAR file). Put it in your lib folder, and add to your build path.