[antlr-interest] AST enhancements

Eric Mahurin eric_mahurin at yahoo.com
Wed Aug 11 13:35:52 PDT 2004


While I'm thinking about it, here is a list of things that would be
nice to have regarding AST's:

1. Allow for sub-rules to have there own root rather than always
rooting the super-rule.  This is described in the documentation as
labeled sub-rules, but apparently is not implemented.  Right now to
get the right AST struture you have to partition the rules to get the
right roots.

2. Allow rule references in addtion to token references to be rooted.
 This feature was described in my previous message.  Right now you may
have to flatten the rules to get the right roots.

3. Have a standard interface for separating/storing/retrieving
children to the left vs. right of the root so that token order can be
easily preserved.  Right now with the way ASTFactory does things, the
current interface can be used to get the token order correct, but the
"addChild" definition must be changed (insert child at beginning
instead of end).  Instead, I think the interface and ASTFactory should
assume that the AST's keep order, but the implementation wouldn't have
to.  Maybe all that is needed is a redefinition of addChild (insert to
the left of the left children), and a few methods which return
separate left and right children lists (non-ordered ASTs would return
the whole list or nothing for these).

4. Consider using a more generic "List" like interface storing sibling
lists.  This way you can have implementations other than linked lists
and you can get easy random access.

5. Add some symbol table stuff.  It would be nice to be able to easily
store symbol table data in the AST.  I haven't thought through the
details yet, but I was thinking you'd have some suffix to say you
wanted something to be a key in a symbol table and the "children" ASTs
would be the value for this entry.  This could work similar to the "^"
 AST operator, but instead of making a root with children, it would
make a map entry.

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