[antlr-interest] question about tree parsing (2.x)
Lloyd Dupont
lloyd at nova-mind.com
Sun Jun 5 15:52:31 PDT 2005
Hi Thanks Brian (and Mounty for his good idea as well)
I do that because I used the a customized GNU-C parser to analyse ObjectiveC
header
but then, in the tree parsing phase, only a limited subset of the produced
tree interest me (my ObjectiveC class + typename & # of STAR in cast), so I
have to parse part of existing tree and ignore the rest.
And I was wondering if these syntax of mine were ok to visit part of big
tree.
But I'm not sure, I still have a few bug when I do that...
----- Original Message -----
From: "Bryan Ewbank" <ewbank at gmail.com>
To: <antlr-interest at antlr.org>
Sent: Friday, June 03, 2005 7:17 PM
Subject: Re: [antlr-interest] question about tree parsing (2.x)
Yes; you can do this; you are probably seeing ambiguity warnings about
the loop because both "ID4" and "." will match an ID4 node. The trick
is a syntactic predicate. Change this:
> bottomNode
> : #(
> ID3
> (
> ID4
> | . // catch all for ID5 | ID6
> ) // '+' volontary removed, exit should get 1 level up, no?
> )
> ;
To this:
> bottomNode
> : #(
> ID3
> (
> (ID4) => ID4
> | . // catch all for ID5 | ID6
> )+
> )
> ;
The "(ID4) => ID4" tells ANTLR to use that selection if an ID4 is seen.
I don't see why you removed the "+" unless you only want to match the
first child of ID3. To match all ID4 children of ID3, you need the
"+".
More information about the antlr-interest
mailing list