Machine-translated by Google. Questions are authored in English.
Top

Discussion

A parser generator resolves a shift-reduce conflict by default in favour of

  • A.the reduce, which is said to produce the shorter of the parse trees
  • B.the production listed first in the grammar specification
  • C.reporting an error and refusing to generate the parser
  • D.the shift, which yields the nearest if behaviour for dangling else

Answer: D

Preferring the shift resolves the dangling else the way languages specify. The generator still reports the conflict so the author can check the default is what was intended. Silently accepting the default without reading the report is a common mistake.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.