Consider the following grammars:

Grammar 1: E → T | E ^ T
T → I | ( E )
Grammar 2: E → T | T ^ E
T → I | ( E )
Grammar 3: E → I | E ^ E | ( E)

If ^ represents exponentiation, how many of these grammars force 2^3^2 to evaluate to 512?

1
  • 0
  • 2
  • 3

Which operator associativity (left or right) does ^ need to have for 2^3^2 to evaluate to 512?

How does left- and right-recursion patterns in a production correspond to the associativity of the operator defined by the production?

How does the double-recursion pattern (i.e., simultaneous left- and right-recursion) in a production impact the associativity of the operator defined by the production?