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

Discussion

An LL(1) grammar for arithmetic expressions typically expresses repetition of the plus operator with

  • A.an ambiguous production resolved by precedence declarations
  • B.a separate grammar used only for expression parsing
  • C.a right recursive auxiliary nonterminal after left recursion removal
  • D.a left recursive production that the parser is able to handle directly

Answer: C

The classic E goes to TE prime with E prime going to plus TE prime or epsilon is exactly the transformed form. Associativity must then be restored in the semantic actions. Forgetting that step yields an expression evaluator that groups the wrong way.

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

Post your comment

Please log in or register to post a comment.