Le mardi 06 octobre 2009 à 01:40 -0400, houtan a écrit :
I just would like to check two things regarding the implementation of the Expectation operator:
- Where should I check that arg1 is numeric in
"EXPECTATION(arg1)(arg2)": during parsing, within the checkPass(), or during the transformPass() while dealing with the expectation operator?
The checkPass() is probably a better place.
However, I'm not sure whether you should allow any arbitrary expression as the first argument of the EXPECTATION operator. For the moment, we are only accepting signed integers. So IMHO it is probably better to enforce this restriction during the parsing, using the "signed_integer" rule of the Bison parser.
- I also want to make sure that, after creating auxiliary variables
for every instance of oExpectation, I should erase the associated BinaryOpNode.
No, you should not erase any node. Your node may be shared with another expression with which you have not yet dealt. And it does not matter if the expression tree contains unused nodes: they are simply not referenced by the top level equations/derivatives, but this is not a problem. If the tree grows too much, we could implement a garbage collector, but memory consumption does not seem to be an issue for the moment.
Best,