A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

Discussion Forum

Que. 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:It detects shift-reduce conflict, and resolves the conflict in favor of a shift over a reduce action
Confused About the Answer? Ask for Details Here
Know Explanation? Add it Here

Similar Questions: