[antlr-interest] Implicit Typecasting with a tree grammar
Tilman Bender
tbender at stud.hs-heilbronn.de
Thu Apr 9 04:35:49 PDT 2009
Hi there,
I am still playing with my interpreter for arithmetic expressions.
Now I would like to work with mixed expressions containing integer and
floating point numbers.
When doing so I would like to have the integers automatically
"uppercasted" when
they occur in an expression together with floats.
So what I currently do is, that I have a Java class providing methods
for the respective
arithmetic operations and invoke it from my interpreter:
^(MINUS a=expr b=expr) { $value = Arithmetic.subtract($a.value,
$b.value);}
In the add-method I check for the type of the parameters passed in and
do the conversion
to BigDecimal magic.
However I would like to make this "implicit uppercast" independant
from the host language for
my interpreter to minimize the amount of code I have to change, when
switching the host language.
Has anyone already done such a thing via a TreeWalker?
Tilman Bender
Student des Software Engineering
Hochschule Heilbronn
tbender at stud.hs-heilbronn.de
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090409/00e68bb4/attachment.html
More information about the antlr-interest
mailing list