Hi all,

After a long research, I ask you because I have no idea how to write  
directly to the AST-Stream from within an action. My parser remembers  
token-names in an ArrayList which must be written to the AST in an  
other rule. Here's my rule "program", where the names are ready to  
write to AST:

        program
        scope SymbolTable;
        @init {
                // initialize the scope for this block
                $SymbolTable::newGlobals = new ArrayList<String>();
        }
        @after {
                System.out.println("Number of globals: " +  
$SymbolTable::newGlobals.size());
        }
            : sourceElement*
            -> ^(PROGRAM sourceElement*)
            ;

There, I like to achieve something like this:

                -> ^(PROGRAM ^(GLOBALS {«return the element of  
$SymbolTable::newGlobals»}) sourceElement*)

The GLOBALS-subtree should look like ^(GLOBALS i x y) when "i", "x"  
and "y" are the token-names in my "newGlobals" ArrayList.

Is it maybe possible to add a method like writeToAstStream(String  
root, String child ...) to the parser? This is, in general, no  
problem, but how can I write something to the tree from within such an  
method or an action?

Any ideas?

Thank you very much in advance,

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