CD |Gate-2020| Previous Year Questions| Set-1

Set-15 GATE-2006 CD

CD |Gate-2020| Compiler Design

  1. Consider the following grammar.
    S->aSB| d
    The number of reduction steps taken by a bottom-up parser while accepting the string aaadbbb is _______. [GATE – 2020]

a. 7
b. 8
c. 9
d. 10

Answer : a)

  1. Consider the following statements.
    I. Symbol table is accessed only during lexical analysis and syntax analysis.
    II. Compilers for programming languages that support recursion necessarily need heap storage for memory allocation in the run-time environment.
    III. Errors violating the condition ‘any variable must be declared before its use’ are detected during syntax analysis.
    Which of the above statements is/are TRUE? [GATE – 2020]

a. II only
b. I only
c. I and III only
d. None of I, II and III

Answer:  d)
CD |Gate-2020|

  1. 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? [GATE – 2020]

a. Only Rule 2 is L-attributed.
b. Only Rule 1 is L-attributed
c. Both Rule 1 and Rule 2 are L-attributed.
d. Neither Rule 1 nor Rule 2 is L-attributed.

Answer : b)
CD |Gate-2020|


Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *