[antlr-interest] line 0:-1 mismatched input '<EOF>' expecting '; '

Fabien Hermenier fabien.hermenier at unice.fr
Sat Oct 6 06:13:58 PDT 2012


I know about this wiki page. I already have my ErrorReporter and indeed, I can detect this situation and I will fix it by getting the last token before mine that as a positive line/column number.

But to me, this seems to be an error from either my grammar or a an issue in the way errors are reported. Why has the EOF token a line/column equals to 0:-1?

Regards
Fabien.

----- Mail original -----
> Override the error handier and detect it and change it :). Also look
> at the wiki article about error recovery.
> 
> Jim
> 
> On Oct 6, 2012, at 17:44, Fabien Hermenier
> <fabien.hermenier at unice.fr> wrote:
> 
> > Hi
> >
> > I am stuck with this problem since long.
> >
> > When I have an error in the parser at the end of the input, the
> > reported error position is always 0:-1.
> > When it is in the middle of the input, there is no problem.
> > The exception RecognitionException that is generated in my parser
> > reported this inaccurate position.
> > In fact, the token related to that error indicates the line 0:-1.
> > So, why this particular situation at the end of the input ?
> >
> >
> > Here is a sample input:
> >
> > "foo(a);
> > foo(b)
> > foo(c);"
> >
> > -> Report an error in line 2:1 :expecting ';'
> >
> > "foo(a);
> > foo(b)"
> >
> > -> Report an error in line 0:-1 : expecting ';'
> >
> >
> > Regards
> > Fabien.
> >
> > List: http://www.antlr.org/mailman/listinfo/antlr-interest
> > Unsubscribe:
> > http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> 


More information about the antlr-interest mailing list