Computer Science and Information Technology
GATE CSE Compiler Design PYQs
Build your understanding with focused practice from past exam papers.
Questions 41–50 of 55. Imported answers require independent review unless marked reviewed.
Question 24
Open questionCSNAT1 markNeeds review
Consider the following grammar.
The number of reduction steps taken by a bottom-up parser while accepting the string
is ________.Log in to check the answer
You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answerQuestion 33
Open questionCSMCQ2 marksNeeds review
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?
Your answerChoose one option.
Log in to check the answer
You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answerQuestion 3
Open questionCSMCQ1 markNeeds review
Which one of the following kinds of derivation is used by LR parsers?
Your answerChoose one option.
Log in to check the answer
You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answerQuestion 19
Open questionCSNAT1 markNeeds review
Consider the grammar given below:
S → Aa
A → BD
B → b | ε
D → d | ε
Let a, b, d, and $ be indexed as follows:
a | b | d | $ |
|---|---|---|---|
3 | 2 | 1 | 0 |
Compute the FOLLOW set of the non-terminal B and write the index values for the symbols in the FOLLOW set in the descending order. (For example, if the FOLLOW set is , then the answer should be 3210)
Answer: __________.
Log in to check the answer
You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answerQuestion 36
Open questionCSMCQ2 marksNeeds review
Consider the following grammar and the semantic actions to support the inherited type declaration attributes. Let
,
,
,
,
, and
be the placeholders for the non-terminals D, T, L or
in the following table:Production rule | Semantic action |
|---|---|
D → T L | .type = .type |
T → int | T.type = int |
T → float | T.type = float |
L → , id | .type = .type; addType(id.entry, .type) |
L → id | addType(id.entry, .type) |
Which one of the following are the appropriate choices for
,
,
and
?Your answerChoose one option.
Log in to check the answer
You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answerQuestion 43
Open questionCSNAT2 marksNeeds review
Consider the augmented grammar given below:
S' → •S
S → ⟨L⟩ | id
L → L,S | S
Let I₀ = CLOSURE ({[S' → •S]}). The number of items in the set GOTO (I₀, ⟨) is: ________.
Log in to check the answer
You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answerQuestion 8
Open questionCSMCQ1 markNeeds review
Which one of the following statements is FALSE?
Your answerChoose one option.
Log in to check the answer
You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answerQuestion 37
Open questionCSMCQ2 marksNeeds review
A lexical analyzer uses the following patterns to recognize three tokens
,
, and
over the alphabet
.
:
:
:
Note that ‘
’ means 0 or 1 occurrence of the symbol x. Note also that the analyzer outputs the token that matches the longest possible prefix.If the string
is processed by the analyzer, which one of the following is the sequence of tokens it outputs?Your answerChoose one option.
Log in to check the answer
You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answerQuestion 38
Open questionCSMCQ2 marksNeeds review
Consider the following parse tree for the expression
, involving two binary operators
and
. 
Which one of the following is correct for the given parse tree?
Your answerChoose one option.
Log in to check the answer
You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answerQuestion 5
Open questionCSMCQ1 markNeeds review
Match the following according to input (from the left column) to the compiler phase (in the right column) that processes it:
(P) Syntax tree
(Q) Character stream
(R) Intermediate representation
(S) Token stream
(i) Code generator
(ii) Syntax analyser
(iii) Semantic analyser
(iv) Lexical analyser
Your answerChoose one option.
Log in to check the answer
You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer