[antlr-interest] Access to lexer warning/error messages after parsing

Jim Idle jimi at temporal-wave.com
Tue Jul 1 11:20:16 PDT 2008


On Tue, 2008-07-01 at 12:42 -0400, Edwards, Waverly wrote:

> Wouldn't it be wise to just let the lexical error go and let the parser
> catch it.
> Any invalid character isn't really recoverable and since the user has to
> fix it
> anyway, it will just show up a misplaced identifier, number or symbol as
> far as the
> parser is concerned.  Also if you store the lexical error, you'll end up
> reporting
> the error twice... once as a lexical error and once as a parse error.


if you do not report both, then sometimes the error from the parser will
be very confusing. so, if you intercept an illegal character in the
lexer, you can first print - or store in a collection ;-0 - the position
of the character that threw things out;

xxx.hhh  parameter

line 17, offset 4, illegal character 0x7ff 

then the parser says;

line 17, offset 5 - near 'hhh'  expecting '.'

without the lexer pointing out that you have the wrong '.' - i didn't
look up what 0x7ff actually is, this is just an example of course - you
would need a few glances at this to realize what had happened.

jim
       

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080701/73ee06cb/attachment.html 


More information about the antlr-interest mailing list