Consider the following grammar for a language L:

S → V = E
      | S ; S
      | if B then S
      | if B then S else S
V → x | y | z
E → V | 0 | 1 | 2 | 3 | 4
B → E === E

where, like in JavaScript, = is the assignment operator and === is the equality testing operator.
Now consider the following candidate for a statement S in the language L:

x = 1; y = 2; if x === y then y = 3

Which one of the following propositions best characterizes the above statement?

It is parsed ambiguously in L.
  • It is parsed in L with a unique parse tree.
  • It is not a statement in L.

Try to build the whole parse tree(s) for this statement with pencil and paper.

Review the definition of an ambiguous grammar.