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

Discussion

Match each associativity declaration with the parser action taken on equal precedence.
List I
A. left associative
B. right associative
C. non associative
D. no declaration at all
List II
1. report an error
2. reduce
3. conflict reported by the generator
4. shift

  • A.A-4, B-2, C-1, D-3
  • B.A-2, B-4, C-3, D-1
  • C.A-3, B-1, C-4, D-2
  • D.A-2, B-4, C-1, D-3

Answer: D

Correct answer: A-2, B-4, C-1, D-3

Four declarations and four behaviours on equal precedence. Left associativity reduces, closing the left operand first; right associativity shifts, deferring the reduction; non-associativity reports an error, which is how a construct like a < b < c is forbidden outright; and with no declaration at all there is nothing to settle the conflict, so the generator reports it.

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

Post your comment

Please log in or register to post a comment.