[antlr-interest] Java.g grammar issues & potential fix
Terence Parr
parrt at cs.usfca.edu
Wed Apr 14 11:46:01 PDT 2004
On Apr 7, 2004, at 1:10 AM, Vincent Mallet wrote:
> 1. the grammar won't accept octal-looking floats or doubles
> (09d for example)
> 2. the grammar will accept hexadecimal numbers with a fractional
> part (0x12.34 for example)
>
> I have seen a fix for problem #1 in java.g version 1.21-october-2003
> but #2 is definitely broken.
>
> In an attempt to clarify that part of the grammar I came up with a
> version of the NUM_INT lexer rule which seems to be more correct and
> potentially easier to read (indentation might need some work).
>
> If you have an opinion on the new rule I would love to hear it.
>
It seems easier to read, but you've added a syntactic predicate that
will execute upon every numeric value I think. Given that this could
cause lots of exceptions, I'm guessing it would seriously degrade the
lexer's speed (probably bad as it is). ;)
It is often the case that being super precise in the grammar can cost
you. Probably best to leave this syntactic hole as there are always
holes like this.
Regards,
Terence
--
Professor Comp. Sci., University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
Cofounder, http://www.knowspam.net enjoy email again!
Cofounder, http://www.peerscope.com pure link sharing
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list