[antlr-interest] Antlr3 does not report error with incorrect input.

Martin Fowler fowler at acm.org
Mon Mar 5 12:40:05 PST 2007

The "xitem foo" was deliberate - I wanted the error.

But the latter part of the message did the trick for me - thanks. I 
didn't realize I needed the EOF in the grammar, although now you mention 
it, it does make sense. I fixed the grammar, and now get `line 1:0 
mismatched input 'xitem' expecting EOF` - which is what I was looking for.


Terence Parr wrote:
> Hi Martin,
> StringReader input = new StringReader("xitem foo");
> is the culprit.  It should be "item foo".  It sees xitem as STRING and 
> then matches nothing, which is legal by your grammar:
> catalog :  item*;
> it silently exists because it didn't find an item. ;)
> If you use
> catalog :  item* EOF;
> then it would say missing EOF, found STRING or something.
> Ter

Martin Fowler

More information about the antlr-interest mailing list