[antlr-interest] to recognise interger and real in one rule
=?gb2312?q?=CB=EF=BC=CD=B8=D5=20Jigang=20(Robert)=20Sun?=
sunjigang1965 at yahoo.com.cn
Fri Jun 2 13:29:45 PDT 2006
In lexer grammar, I try to recognise interger and real in one rule,
BasicValue: ( Sign)? (Digit)+ {$setType(IntDenot);} ( '.' (Digit)+ (Exponent)?
{$setType(RealDenot);})? ;
protected Exponent : 'E' (Sign)? (Digit)+ ;
In parser grammar, put
basicValue :BaiscValue EOF;
when parsing "78.9", produces error message:
line 1:2: expecting "BaiscValue", found '78.9'.
Further more I wish, with action {$setType(IntDenot);} and {$setType(RealDenot);} in lexical
grammar, the token type BasicValue is redundant.
Robert
__________________________________________________
¸Ï¿ì×¢²áÑÅ»¢³¬´óÈÝÁ¿Ãâ·ÑÓÊÏä?
http://cn.mail.yahoo.com
More information about the antlr-interest
mailing list