Original Post
I am trying to write an expression parser that can handle nested (?
style if statements in C#. I have a library that can handle the bracket counting, evalution, etc that I downloaded, but it does not handle the if statements so I have to make my own parser for that. Now I have an idea of putting the nested statements into a tree type system where I break my original statement down into branches then solve it from the ends first. Its kinda hard to explain so here is an example.
Here is the original expression
My problem is finding a way to organize the original statement into a tree of this sort is a fast and accurate manner. So if anyone can give me some suggestions or some examples, I would be extremely thankful.
Thank you.
[edited by - ISOPimp on August 14, 2003 6:10:46 PM]
5 - ((6 > 2) ? 2 : 0) + 5 - 6 ( (8 + 2) - ( 8 > 2 ? (5 < 6 ? 1 : 0) : 2)) + 2here is the tree, and the tree after a first pass of the evalution:
My problem is finding a way to organize the original statement into a tree of this sort is a fast and accurate manner. So if anyone can give me some suggestions or some examples, I would be extremely thankful.
Thank you.
[edited by - ISOPimp on August 14, 2003 6:10:46 PM]