Hello,
I am a absolute beginner to ANTLR. I already worked through some
tutorials but couldn't solve my problem. I would like to add some
numbers encoded by strings and print them to STDOUT or display them in
the ANTLR Debug environment (to test if my calculations were correct).
Two things I didn't find out:
how to display or print out used variables
how to use a global variable as a counter and inrease it e.g. cnt+=a
To start I found a simple grammar for chemical terms beeing able to
calculate the weight of things like "H2O" or "Cl2".
file : species*;
species : atom DIGITS? {};
atom returns [double weight]
: 'H' { $weight = 1.00794; }
| 'C' { $weight = 12.001; }
| 'Cl' { $weight = 35.453; }
| 'O' { $weight = 15.999; }
| 'S' { $weight = 32.06; }
;
DIGITS : ('0'..'9');
How could I embed a simple counter? For the beginning I would be happy
to sum up the weights ignoring the digits (e.g. H20 => 17.00694) How
can I display the result of the calculations in the debug environment?
For any help I would be gladful!
Regards,
Toby
--~--~---------~--~----~------------~-------~--~----~
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/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address