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

Discussion

The reason a mid-production action cannot simply be executed when the parser reaches that point in a bottom up parse is that

  • A.the parser does not yet know which production it is working on
  • B.the value stack has already been emptied by that stage
  • C.actions are forbidden anywhere but at the end of a right side
  • D.the lookahead token has not been read from the scanner yet

Answer: A

Until a reduction occurs the parser has committed to nothing, so there is no moment at which it could know that this particular action applies. Inserting an empty nonterminal manufactures a reduction at the wanted point, which is how generators implement such actions and also why they sometimes introduce conflicts.

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

Post your comment

Please log in or register to post a comment.