[antlr-interest] Problem with REAL and INT
Imran A R (RBIN/EDM2)
Imran.AR at in.bosch.com
Sun Sep 10 23:35:26 PDT 2006
Hello all
I have a antlr lexer for REAL and INT grammer as follows.
INT: (DIGITSET '.')=> REAL { $setType (REAL) ;}
| DIGITSET {$setType (INT) ;};
protected DIGITSET: ('0'..'9')('0'..'9')*;
protected ALPHABETS :'a'..'z' |'A'..'Z';
protected REAL: DIGITSET '.' DIGITSET;
protected PARTIALSTRING : (ALPHABETS|'_') (ALPHABETS |'0'..'9'
| '_' )*;
IDENT options{ testLiterals = true;}: PARTIALSTRING ( '.'
PARTIALSTRING )* ;
I have a small parser as follows
rule:(speed:"speed" EQUAL speed_val:REAL SEMI){
printf("%s\n",speed->getText().c_str());
printf("%s\n",speed_val->getText().c_str());
};
when I give speed = 19.2;, it is working fine.
but when I give 19 it is giving
"line 1:8: expecting REAL, found '19'"
Can you please help me to solve this problem.
Thank you
Imran
More information about the antlr-interest
mailing list