[antlr-interest] basic doubt to assign value to AST nodes!!
mark twain
himmy070 at gmail.com
Thu Aug 21 07:43:05 PDT 2008
Hi Every1...
I am newbie here and just few days back started working on this cool ANTLR .
Have a very basic question on assigning the values to AST nodes. So far, I
am able to generate the AST supporting simple arithmetic operations and
also able to evaluate the tree. Just an example, if my
input expression is: a = 1+ 2 , I can generate following AST and also able
to evaluate it and get output : 3
AST : =
/ \
a +
/ \
1 2
This way if my expression changes to a = 3+4(say) I generate AST again and
evaluate the output from AST
But now say instead of 1 and 2, I make it generic and use b and c to
generate the AST. Now, is there is anyway I can assign the values to b and c
of AST without a need to create AST again and again for different values of
b and c. I want flow of execution code to be:
===========================================
func1 (a = b + c) // generate the AST from variables *just once*
func2 (2, 3) //expected output value of a = 5
func2(4,5) //expected output value of a = 9
...
...
==========================================
So, this way I wanna create AST only if my arithmetic formula changes......
cheers:)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080821/20bf1a29/attachment.html
More information about the antlr-interest
mailing list