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.

 

NUMBER

@after

{

ClassifyNumber($text);

}

        :       '.'? '0'..'9'

                (       // <-- It throws a NoViableAltException at this
decision when next the input is '..'

                        (       '0'..'9'

                        |       'a'..'d'

                        |       'f'..'z'

                        |       'A'..'D'

                        |       'F'..'Z'

                        |       ('.' ~'.') => '.'

                        )

                |       ('e' | 'E')

                        (       ('+'|'-') => ('+' | '-')?

                                '0'..'9'

                        )?

                )*

        ;

 

I found that I had to rearrange the rule in a strange way to get rid of
the error:

 

NUMBER

@after

{

ClassifyNumber($text);

}

        :       '.'? '0'..'9'

                (       (       (       '0'..'9'

                                |       'a'..'d'

                                |       'f'..'z'

                                |       'A'..'D'

                                |       'F'..'Z'

                                )

                        |       '.' ('0'..'9' | 'a'..'d' | 'f'..'z' |
'A'..'D' | 'F'..'Z')

                        |       '.'? ('e' | 'E')

                                (       ('+'|'-') => ('+' | '-')?

                                        '0'..'9'

                                )?

                        )

                )*

                (       ('.' ~'.') => '.'

                )?

        ;

 

Thank you,

Sam Harwell


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

Reply via email to