Q. Consider the following expression grammar. The seman-tic rules for expression
calculation are stated next to each grammar production.
E → number E.val = number. val
| E '+' E E(1).val = E(2).val + E(3).val
| E '×' E E(1).val = E(2).val × E(3).val
The above grammar and the semantic rules are fed to a yacc tool (which is an LALR (1)
parser generator) for parsing and evaluating arithmetic expressions. Which one of the
following is true about the action of yacc for the given grammar?

  • (A) It detects recursion and eliminates recursion
  • (B) It detects reduce-reduce conflict, and resolves
  • (C) It detects shift-reduce conflict, and resolves the conflict in favor of a shift over a reduce action
  • (D) It detects shift-reduce conflict, and resolves the conflict in favor of a reduce over a shift action
πŸ’¬ Discuss
βœ… Correct Answer: (C) It detects shift-reduce conflict, and resolves the conflict in favor of a shift over a reduce action

You must be Logged in to update hint/solution

πŸ’¬ Discussion

πŸ“Š Question Analytics

πŸ‘οΈ
504
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
93%
Success Rate