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

Granville Barnett granville at gbarnett.org
Tue Jul 1 11:35:57 PDT 2008


Ooops. I stand corrected.

 

Granville

 

From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Jim Idle
Sent: 01 July 2008 19:20
To: Edwards, Waverly
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] Access to lexer warning/error messages after parsing

 

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/f5f3d1ff/attachment.html 


More information about the antlr-interest mailing list