Exercise 34. Analyzers
You now have a parser that should be producing a tree of grammar production objects. I’ll call this your “parse tree,” and it means you can analyze the whole program by starting at the top of the parse tree and then “walking” it until you’ve visited every node. You’ve done something like this when you were learning about the
TSTree data structures. You started at the top and visited each node, and the order you visited them in (depth-first, breadth-first, in-order, etc.) determined how the nodes were processed. Your parse tree has the same capability, and your next step in writing the little Python interpreter is to walk the tree and analyze it.
The analyzer’s job is to find semantic mistakes in your grammar ...