[antlr-interest] TreeParser efficiency: Can TreeParsers ignore arbitary subtrees?
Terence Parr
parrt at jguru.com
Tue May 13 09:13:44 PDT 2003
On Tuesday, May 13, 2003, at 05:11 AM, micheal_jor wrote:
> Hi,
>
> I just wondered if it is possible to generate TreeParsers that ignore
> (i.e. do not "visit") the nodes in arbitary subtrees.
Sure. :) Use wildcard:
expr : #(MULTIPLY . .) ;
will match just the multiply and ensure there are two children. I use
this all the time for efficiency when doing simple phases. For
example, if you don't care about what's inside a method body, just use
dot for the body and it won't be parsed. :)
Terence
>
> 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/
>
>
>
--
Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org
Co-founder, http://www.peerscope.com link sharing, pure-n-simple
Lecturer in Comp. Sci., University of San Francisco
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list