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
Answer» C. It detects shift-reduce conflict, and resolves the conflict in favor of a shift over a reduce action
1.2k
0
Do you find this helpful?
13

Discussion

No comments yet

Related MCQs