[antlr-interest] Strange parsing behavior

Dan Baumberger dbaumber at gmail.com
Tue Apr 7 21:38:49 PDT 2009


Actually, I don't want the semicolon between the blocks. I wanted to detect
it as an error. In any case, putting the EOF in the rule as you indicate
below fixed the issue!

Thanks for your help!

- Dan -

On Tue, Apr 7, 2009 at 10:01 AM, Jim Idle <jimi at temporal-wave.com> wrote:

>  Dan Baumberger wrote:
>
>  Handling only a single block was a mistake on my part in the email. The
> rule should have been:
>
> prog : (b=ID '{' (ID ';')+ '}')+ { System.out.println("Found block: " +
> $b.text);} ;
>
> There may be other things in your grammar (you have removed all the
> warnings and errors?), but this fragment does not do what you want. Use:
>
> prog : (b=ID '{' (ID ';')+ '}' *';'*)+ { System.out.println("Found block:
> " + $b.text);}  *EOF;*
>
> See the ';' and the EOF?
>
> Jim
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090407/b3ce5012/attachment.html 


More information about the antlr-interest mailing list