[antlr-interest] weird rule...
John B. Brodie
jbb at acm.org
Mon Apr 18 10:08:57 PDT 2005
Greetings!
On Mon, 18 Apr 2005 01:04:12 -0700 (PDT), Octavian Nita wrote:
>
>How can I write something like
>
>suf : (x | y)* ( (x '=') | y ) ;
>
>so that ANTLR will be ok with?
>
The following seems to do the trick, but is probably way too
complex. Can't think of any other way off hand.
This does run through the antlr.Tool without complaint, but I did not
actually try parse any test sentences.
Hope this helps...
-----begin test.g-----cut here-----cut here-----cut here-----
class testParser extends Parser;
suf :
( x ( must_end_with_x )? z )
| ( y ( must_end_with_y )? )
;
must_end_with_x : ( y )* x ( must_end_with_x )? ;
must_end_with_y : ( x )* y ( must_end_with_y )? ;
x : X ;
y : Y ;
z : Z ;
-----end test.g-----cut here-----cut here-----cut here-----
-jbb
More information about the antlr-interest
mailing list