Consider the following two syntax-directed definitions SDD1 and SDD2 for typeβ¦
2026
Consider the following two syntax-directed definitions SDD1 and SDD2 for type declarations.

π· is the start symbol, and πππ‘, πππππ‘ and ππ are the three terminals. The non-terminal π1 is the same as π and the non-terminal π·1 is the same as π·. Here, the subscript is used to differentiate the grammar symbols on the two sides of a production. The function ππ’π‘ updates the symbol table with the type information for an identifier. Let P and Q be the languages specified by grammars G1 and G2, respectively.
Which of the following statements is/are true?
- A.
The languages P and Q are the same
- B.
SDD2 is S-attributed and contains only synthesized attributes
- C.
SDD1 is L-attributed and contains only inherited attributes
- D.
The specifications of SDD1 and SDD2 are such that the same entries get added to the symbol table
Attempted by 3 students.
Show answer & explanation
Correct answer: A, B, D
Both grammars generate declarations of the form type followed by one or more identifiers.
Statement A is true. In G1, D β T V and V β Vβ id | id generate one or more identifiers after a type. In G2, D β Dβ id | T id generates the same strings by left recursion. Hence P = Q.
Statement B is true. In SDD2, every type attribute is synthesized: T.type is set from the terminal int/float, and D.type is computed from T.type or Dβ.type. No inherited attribute is used, so SDD2 is S-attributed.
Statement C is false. SDD1 is L-attributed because the inherited attribute V.type is passed to Vβ.type in a left-to-right manner. However, it does not contain only inherited attributes; T.type and D.type are synthesized attributes.
Statement D is true. In both SDDs, each identifier receives the type computed from the declaration, so the same put(id.entry, type) entries are added to the symbol table.
Therefore, the correct options are A, B, and D.