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

Discussion

During a reduction, the input pointer of an LR parser

  • A.moves backward by the length of the right side reduced
  • B.does not move, since no token is consumed by a reduction
  • C.advances by one token exactly as it does on a shift
  • D.advances by as many tokens as the right side has symbols

Answer: B

Correct answer: does not move, since no token is consumed by a reduction

A reduction rearranges what is already on the stack and consumes nothing from the input. Only a shift advances the pointer. This is why a parser may perform several reductions in succession on the same lookahead, and why the lookahead is examined repeatedly without being consumed.

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

Post your comment

Please log in or register to post a comment.