[antlr-interest] ANTLR parsing too lazy

Marco Bakera marco.bakera at tu-dortmund.de
Mon Dec 17 06:33:15 PST 2007


On Monday 17 December 2007 12:05:40 shmuel siegel wrote:
>
> You didn't insist that the grammar recognize the entire
> input. For instance, your case could have been written as
>
> prog: sentence+;
> sentence: '(' IDENT '&' IDENT ')';
>
> It hits the second right paren and stops; it found a sentence; hence it
> found a prog.
>
> Instead write
> prog: sentence+ EOF;
>
> Now, everything until the EOF must be recognized. I hope that it is
> obvious how to apply this to your case.

Yes. That was the key idea that made my day. :)

Thanks a lot for that fast response.


Greetings,
Marco.




More information about the antlr-interest mailing list