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 PYQ2013Compiler DesignLocal OptimizationMCQ · 1 mark
The following code segment is executed on a processor which allows only register operands in its instructions. Each instruction can have atmost two source operands and one destination operand. Assume that all variables are dead after this code segment. c = a + b; d = c * a; e = c + a; x = c * c; if (x > a) { y = a * a; } else { d = d * d; e = e * e; } …
Official PYQ2013Compiler DesignRuntime EnvironmentsMCQ · 1 mark
The following code segment is executed on a processor which allows only register operands in its instructions. Each instruction can have atmost two source operands and one destination operand. Assume that all variables are dead after this code segment. c = a + b; d = c * a; e = c + a; x = c * c; if (x > a) { y = a * a; } else { d = d * d; e = e * e; } …
Official PYQ2013Compiler DesignParsing (LL, LR)MCQ · 1 mark
Consider the following two sets of LR(1)\textsf{LR(1)} items of an LR(1)\textsf{LR(1)} grammar.X→c.X,c∕dX→c.X,$X→.cX,c∕dX→.cX,$X→.d,c∕dX→.d,$\begin{array}{l|l} X \rightarrow c.X, c∕d &X → c.X, \$\\ X \rightarrow .cX, c∕ d& X → .cX, \$\\ X \rightarrow .d, c∕ d & X → .d, \$ \end{array}Which of the following statements related to merging of the two sets in the corresponding LALR\textsf{LALR} …
Official PYQ2013Compiler DesignParsing (LL, LR)MCQ · 1 mark
What is the maximum number of reduce moves that can be taken by a bottom-up parser for a grammar with no epsilon and unit-production (i.e., of type A→ϵA \rightarrow \epsilon and A→aA \rightarrow a) to parse a string with nn tokens?
Official PYQ2012Compiler DesignParsing (LL, LR)MCQ · 1 mark
For the grammar below, a partial LL(1)LL(1) parsing table is also presented along with the grammar. Entries that need to be filled are indicated as E1,E2,E1, E2, and E3E3. ε\varepsilon is the empty string, \$ indicates end of input, and, ∣\mid separates alternate right hand sides of productions. S→aAbB∣bAaB∣εS \rightarrow a A b B \mid b A a B \mid \varepsilon …
Official PYQ2011Compiler DesignRuntime EnvironmentsMCQ · 1 mark
Consider evaluating the following expression tree on a machine with load-store architecture in which memory can be accessed only through load and store instructions. The variables a,b,c,d,a, b, c, d, and ee are initially stored in memory. The binary operators used in this expression tree can be evaluated by the machine only when operands are in registers. The …
Official PYQ2011Compiler DesignParsing (LL, LR)MCQ · 1 mark
Consider two binary operators ‘↑’\text{‘} \uparrow \text{’} and ‘↓’\text{‘} \downarrow \text{’} with the precedence of operator ↓\downarrow being lower than that of the operator ↑\uparrow. Operator ↑\uparrow is right associative while operator ↓\downarrow is left associative. Which one of the following represents the parse tree for expression …
Official PYQ2011Compiler DesignLexical AnalysisMCQ · 1 mark
The lexical analysis for a modern computer language such as Java needs the power of which one of the following machine models in a necessary and sufficient sense?
Official PYQ2011Compiler DesignLexical AnalysisMCQ · 1 mark
In a compiler, keywords of a language are recognized during
Official PYQ2010Compiler DesignParsing (LL, LR)MCQ · 1 mark
The grammar S→aSa∣bS∣cS \to aSa \mid bS \mid c is
Official PYQ2010Compiler DesignRuntime EnvironmentsMCQ · 1 mark
The program below uses six temporary variables a,b,c,d,e,fa, b, c, d, e, f. a = 1 b = 10 c = 20 d = a + b e = c + d f = c + e b = c + e e = b + f d = 5 + e return d + f Assuming that all operations take their operands from registers, what is the minimum number of registers needed to execute this program without spilling?
Official PYQ2010Compiler DesignRuntime EnvironmentsMCQ · 1 mark
Which languages necessarily need heap allocation in the runtime environment?
Official PYQ2010Compiler DesignLexical AnalysisMCQ · 1 mark
Which data structure in a compiler is used for managing information about variables and their attributes?
Official PYQ2009Compiler DesignParsing (LL, LR)MCQ · 1 mark
Which of the following statements are TRUE? There exist parsing algorithms for some programming languages whose complexities are less than Θ(n3)\Theta(n^3) A programming language which allows recursion can be implemented with static storage allocation. No L-attributed definition can be evaluated in the framework of bottom-up parsing. Code improving …
Official PYQ2009Compiler DesignLexical AnalysisMCQ · 1 mark
Match all items in Group 1 with the correct options from those given in Group 2. …
Official PYQ2008Compiler DesignParsing (LL, LR)MCQ · 1 mark
An LALR(1) parser for a grammar G can have shift-reduce (S-R) conflicts if and only if
Official PYQ2008Compiler DesignRuntime EnvironmentsMCQ · 1 mark
Which of the following are true? A programming language which does not permit global variables of any kind and has no nesting of procedures/functions, but permits recursion can be implemented with static storage allocation Multi-level access link (or display) arrangement is needed to arrange activation records only if the programming language being …
Official PYQ2008Compiler DesignLocal OptimizationMCQ · 1 mark
Some code optimizations are carried out on the intermediate code because
Official PYQ2008Compiler DesignParsing (LL, LR)MCQ · 1 mark
Which of the following describes a handle (as applicable to LR-parsing) appropriately?
Official PYQ2008Compiler DesignParsing (LL, LR)MCQ · 1 mark
Which of the following statements are true? Every left-recursive grammar can be converted to a right-recursive grammar and vice-versa All ϵ\epsilon-productions can be removed from any context-free grammar by suitable transformations The language generated by a context-free grammar all of whose productions are of the form X→wX \rightarrow w or …