Java AST Package

The ast package is provided for your use when creating abstract syntax trees. This package contains the 4 components described below. It is very important to note that you may not change any component of this package nor may you add any additional interfaces or classes. When marking your submissions we will delete any ast package you may submit and substitute it with the original versions.

As I have used a java package you will also need to use packages. It is our experience that many students do not understand packages. Please make sure that you do. The Java Tutorial is a good starting point.

The individual files......

ASTNode

This is an interface that defines all the essential methods for building and manipulating ASTs.

There are two provided classes that implement this interface.

AbstractASTNode

This is a class that implements the ASTNode interface. I suggest you do not use this class. It is provided for reference only. You can look at this to see how it is implemented. If you are unsure how the AST is built, this is the class to look at first.

AbstractViewableASTNode

This is the class I intend you to use. It provides a means of visualising the AST. It is identical to AbstractASTNode in all other respects. You can use it's main() method to see how to set up the visualisation.

To use this, you need to do what was described in lectures – you need to extend (subclass) this class. So you will end up with class definitions for all the major syntactic categories in the language.

ASTNodeNotFoundException

What more do I need to say?

JavaDoc Documentation.

Modified by Rob Esser on 2nd March 2004