[antlr-interest] A little problem with DOT in numbers and as lineterminators.

Nigel Sheridan-Smith nbsherid at secsme.org.au
Thu Mar 10 16:03:37 PST 2005




> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Eric Merritt
> Sent: Friday, 11 March 2005 9:52 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] A little problem with DOT in numbers and as
> lineterminators.
> 
> I am using a dot as both a decimal separator in numbers and a
> statement terminator. I run into a problem when a number is at the end
> of a statement. For example
> 
>  origin := 0 @ 0.
> 
> Gives me huge problems because the NUMBER rule consumes the '.' and
> automatically expects another digit. When it doesn't find one it dies
> because it doesn't find the expected digit. What I need to to do is
> check the character after the '.' to see if it is a number. If a
> number follows it should continue to consume normally. If not it
> should unconsume the '.' and terminate the number rule. That would
> allow the '.' to be consumed by the DOT rule and form the expected
> statement terminator. Of course, I will still have problems with
> 

<snip>

> 
> // a numeric literal
> NUMBER
>   : (DIGIT DIGIT 'r')? (DIGIT)+ ('.' (DIGIT)+ EXPONENT)?
>   ;
> 

Is k>=2 or k=1? It will always try and consume the next '.' if k=1 since it
can't determine that a DIGIT always follows.

Nigel

--
Nigel Sheridan-Smith
PhD research student

Faculty of Engineering
University of Technology, Sydney
Phone: 02 9514 7946
Fax: 02 9514 2435



More information about the antlr-interest mailing list