[antlr-interest] weird rule...
John B. Brodie
jbb at acm.org
Mon Apr 18 10:27:42 PDT 2005
Greetings again!
My previous post on this subject was wrong. Sorry about that.
In my previous post, I wrote:
>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-----
My testParser does not handle the string: yx=
which is valid under your rule.
Again, sorry about that... (i hate it when this happens...)
-jbb
More information about the antlr-interest
mailing list