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

Discussion

Left recursion in a grammar is

  • A.fatal to an LR parser exactly as it is to a top down parser
  • B.quite impossible to express in a context free grammar at all
  • C.automatically removed by the parser generator before use
  • D.welcome in an LR parser, as it keeps the parsing stack shallow

Answer: D

An iterative construct written left recursively is reduced item by item, so the stack stays short. Written right recursively the whole list must be stacked before any reduction occurs. A long initialiser list makes the difference plainly visible.

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

Post your comment

Please log in or register to post a comment.