[antlr-interest] REAL or int or Range

Alexander Gängel alexander at gaengel.de
Wed Jan 9 08:55:59 PST 2008


I have a Problem in My grammar

I try to decide if I got in Integer an Real or an Range like 0..9

It works for Int and Real but if I input 0..9 in Antlrworks in the Input 
frame is only 9 and the Parse Tree is like ths:

Where is the Rest of my Input?

My grammar is like this:
grammar test;
start    :
    uint_or_real
    |(uint_or_real RANGE uint_or_real)+;

uint_or_real
    :   
    UINT
    |REAL;

REAL
        :   
        UINT 
            (
                    Exponent FloatTypeSuffix?
                    |FloatTypeSuffix
                        |
                                (DOT (UINT Exponent? FloatTypeSuffix?
                        )
                )
            );


fragment
Exponent : ('e'|'E') ('+'|'-')? UINT ;
UINT : DIGIT_10+ ;

fragment DIGIT_10 : '0'..'9' ;

fragment
FloatTypeSuffix : ('f'|'F'|'d'|'D') ;

RANGE    :    '..';
DOT    :    '.';

WS    :  (' '|'\r'|'\t'|'\u000C'|'\n') {$channel=HIDDEN;};
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080109/8ee07091/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: parseTree.jpg
Type: image/jpeg
Size: 3680 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20080109/8ee07091/attachment.jpg 


More information about the antlr-interest mailing list