2025 question paper
Compiler Design
26 questions
Q1a. Which phase of compiler converts source code into tokens? (i) Code generation (ii) Lexical analysis (iii) Optimization (iv) Parsing20252m
Module 1 : Introduction & Lexical Analysis
View this question on its own page →Which phase of compiler converts source code into tokens?
(i) Code generation
(ii) Lexical analysis
(iii) Optimization
(iv) ParsingQ1b. Which data structure is mainly used in lexical analysis? (i) Queue (ii) Stack (iii) Tree (iv) Finite automata20252m
Module 1 : Introduction & Lexical Analysis
View this question on its own page →Which data structure is mainly used in lexical analysis?
(i) Queue
(ii) Stack
(iii) Tree
(iv) Finite automataQ1c. Which automaton accepts regular languages? (i) PDA (ii) DFA (iii) Turing machine (iv) LBA20252m
Module 1 : Introduction & Lexical Analysis
View this question on its own page →Which automaton accepts regular languages?
(i) PDA
(ii) DFA
(iii) Turing machine
(iv) LBAQ1d. Which parser uses leftmost derivation? (i) LL parser (ii) Bottom-up parser (iii) LR parser (iv) Operator precedence parser20252m
Module 2 : Syntax Analysis (Parser)
View this question on its own page →Which parser uses leftmost derivation?
(i) LL parser
(ii) Bottom-up parser
(iii) LR parser
(iv) Operator precedence parserQ1e. LR parsing is a (i) Top-down parsing (ii) Bottom-up parsing (iii) Recursive parsing (iv) Predictive parsing20252m
Module 2 : Syntax Analysis (Parser)
View this question on its own page →LR parsing is a
(i) Top-down parsing
(ii) Bottom-up parsing
(iii) Recursive parsing
(iv) Predictive parsingQ1f. Which parsing technique is most powerful? (i) LL(1) (ii) Recursive descent (iii) LR(1) (iv) Operator precedence20252m
Module 2 : Syntax Analysis (Parser)
View this question on its own page →Which parsing technique is most powerful?
(i) LL(1)
(ii) Recursive descent
(iii) LR(1)
(iv) Operator precedenceQ1g. Synthesized attributes are evaluated from (i) Parent to child (ii) Child to parent (iii) Left to right (iv) Right to left20252m
Module 3 : Semantic Analysis & Symbol Table
View this question on its own page →Synthesized attributes are evaluated from
(i) Parent to child
(ii) Child to parent
(iii) Left to right
(iv) Right to leftQ1h. Which attribute is commonly stored in symbol table? (i) Variable type (ii) Address (iii) Scope (iv) All of these20252m
Module 3 : Semantic Analysis & Symbol Table
View this question on its own page →Which attribute is commonly stored in symbol table?
(i) Variable type
(ii) Address
(iii) Scope
(iv) All of theseQ1i. Which optimization removes repeated computations? (i) Dead code elimination (ii) Common sub-expression elimination (iii) Loop optimization (iv) Register allocation20252m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Which optimization removes repeated computations?
(i) Dead code elimination
(ii) Common sub-expression elimination
(iii) Loop optimization
(iv) Register allocationQ1j. A three-address code uses (i) One operand (ii) Two operands (iii) Three operands (iv) No operands20252m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →A three-address code uses
(i) One operand
(ii) Two operands
(iii) Three operands
(iv) No operandsQ2a. Define Compiler. Explain all phases of a compiler with neat diagram.20257m
Module 1 : Introduction & Lexical Analysis
View this question on its own page →Define Compiler. Explain all phases of a compiler with neat diagram.
Q2b. Construct a DFA for the regular expression r = 0^*1^*2^*.20257m
Module 1 : Introduction & Lexical Analysis
View this question on its own page →Construct a DFA for the regular expression .
Q3a. Prove that the following grammar is ambiguous on string 'aab': S \rightarrow aS \mid aSbS \mid \varepsilon20257m
Module 2 : Syntax Analysis (Parser)
View this question on its own page →Prove that the following grammar is ambiguous on string 'aab':
Q3b. Explain top-down and bottom-up parsing techniques.20257m
Module 2 : Syntax Analysis (Parser)
View this question on its own page →Explain top-down and bottom-up parsing techniques.
Q4a. Describe the working of LL(1) parser. Draw the LL(1) parsing table for the given grammar: S \rightarrow aA \mid bB A \rightarrow a B \rightarrow b20257m
Module 2 : Syntax Analysis (Parser)
View this question on its own page →Describe the working of LL(1) parser. Draw the LL(1) parsing table for the given grammar:
Q4b. Explain synthesized and inherited attributes with suitable examples.20257m
Module 3 : Semantic Analysis & Symbol Table
View this question on its own page →Explain synthesized and inherited attributes with suitable examples.
Q5a. Write down Three Address Code for the following expression: (a \times b) + (c + d) - (a + b + c + d)20257m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Write down Three Address Code for the following expression:
Q5b. Explain peephole optimization with examples and its benefits.20257m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Explain peephole optimization with examples and its benefits.
Q6a. Define regular expression. Write the regular expression for the language having a string which should have at least one '0' and at least one '1'.20257m
Module 1 : Introduction & Lexical Analysis
View this question on its own page →Define regular expression. Write the regular expression for the language having a string which should have at least one '0' and at least one '1'.
Q6b. Define Symbol Table. Discuss symbol table implementation techniques.20257m
Module 3 : Semantic Analysis & Symbol Table
View this question on its own page →Define Symbol Table. Discuss symbol table implementation techniques.
Q7a. Write down the differences between DFA and NFA.20257m
Module 1 : Introduction & Lexical Analysis
View this question on its own page →Write down the differences between DFA and NFA.
Q7b. Describe the role of shift-reduce parsing with an example.20257m
Module 2 : Syntax Analysis (Parser)
View this question on its own page →Describe the role of shift-reduce parsing with an example.
Q8a. Explain local and global optimization techniques.20257m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Explain local and global optimization techniques.
Q8b. Compare imperative and non-imperative programming languages.20257m
Module 5 : Advanced topics
View this question on its own page →Compare imperative and non-imperative programming languages.
Q9a. Convert the regular expression (a+b)^*ab into NFA.20257m
Module 1 : Introduction & Lexical Analysis
View this question on its own page →Convert the regular expression into NFA.
Q9b. Discuss ambiguity in grammar. Show that the given grammar is ambiguous: S \rightarrow ABA A \rightarrow aA \mid \varepsilon B \rightarrow bB \mid \varepsilon20257m
Module 2 : Syntax Analysis (Parser)
View this question on its own page →Discuss ambiguity in grammar. Show that the given grammar is ambiguous: