Hi, just a reminder in case you folks haven't used the TreeWizard that it's 
useful in some situations. For example, when creating the implicitly generated 
lexers pulled from combined grammars, I need to build lexer rules for keywords 
you reference in the grammar. Once I have a wizard

TreeWizard wiz = new TreeWizard(adaptor,ANTLRParser.tokenNames);

Then I can create trees without having to do all of the manual "add child" 
stuff:

GrammarAST litRule = (GrammarAST)
        wiz.create("(RULE ID["+rname+"] (BLOCK (ALT 
STRING_LITERAL["+lit+"])))");

If you have a tree and you want to pull out information from it, you can use a 
scanf like method:

Map nodes = new HashMap();
boolean isLitRule =
        wiz.parse(r, "(RULE %name:ID (BLOCK (ALT %lit:STRING_LITERAL)))", 
nodes);

then get the node pointers from the map you pass in:

GrammarAST litNode = (GrammarAST)nodes.get("lit");
GrammarAST nameNode = (GrammarAST)nodes.get("name");

It's really making my life much easier.

Ter

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to