Next: Application and diagnostic behavior, Previous: Evaluating a parse, Up: Terms [Contents][Index]
In real life, the structure of a parse is usually a means to an end. Grammars usually have a semantics associated with them, and what the user actually wants is the value of the parse according to the semantics.
The tree representation is especially useful when evaluating a parse. In the traditional method of evaluating a parse tree, every node which represents a terminal symbol has a value associated with it on input. Recall that nodes are often called “instances” of their symbols or rules. Semantics is associated with instances of rules or of lexemes.
Non-null inner nodes take their semantics from the rule whose LHS they represent. Nulled nodes are dealt with as special cases.
The semantics for a rule describe how to calculate the value of the node which represents the LHS (the parent node) from the values of zero or more of the nodes which represent the RHS symbols (child nodes). Values are computed recursively, bottom-up. The value of a parse tree is the value of its start symbol.