Essentially, I want a return of type double for e.g.
3
1.523
1 2/3
Below's my grammar with C# actions, and I get
"Decision can match input such as "INT SLASH INT" using multiple
alternatives" in Antlrworks.
Thanks for your help!!
Sven
//
//Trouble Grammar
//
number returns [double n]
:
(INT {$n = (double)int.Parse($INT.text);}) (f = fraction {$n
+= f;})? |
f = fraction {$n = f;} |
AFLOAT {$n = double.Parse($AFLOAT.text);};
fraction returns [double f] :
i1=INT SLASH i2=INT {$f = (double)int.Parse($i1.text) /
(double)int.Parse($i2.text);};
AFLOAT : INT DOT INT?;
INT : '0'..'9'+;
SLASH : '/';
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address