If a production is gt than another, it
can never be used to derive the second production. For
example if [E -> E * E]
gt [E -> E + E]
then
the derivations [E -> [E -> E + E] * E]
and
[E -> E * [E -> E + E]]
will never be allowed.
If a production is right with respect to another, then
the first production cannot derive the second one at the right-
most position of the first production. For example if
[E -> E * E]
right [E -> E + E]
then the
derivation [E -> [E -> E + E] * E]
is not allowed, but the
derivation [E -> E * [E -> E + E]]
is. Similarly the left
relation indicates that the first production cannot derive the
second at the left-most position. The relationship nonassoc
is a combination of both the right and left relationships.
The relationship between productions is inferred from the precedence rules and the precedence operators in a grammar specification file. The precedence rules setup a precedence ordering among terminals. Each precedence involving a terminal that has a precedence associated with it inherits the precedence of that symbol. One production is gt another if it has a higher precedence. Productions relate to themselves with the right, left or nonassoc relations if they contain a terminal with the given associativity.
The restrictions placed on the derivation by the precedence rules are used during parser construction in two ways. First, it is used to prevent certain items from being added to an itemset if the item represents a precedence conflict. Second, the computation of the FOLLOWS set is modified to compute the symbols that can follow each production, rather than the symbols that can follow each symbol. Symbols that indicate a conflict are not added to the FOLLOWS set of a production.
See Also:
See the PyGgy Home Page.