Consider the productions A → PQ and A → XY. Each of the five non-terminals A, P, Q, X and Y has two attributes: s is a synthesized attribute, and i is an inherited attribute. Consider the following rules. Rule 1: P.i = A.i + 2, Q.i = P.i + A.i, and A.s = P.s + Q.s Rule 2: X.i = A.i + Y.s and Y.i = X.s + A.i Which one of the following is TRUE?

Consider the productions A → PQ and A → XY. Each of the five non-terminals A, P, Q, X and Y has two attributes: s is a synthesized attribute, and i is an inherited attribute. Consider the following rules. Rule 1: P.i = A.i + 2, Q.i = P.i + A.i, and A.s = P.s + Q.s Rule 2: X.i = A.i + Y.s and Y.i = X.s + A.i Which one of the following is TRUE? Correct Answer Only Rule 1 is L-attributed.

Concept:

A rule is said to be L- attributed if it used both synthesized and inherited attributes. But, in the inherited attribute, we can get attribute values from the parent or from the left siblings, but not the right sibling.

Rule 1 is L- attributed.

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

Explanation:

P.i = A.i + 2     ...{This is an inherited attribute, as child P is getting value from parent A}

Q.i = P.i + A.i     ...{This is also inherited attribute and Q is getting value from parent P and left sibling A}

A.s = P.s + Q.s     ...{This is synthesized attribute as Parent A is taking values from children P and Q}

Rule 2 is not L- attributed

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

Explanation:

X.i = A.i + Y.s     ...{Child X is taking attribute value from parent A and right sibling Y}

Therefore, this violates the conditions of L- attributed definitions.

Related Questions

In the question below, are given a statement followed by three courses of actions numbered I, II and III. On the basis of the information given, you have to assume everything in the statement to be true, and then decide which of the following suggested courses of actions logically follow(s) for pursuing. Statement: Soon VAT 69 whiskey and Smirnoff Vodka will not be found on the shelves of Delhi Liquor stores owing to the duplication of barcode by manufacturer United Limited. The Delhi government financial commissioner blacklisted the manufacturer. Financial commissioner Anindo Majumdar had said in an order dated September 14, that USL had violated provisions of the Delhi Excise Act, 2009 and Delhi Excise Rules, 2010 by using unauthorized and loose barcodes, which could be easily misused. Courses of action: I. The ban will force United Spirits Limited not to sell its liquor in the national capital for two years. II. the appellant violated provisions of the Delhi Excise Act, 2009, Delhi Excise Rules, 2010, the terms and conditions of the license issued to it and the standard operating procedure framed by the Delhi Excise Department and that consequently the department has rightly imposed the penalty of blacklisting under Rule 70 of the Delhi Excise Rules, 2010 upon United Spirits LTD (USL), Aurangabad. III. United Limited has been blacklisted by the Delhi government financial commissioner.