[antlr-interest] OrderedAST plus other sub-classes

Eric Mahurin eric_mahurin at yahoo.com
Thu Aug 12 18:32:38 PDT 2004


I just uploaded a tar-file (ordered_AST.tgz) of some useful AST classes:

OrderedAST extends BaseAST: maintains which children are to the left
of the root and which are to the right.  The writeTo method writes out
the text of the AST nodes in the correct order.  writeTo uses the
method getSeparator (returns a new line in this class) between text of
the AST nodes.

TokenAST extends OrderedAST: puts a whole token in the AST node. 
getLine and getColumn now do something.  getSeparator returns a
concatenation of hiddenAfter text.

SeparatedAST extends OrderedAST: adds a separator field which defaults
to coming from a concatenation of the hiddenAfter tokens
(CommonHiddenStreamToken).

LiteralAST extends SeparatedAST: maintains a static lookup table so
that each object doesn't need to store the token text because it is
assumed to be fixed per type for tokens using this AST class.

FixedAST extends SeparatedAST: assumes that for each class that
inherits this, the token type is fixed.  Only one token type is needed
per class rather than per object.

RealAST/IdenAST/UnsignedAST/StringAST extends FixedAST: Stores the
data in a more usable format rather than the raw incoming format.

Since most token types have fixed strings, I use LiteralAST as a
default and use AST classes specific to a token type the others.

Eric




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list