[antlr-interest] Re: TreeParser efficiency: Can TreeParsers i gnore arbitary subtrees?

mzukowski at yci.com mzukowski at yci.com
Tue May 13 12:09:56 PDT 2003


To be more clear here, when tree parsing you are not obligated to traverse
subtrees.  You only do that by using #() constructs.  

rule: DECL;
v.
rule: #(DECL etc) ;
 
rule: .

. is still the wild card.

Note that because you are not obligated to traverse subtrees you may leave
out entire subtrees when your tree pass is constructing a new tree.  My
strategy is to have a supergrammar tree grammar through which I run the tree
and then compare the two trees (input and output) to make sure that I am
traversing the entire tree.  I combine this test with my unit tests for each
rule to try to excersize every rule in the grammar and make sure that things
pass through all the way.

Monty

-----Original Message-----
From: lgcraymer [mailto:lgc at mail1.jpl.nasa.gov]
Sent: Tuesday, May 13, 2003 11:22 AM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] Re: TreeParser efficiency: Can TreeParsers
ignore arbitary subtrees?


Micheal--

The trick here is that "." matches any AST and does not attempt to 
search the subtree.  So you can do something like
     (FOO) => .
to match FOO and not search the subtree under FOO.

--Loring


--- In antlr-interest at yahoogroups.com, "micheal_jor" <open.zone at v...> 
wrote:
> Hi,
> 
> I just wondered if it is possible to generate TreeParsers that 
ignore 
> (i.e. do not "visit") the nodes in arbitary subtrees. 
> 
> I have an AST in which only a few nodes have attributes I am 
> interested in processing with a TreeParser. Because every TreeParser 
> grammar describes the whole tree(?), all nodes are still visited 
even 
> if no action code exists to be executed.
> 
> Is it possible to effectively say in the TreeParser grammar "I won't 
> be doing anything in this node/subtree so don't even generate code 
to 
> visit it?
> 
> Cheers,
> 
> Micheal


 

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


 

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




More information about the antlr-interest mailing list