ast: A system for creating Abstract Syntax Trees

The "ast" system takes as input a description of a heterogenous tree structure, and outputs C++ code to define a set of classes that implement the described tree. Abstract Syntax Trees, used in language processors (like compilers), are the principal intended application, though of course the need for heterogenous trees arises in other situations as well.

As a short example, the following is a sample input to the "astgen" tool. It's also in the file demo.ast.

  class Root(A a, B b);

  class A {
    -> A_one(string name);
    -> A_two(B b);

  class B(string name) {
    public int x = 0;

    -> B_one(int y);
    -> B_two(char c);

From this description, astgen produces two files, demo.h and You can then write C++ code that uses these tree classes.

The basic inspiration for the ast system is ML's disjoint union types, but I extended them in several ways:

For more information about the features of the ast system, consult the AST Manual.

The ast system requires the following external software:

Build instructions:

  $ ./configure
  $ make
  $ make check
./configure understands these options. You can also look at the Makefile.

Module List:

Valid HTML 4.01!