[antlr-interest] tree parser / rewritter

Bogdan Mitu bogdan_mt at yahoo.com
Wed Sep 4 04:42:05 PDT 2002


--- Lloyd Dupont <lloyd at galador.net> wrote:
> I have a tree parser. and I have tree I want to read muliple time,
> simplyfing each time.
> 
> let's imagine I have
> 
> file: (node1 | node2) *;
> node1: #(NODE1 FOO);
> node2: #(NODE2 BAR);
> 
> I want to do something with node1 on first pas and remove it.
> 
> I tryed something like:
> 
> options {
>     buildAST = true;
> }
> stage1: (!node1Analysis | .) *;
> 
> stage2:! (node2Analysis) *;
> 
> where stage2 is called with getAST() produce by stage1.
> unfrtunately, hen I do that the node2 is empty, where all child are gone ?
> I can't understand.
> has anyone idea ?

When you use . ANTLR copies the current node in the return AST _without_
children. Try:

stage1: (!node1Analysis | node2) *;

node2: #(NODE2 BAR);

ANTLR will now have to parse all node2 subtree, and the children will be
copied to returned AST.


Hope it works,
Bogdan

> 


__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com

 

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



More information about the antlr-interest mailing list