Papers-Articles-Workshop-Seminar-Conference-and-Symosium
October 7, 2023Compiler-Design
October 7, 2023Compiler-Design
| Question 72 |
Consider the following expression grammar. The semantic 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>sup>(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?
| It detects recursion and eliminates recursion
| |
| It detects reduce-reduce conflict, and resolves
| |
| It detects shift-reduce conflict, and resolves the conflict in favor of a shift over a reduce action | |
| It detects shift-reduce conflict, and resolves the conflict in favor of a reduce over a shift action
|
Question 72 Explanation:
Yacc favours shift move in case of SR conflict.
Correct Answer: C
Question 72 Explanation:
Yacc favours shift move in case of SR conflict.
