Skip to content

GATE CS Compiler Design questions

Practise Compiler Design questions for GATE CS. Explore official PYQs and original subject-wise quizzes, check answers and view available solutions. Free, no sign-in.

Subject, topic, year and type filter the full library. Match any choice within a filter, and all selected filter categories. Search, source and sort apply to this page.

20 on this page
Official PYQ2021Compiler DesignParsing (LL, LR)NAT · 2 marks
Consider the following augmented grammar with {#,@,<,>,a,b,c}\{ \#, @, <, >, a, b, c \} as the set of terminals. S’→SS→S#cSS→SSS→S@S→<S>S→aS→bS→c\begin{array}{l} S’ \rightarrow S \\ S \rightarrow S \# cS \\ S \rightarrow SS \\ S \rightarrow S @ \\ S \rightarrow < S > \\ S \rightarrow a \\ S \rightarrow b \\ S \rightarrow c \end{array}Let …
Official PYQ2020Compiler DesignRuntime EnvironmentsMCQ · 1 mark
Consider the following statements. Symbol table is accessed only during lexical analysis and syntax analysis. Compilers for programming languages that support recursion necessarily need heap storage for memory allocation in the run-time environment. Errors violating the condition ‘any variable must be declared before its use’ are detected during syntax …
Official PYQ2020Compiler DesignParsing (LL, LR)NAT · 1 mark
Consider the following grammar. S→aSB∣dS \rightarrow aSB \mid d B→bB \rightarrow b The number of reduction steps taken by a bottom-up parser while accepting the string aaadbbbaaadbbb is ___________.
Official PYQ2020Compiler DesignSyntax-directed TranslationMCQ · 2 marks
Consider the productions A→PQA \rightarrow PQ and A→XYA \rightarrow XY. Each of the five non-terminals A,P,Q,X,A, P, Q, X, and YY has two attributes: ss is a synthesized attribute, and ii is an inherited attribute. Consider the following rules. Rule 1:P.i=A.i+2, Q.i=P.i+A.i,1: P . i = A.i + 2, \: Q.i = P. i + A.i, and A.s=P.s+Q.sA.s = P.s +Q. s Rule 2:X.i=A.i+Y.s2: X.i = A.i + Y.s and …
Official PYQ2019Compiler DesignParsing (LL, LR)MCQ · 1 mark
Which one of the following kinds of derivation is used by LR parsers?
Official PYQ2019Compiler DesignSyntax-directed TranslationMCQ · 2 marks
Consider the following grammar and the semantic actions to support the inherited type declaration attributes. Let X1,X2,X3,X4,X5X_1, X_2, X_3, X_4, X_5, and X6X_6 be the placeholders for the non-terminals D,T,LD, T, L or L1L_1 in the following table: …
Official PYQ2019Compiler DesignParsing (LL, LR)NAT · 2 marks
Consider the augmented grammar given below: S’→SS’ \rightarrow S S→⟨L⟩∣idS \rightarrow \langle L \rangle \mid id L→L,S∣SL \rightarrow L, S \mid S Let I0=CLOSURE({[S’→⋅S]}).I_0 = \text{CLOSURE} (\{[S’ \rightarrow \cdot S ]\}). The number of items in the set GOTO(I0,⟨ )\text{GOTO} (I_0, \langle \: ) is______
Official PYQ2018Compiler DesignLexical AnalysisMCQ · 2 marks
A lexical analyzer uses the following patterns to recognize three tokens T1,T2T_1, T_2, and T3T_3 over the alphabet {a,b,c}\{a, b, c\}. T1:a?(b∣c)∗aT_1: a?(b \mid c)^\ast a T2:b?(a∣c)∗bT_2: b?(a \mid c)^\ast b T3:c?(b∣a)∗cT_3: c?(b \mid a)^\ast c Note that ‘x?x?’ means 00 or 11 occurrence of the symbol x.x. Note also that the analyzer outputs the token that matches the …
Official PYQ2018Compiler DesignLexical AnalysisMCQ · 1 mark
Which one of the following statements is FALSE?
Official PYQ2017Compiler DesignRuntime EnvironmentsNAT · 1 mark
Consider the expression (a−1)∗(((b+c)/3)+d)(a-1) * (((b+c)/3)+d). Let XX be the minimum number of registers required by an optimal code generation (without any register spill) algorithm for a load/store architecture, in which only load and store instructions can have memory operands and arithmetic instructions can have only register or immediate operands. ​​​​​​​The …
Official PYQ2017Compiler DesignParsing (LL, LR)NAT · 1 mark
Consider the following grammar: stmt →\rightarrow if expr then expr else expr; stmt | OˋÒ expr →\rightarrow term relop term | term term →\rightarrow id | number id →\rightarrow a | b | c number →[0−9]\rightarrow [0-9] where relop is a relational operator ((e.g., <,>,…),< , >,\ldots), OˋÒ refers to the empty statement, and if, then, else …
Official PYQ2017Compiler DesignIntermediate Code GenerationMCQ · 1 mark
Consider the following intermediate program in three address code p = a - b q = p * c p = u * v q = p + q Which one of the following corresponds to a static single assignment form of the above code?
Official PYQ2017Compiler DesignLexical AnalysisMCQ · 1 mark
Match the following according to input (from the left column) to the compiler phase (in the right column) that processes it: …
Official PYQ2017Compiler DesignParsing (LL, LR)MCQ · 1 mark
Consider the following expression grammar GG: E→E−T∣TE \rightarrow E-T \mid T T→T+F∣FT \rightarrow T + F \mid F F→(E)∣idF \rightarrow (E) \mid id Which of the following grammars is not left recursive, but is equivalent to GG?
Official PYQ2017Compiler DesignParsing (LL, LR)MCQ · 1 mark
Which of the following statements about parser is/are CORRECT? Canonical LR\text{Canonical LR} is more powerful than SLR\text{SLR} SLR\text{SLR} is more powerful than LALR\text{LALR} SLR\text{SLR} is more powerful than Canonical LR\text{Canonical LR}
Official PYQ2016Compiler DesignRuntime EnvironmentsMCQ · 1 mark
What will be the output of the following pseudo-code when parameters are passed by reference and dynamic scoping is assumed? a = 3; void n(x) { x = x * a; print (x); } void m(y) { a = 1 ; a = y - a; n(a); print (a); } void main () { m(a); }
Official PYQ2016Compiler DesignSyntax-directed TranslationMCQ · 1 mark
Consider the following Syntax Directed Translation Scheme (SDTS)( SDTS ), with non-terminals {S,A}\{S,A \} and terminals {a,b}\{a,b \}. S→aA{print 1}S \to aA \quad \{\text{print }1\} S→a{print 2}S \to a \quad \{\text{print }2\} A→Sb{print 3}A \to Sb \quad \{\text{print }3\} Using the above SDTSSDTS , the output printed by a bottom-up parser, for the input aabaab is:
Official PYQ2016Compiler DesignParsing (LL, LR)NAT · 1 mark
The attribute of three arithmetic operators in some programming language are given below. …
Official PYQ2016Compiler DesignData Flow Analyses: Constant Propagation, Liveness, CSENAT · 1 mark
Consider the following code segment. x = u - t; y = x * v; x = y + w; y = t - z; y = x * y; The minimum number of total variables required to convert the above code segment to static single assignment form is __________.
Official PYQ2016Compiler DesignParsing (LL, LR)MCQ · 1 mark
A student wrote two context-free grammars G1 and G2 for generating a single C-like array declaration. The dimension of the array is at least one. For example, int a[10] [3]; The grammars use D as the start symbol, and use six terminal symbols int ; id [ ] num. …