Skip navigation links

Package net.sourceforge.czt.base.ast

Base interfaces of the AST for Z.

See: Description

Package net.sourceforge.czt.base.ast Description

Base interfaces of the AST for Z.

The (Java) AST for Z consists of a set of interfaces whose inheritance hierarchy can be seen as a tree (the abstract or annotated syntax tree for Z). All Z constructs (called terms), provided in the Z standard package or in one of the Z extension packages, should extend one of the interfaces provided in this package in a way that the whole AST interface inheritance hierarchy forms such a tree. The inner (non-leaf) interfaces are used for abstract Z constructs like term, predicate, and expression. The leaf interfaces represent concrete Z constructs, like the truth predicate.

Together with the interfaces, which are usually in packages named net.sourceforge.czt.*.ast, a set of implementation classes is provided which are located in packages called net.sourceforge.czt.*.impl. Abstract classes usually implement non-leaf interfaces, whereas non-abstract classes implement the leaf interfaces, which represent concrete Z terms. It is strongly discouraged to use the implementation classes in applications explicitly. Using the implementation classes explicitly would restricts the application to a particular set of implementation classes. An application programmer should use the interfaces in net.sourceforge.czt.*.ast and the object factories in order to get AST implementation-independent code.

To provide an implementation of one of the Z terms, the programmer needs to implement the corresponding interface. The new implementation can extend one of the existing implementation classes provided in net.sourceforge.czt.*.impl, or can be completely independend from the implementations provided there. Special care must be taken to implement the accept(Visitor) and getChildren() methods. These methods are used by all kinds of AST visitors like type checkers, XML writers, etc.

In addition to the implementation of the Z term, an object factory should be provided that creates objects of the newly implemented term. The easiest way to provide a factory method is to overwrite the corresponding factory method in net.sourceforge.czt.*.impl.*FactoryImpl to return an instance of the newly implemented Z construct.

Skip navigation links

Copyright © 2003–2016 Community Z Tools Project. All rights reserved.