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

Edwards, Waverly Waverly.Edwards at genesys.com
Tue Jul 1 11:30:15 PDT 2008


I see.
I understand.
I learned something.
I concede.
I thank you.
 
 
W.

________________________________

From: Jim Idle [mailto:jimi at temporal-wave.com] 
Sent: Tuesday, July 01, 2008 2:20 PM
To: Edwards, Waverly
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] Access to lexer warning/error messages
afterparsing


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


More information about the antlr-interest mailing list