Hi,
In my language specification (using EBNF), including the following
contents:
...
value = ivalue | fvalue
ivalue = any positive integer
fvalue = any positive integer or float
...
Now I have written an garmer file and generate java code. I hope when the
parser read the token of ivalue, fvalue, it can recognized it's a value and
then return the value.
I have added the code as the following in my gramer file.
...
ivalue returns [int value]
:IVALUE {$value=Integer.parseInt($IVALUE.text);}
;
...
IVALUE : '1'..'9'('0'..'9')*;
FVALUE :IVALUE | (('0' | ('1'..'9')*) '.' ('1'..'9')*);
My problem is fvalue, it may be integer or float, that means the return
type is flexible. So I don't know the type of return value.
fvalue returms [?? value]
....
And the value mentioned above (may be integer or float) has the same
problem.
How can I solve this problems? Can someone give me some advice? Thank you!
Cheers!
Xiaohua
_______________________________________________
antlr-dev mailing list
[email protected]
http://www.antlr.org/mailman/listinfo/antlr-dev