[antlr-interest] about space between operator

李志鹏 lizhipeng at gmail.com
Mon Dec 5 03:55:24 PST 2011


thank you

but not work.....

On Monday, December 5, 2011, Bart Kiers wrote:

> Try this:
>
> NOTEQUALS
>   :  '<>'
>   ;
>
> LT
>   :  '<' (' '+ '>' {$type=NOTEQUALS;})?
>   ;
>
> Regards,
>
> Bart.
>
>
> On Mon, Dec 5, 2011 at 8:14 AM, 李志鹏 <lizhipeng at gmail.com<javascript:_e({}, 'cvml', 'lizhipeng at gmail.com');>
> > wrote:
>
>> 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
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe:
>> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>
>
>


More information about the antlr-interest mailing list