Evaluating Statements Using a Parse Tree
-
01-11-2019 - |
Question
I'm building a compiler. I already have a parse tree which I built using Bison for a grammar similar to the ANSI C grammar in this link. I see that for multiplicative expression in my parse tree, there can be 3 children e.g.
child 1: multiplicative_expression
child 2: '*'
child 3: cast_expression
I expect to implement a new class for interpreting the parse tree. However, I have no idea how to even traverse the parse tree in order to evaluate the statements. How do I traverse the tree properly in order to interpret all the types of statements? I want to interpret not only multiplicative statements but also if-else statements etc.
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with cs.stackexchange