Original Post
Hi, I'm writing a script engine and have the scripts parsed and tokenized, including expressions but I can't manage to code something that evaluates the expressions. Can someone point me in the direction of a good easy to understand tutorial? I've found a couple but they've been complex and not easy to follow at all. What interests most are expression trees. Since my tokenized set up is already one object per token, adding a tree/leaf structure would be very simple i'm just not sure of two things. 1.How do I construct the tree? Do I parse from left to right of the expression? It being very important () parantheses(sp?) is taken into account. I'd be grateful if someone posted some psudeo code that does this, given tokens can be Multiply,Plus,Sub,Or Numeric (there are more but those are the essential ones) 2.Once I have a tree constructed, how do I evalute it maintaing operate precedence? A good tutorial on expression trees anywhere? Or anyone know of some code that lets me manually construct an expression tree by passing tokes and then can evaluate it?