
Hi,
I was wondering if there is any easy way to find out if a given expression will result in a boolean value or a numeric value.
For example, if I have an expression (A + B * C)/D, I know this will result in a numeric value, whereas an expression like ((A & B) = B) would result in a boolean value. Is there a way I can check this using NCalc?
In my specific requirement, user indicates that he wants to build a boolean/numeric expression, I need to ensure that the expression that he has supplied indeed results in a boolean/numeric value. Initially I though, just looking for boolean operators in
the expression should tell me that, but expressions like (A & B) (bitwise AND) actually results in a numeric value.
Any ideas?
Thanks,
Regards,
 Vikram


Coordinator
Feb 27, 2010 at 7:49 AM

Well, everything with '&&' or 'and' results in boolean, whereas '&' only results in numeric value. In a more scientific way, you can create a specific Visitor implementation for evaluating each node and returning the intended type. Just like
the ExpressionVisitor class.



Thanks Sebastien,
I will try that out.
Regards,
 Vikram



Hi Sebastien,
I'm new to NCal so I would appreciate it if you could give me an example or more info on the visitor implementation.
Many thanks,
Nero



Hi Nero,
We did try to implement the visitor as suggested by Sebastien, but eventually we switched to using flee.codeplex.com, which was more suitable for our requirements.
Sorry  couldn't be much help.
Regards,
Vikram

