[antlr-interest] problem with characters in grammar

Wojciech Tomasz Cichon wtcichon at googlemail.com
Sat Mar 19 12:14:07 PDT 2011


i decided to extend my grammar for characters
and i added:

factor  :  '-'? (NUMBER )
        | character
       ;
character : AP (LETTER | NUMBER) AP;
AP : '\'';
LETTER :  'A'..'Z' | 'a'..'Z';
NUMBER :  '0'..'9'+;


it's compile with no error
which is good, 

i running program and i’m sending 
2+3*3 >= 'a' + 2

and that gave me
(>= (+ 2 (* 3 3)) (+ ' ' 2))
line 1:10 no viable alternative at character 'a'

clearly this grammar can’t handle characters
can somebody tell me what i’m doing wrong


More information about the antlr-interest mailing list