I have come quite far with writing an interpreter. What I understand
is that I need to identify the code written and put this down like an "Expression Tree" of any kind ?
I have tried to really understand the logic.
I do understand that I have to "break down" the whole statement in someway but I am not sure of what has priority over others.
I will take an example where I get stuck.
My first question is: When parsing this out to make an "Expression Tree", do you read this from Start to End like you read it or do you find priorities as ((..Longest distance between Equal lot of parantheses ..)) parantheses etc...Code:a > a2 && b > b2 && (((c > c2 || d > d2) && (e > e2 || f > f2)) || ((g > g2 || h > h2) && (i > i2 || j > j2))) && k > k2 && l > l2
If I start out to read from start to end with the example above. The first is easy:
a > a2 &&
b > b2
Then I got problem to understand what to do. I understand when looking at it that Either of the green parts has to be true and this I can identify by finding equal lot of parantheses.
Then if Either of the green areas is true then:
k> k2 &&
l > l2
My second question is that if I only would have statements with && wihout parantheses ex:
k> k2 &&
l > l2
I could save these into a vector vec and run this through my interpreter wich do works fine now.
My question here is how I will put all the statements that in this case are green. Will I use 2D, 3D vector for scenarios like this or how do the procedure work.
I am quite confused.
The mainquestion is how to build an expression tree. Do I have to read from left to right and understand what areas is together (((....))) and what have priorities over others like for math: * has priority over + etc...