Hi Gavin,

> All the functions that ANTLR itself uses to
> construct ASTs are available to your code.

The following helper method works great, thanks a lot!

<snip>
private CommonTree createTreeByGlobals(List<String> symbols) {
        CommonTree globalTree = null;

        if (newGlobals.size() > 0) {
            globalTree =  
(CommonTree)adaptor.becomeRoot(adaptor.create(GLOBAL,  
"GLOBAL"),adaptor.nil());
            for (String name : newGlobals) {
                adaptor.addChild(globalTree, adaptor.create(Identifier, name));
            }
        }

        return globalTree;
}

<snip>

: sourceElement*
  -> ^(PROGRAM  
{createTreeByGlobals 
(((SymbolTable_scope)SymbolTable_stack.peek()).newGlobals)}  
sourceElement*)

<snip>

Kind regards,

Chris

List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org:8080/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