Skip to content
GATEiit

GATE CSE 2020 Q43: Which semantic rules are L-attributed

Question

Consider the productions A→PQA \to PQ and A→XYA \to XY. Each of the five non-terminals A, P, Q, X, and Y has two attributes: ss is a synthesized attribute, and ii is an inherited attribute. Consider the following rules.

Rule 1: P.i=A.i+2P.i = A.i + 2, Q.i=P.i+A.iQ.i = P.i + A.i, and A.s=P.s+Q.sA.s = P.s + Q.s

Rule 2: X.i=A.i+Y.sX.i = A.i + Y.s and Y.i=X.s+A.iY.i = X.s + A.i

Which one of the following is TRUE?

Try it: multiple choice: exactly one correct option

Select one option
Wrong answer costs 2/3 mark in GATE.
Show answer and explanation

Answer: B (official GATE 2020 final answer key)

Concept used: L-attributed: an inherited attribute of a child may depend only on the parent's inherited attributes and on attributes of siblings to its left.

First step: Check each inherited attribute: in Rule 2, X.iX.i uses Y.sY.s, and YY is to the right of XX.

Full step-by-step solution

Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.

Share this question

WhatsAppDownload image

Source: official GATE 2020 CS question paper and final answer key, organised by IIT Delhi. Question paper · Answer key