...
2018 July 22 NTA UGC NET Paper 1
October 7, 2023
Compiler-Design
October 7, 2023
2018 July 22 NTA UGC NET Paper 1
October 7, 2023
Compiler-Design
October 7, 2023

Compiler-Design

Question 72

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>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?

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
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.
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!