[antlr-interest] about space between operator

李志鹏 lizhipeng at gmail.com
Sun Dec 4 23:14:13 PST 2011


hello all

I have a very simple grammar like this:
grammar AA;

expression
: TYPE_DOUBLE (NOTEQUALS | LT)  TYPE_DOUBLE EOF
;

NOTEQUALS
: '<>' | '<' (' '+) '>'
;

LT : '<';

TYPE_DOUBLE
:   Digit+ '.' Digit*
|   '.' Digit+
;

fragment
Digit
: '0'..'9'
;
WS
:  (' '|'\r'|'\t'|'\u000C'|'\n')+ {$channel=HIDDEN;}
;

if input "1.6<>1.7" or "1.6<1.7" or "1.6 <>  1.7", it is ok
but input "1.6 < 1.7"(has white space on both sides '<' ), the grammar
can't resolve it

if I change as this
NOTEQUALS
: '<>'
;
above all are ok, but "1.6 <   > 1.7" is not work, I wan't use "<>" to mean
not equal,  and white space is allow between "< >", How Can i do?

thank you all


More information about the antlr-interest mailing list