[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Wrong line number

Pawel Szymanski wrote:
> Hi
> I built a parser with SableCC and noticed that the default error handling
> messages give wrong line number of source file, where error occured.
> For example
> com.intel.itp.mof.lexer.LexerException: [5523,36] Unknown token: 0)
>         at com.intel.itp.mof.lexer.Lexer.getToken(Lexer.java, Compiled Code)
>         at com.intel.itp.mof.lexer.Lexer.peek(Lexer.java, Compiled Code)
>         at com.intel.itp.mof.parser.Parser.parse(Parser.java, Compiled Code)
>         at com.intel.itp.mof.parserTest.main(parserTest.java:21)
> While error is in line 3100.
> Why ?

I do not know.  You didn't give enough information (see below).

This seems to be a lexer error.  The first erroneous regular expression
(which is not matched to a token) starts at line 5523, column 36.  If
this should not be so:
(1) debug the lexer, by printing all matched tokens.  This is easily
done using a custom lexer.  Such a customized lexer can be found in the
mailing list archive.
(2) If you discover that tokens are not as you would like them to be
(this is quite likely to happen), fix your tokens definitions.

There is a very, very low probability that SableCC is faulty, but I
would be quite surprised, as programs tend to behave similarly over
time, and nobody has yet experienced a faulty line/column calculation up
to now (unless they have not reported it).

Normally, you should send a minimal grammar and input file necessary to
reproduce any bug you experience.

Etienne M. Gagnon, M.Sc.                     e-mail: egagnon@j-meg.com
Author of SableCC:                 http://www.sable.mcgill.ca/sablecc/