[antlr-interest] Relaxed number format lexer problem

Sam Harwell sharwell at pixelminegames.com
Wed Apr 22 10:19:39 PDT 2009


There are a few problems with that method I have overcome:

 

1.       It uses sempreds. Sempreds break the heavy optimizations I'm
working on integrating into the ANTLR compiler.

2.       It uses actions. Mine also uses an action, but it's a simple
one that could easily be altered for a different target. It's also
easier to make use of this rule across languages with varying number
semantics (alterations to the rule would likely be minimal if required).
Interleaved actions also hurt the optimizer; here I restricted it to the
@after section but I can move it to NextToken() later if necessary.

3.       There are several places in the IntelliSense engine where it
doesn't matter whether or not the number is valid. For those I disable
the classifier and its messages to favor IDE response times.


In a setting where these are not issues, I really understand where
you're coming from with your rule. It's a great example of the measures
a compiler designer should take to make the system able to provide
clearly understandable, localized messages in the face of a wide variety
of errors, and more people should work like that.

 

Nevertheless, I still think ANTLR is generating incorrect code for way I
originally tried to structure the rule.

 

Sam

 

From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Jim Idle
Sent: Wednesday, April 22, 2009 11:52 AM
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] Relaxed number format lexer problem

 

Sam Harwell wrote: 

I'm using a heavily relaxed NUMBER token in my lexer so I can provide
better error messages. The problem I'm having occurs when input such as
1..2 is reached. The '..' should be an OP_RANGE token, not part of the
number.

 

Please check the wiki for things like this, this is an FAQ witch a
complete example:

http://www.antlr.org/wiki/display/ANTLR3/Lexer+grammar+for+floating+poin
t%2C+dot%2C+range%2C+time+specs

Jim



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


More information about the antlr-interest mailing list