2024 question paper
Compiler Design
29 questions
Q1a. Choose the correct option / answer the following: During lexical analysis, how many tokens are identified in the following statement? while(count<=10) count = count + 1; (i) 9 (ii) 11 (iii) 10 (iv) 1220242m
Module 1 : Introduction & Lexical Analysis
View this question on its own page →Choose the correct option / answer the following:
During lexical analysis, how many tokens are identified in the following statement?while(count<=10) count = count + 1;
(i) 9
(ii) 11
(iii) 10
(iv) 12Q1b. Choose the correct option / answer the following: Which of the following is NOT accepted by finite automata? (i) Palindromes (ii) Strings with even number of a's (iii) Binary strings divisible by 3 (iv) Strings ending with 'ab'20242m
Module 1 : Introduction & Lexical Analysis
View this question on its own page →Choose the correct option / answer the following:
Which of the following is NOT accepted by finite automata?
(i) Palindromes
(ii) Strings with even number of a's
(iii) Binary strings divisible by 3
(iv) Strings ending with 'ab'Q1c. Choose the correct option / answer the following: Which grammar type is recognized by a push-down automaton? (i) Regular (ii) Context-free (iii) Context-sensitive (iv) Unrestricted20242m
Module 2 : Syntax Analysis (Parser)
View this question on its own page →Choose the correct option / answer the following:
Which grammar type is recognized by a push-down automaton?
(i) Regular
(ii) Context-free
(iii) Context-sensitive
(iv) UnrestrictedQ1d. Choose the correct option / answer the following: Which of the following parsers uses a stack and rightmost derivation in reverse? (i) LL Parser (ii) Top-down parser (iii) LR Parser (iv) Operator parser20242m
Module 2 : Syntax Analysis (Parser)
View this question on its own page →Choose the correct option / answer the following:
Which of the following parsers uses a stack and rightmost derivation in reverse?
(i) LL Parser
(ii) Top-down parser
(iii) LR Parser
(iv) Operator parserQ1e. Choose the correct option / answer the following: In S-attributed definitions, all attributes are: (i) Inherited (ii) Explicit (iii) Static (iv) Synthesized20242m
Module 3 : Semantic Analysis & Symbol Table
View this question on its own page →Choose the correct option / answer the following:
In S-attributed definitions, all attributes are:
(i) Inherited
(ii) Explicit
(iii) Static
(iv) SynthesizedQ1f. Choose the correct option / answer the following: Which of the following is used to determine the evaluation order of attributes? (i) Symbol table (ii) Transition table (iii) Dependency graph (iv) Abstract grammar20242m
Module 3 : Semantic Analysis & Symbol Table
View this question on its own page →Choose the correct option / answer the following:
Which of the following is used to determine the evaluation order of attributes?
(i) Symbol table
(ii) Transition table
(iii) Dependency graph
(iv) Abstract grammarQ1g. Choose the correct option / answer the following: Which of the following phase of the compiler is optional? (i) Syntax Analysis (ii) Intermediate Code Generation (iii) Semantic Analysis (iv) Code Optimization20242m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Choose the correct option / answer the following:
Which of the following phase of the compiler is optional?
(i) Syntax Analysis
(ii) Intermediate Code Generation
(iii) Semantic Analysis
(iv) Code OptimizationQ1h. Choose the correct option / answer the following: The symbol table stores information about: (i) Only variables (ii) Only functions (iii) Identifiers and their attributes (iv) Syntax errors20242m
Module 3 : Semantic Analysis & Symbol Table
View this question on its own page →Choose the correct option / answer the following:
The symbol table stores information about:
(i) Only variables
(ii) Only functions
(iii) Identifiers and their attributes
(iv) Syntax errorsQ1i. Choose the correct option / answer the following: Which optimization technique focuses on reducing code in small sequences? (i) Peephole optimization (ii) Strength reduction (iii) Loop optimization (iv) Code hoisting20242m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Choose the correct option / answer the following:
Which optimization technique focuses on reducing code in small sequences?
(i) Peephole optimization
(ii) Strength reduction
(iii) Loop optimization
(iv) Code hoistingQ1j. Choose the correct option / answer the following: Which of the following parsers can parse ambiguous grammars? (i) LL(1) (ii) Operator Precedence (iii) CLR(1) (iv) None of the above20242m
Module 2 : Syntax Analysis (Parser)
View this question on its own page →Choose the correct option / answer the following:
Which of the following parsers can parse ambiguous grammars?
(i) LL(1)
(ii) Operator Precedence
(iii) CLR(1)
(iv) None of the aboveQ2a. Describe the major phases of a compiler, highlighting the role of each phase in the compilation process. Illustrate your answer with a neat and labeled diagram of the compilation phases.20247m
Module 1 : Introduction & Lexical Analysis
View this question on its own page →Describe the major phases of a compiler, highlighting the role of each phase in the compilation process. Illustrate your answer with a neat and labeled diagram of the compilation phases.
Q2b. Differentiate between Deterministic Finite Automata (DFA) and Non-Deterministic Finite Automata (NFA). Also, explain the procedure to convert an NFA to DFA with a suitable example.20247m
Module 1 : Introduction & Lexical Analysis
View this question on its own page →Differentiate between Deterministic Finite Automata (DFA) and Non-Deterministic Finite Automata (NFA). Also, explain the procedure to convert an NFA to DFA with a suitable example.
Q3a. Design a finite automaton that accepts all binary strings that do not contain the substring "101".20247m
Module 1 : Introduction & Lexical Analysis
View this question on its own page →Design a finite automaton that accepts all binary strings that do not contain the substring "101".
Q3b. Given a context-free grammar (CFG), compute FIRST and FOLLOW sets for all non-terminals, and construct the LL(1) parsing table. Also, determine whether the grammar is LL(1) or not. Grammar: S \rightarrow A B A \rightarrow a A | \epsilon B \rightarrow b B | \epsilon20247m
Module 2 : Syntax Analysis (Parser)
View this question on its own page →Given a context-free grammar (CFG), compute FIRST and FOLLOW sets for all non-terminals, and construct the LL(1) parsing table. Also, determine whether the grammar is LL(1) or not.
Grammar:Q4a. Consider the following grammar: E \rightarrow E + T | T T \rightarrow T * F | F F \rightarrow (E) | id Construct the canonical collection of LR(0) items.20244m
Module 2 : Syntax Analysis (Parser)
View this question on its own page →Consider the following grammar:
Construct the canonical collection of LR(0) items.
Q4b. Consider the following grammar: E \rightarrow E + T | T T \rightarrow T * F | F F \rightarrow (E) | id Build the SLR(1) parsing table using the above items.20244m
Module 2 : Syntax Analysis (Parser)
View this question on its own page →Consider the following grammar:
Build the SLR(1) parsing table using the above items.
Q4c. Consider the following grammar: E \rightarrow E + T | T T \rightarrow T * F | F F \rightarrow (E) | id Determine whether the grammar is SLR(1), clearly stating any shift-reduce or reduce-reduce conflicts.20242m
Module 2 : Syntax Analysis (Parser)
View this question on its own page →Consider the following grammar:
Determine whether the grammar is SLR(1), clearly stating any shift-reduce or reduce-reduce conflicts.
Q4d. Consider the following grammar: E \rightarrow E + T | T T \rightarrow T * F | F F \rightarrow (E) | id Parse the string id + id * id using the constructed SLR(1) table and show the parser actions step-by-step.20242m
Module 2 : Syntax Analysis (Parser)
View this question on its own page →Consider the following grammar:
Parse the string
id + id * idusing the constructed SLR(1) table and show the parser actions step-by-step.Q4e. Consider the following grammar: E \rightarrow E + T | T T \rightarrow T * F | F F \rightarrow (E) | id Is the grammar ambiguous? Justify your answer with proper reasoning.20242m
Module 2 : Syntax Analysis (Parser)
View this question on its own page →Consider the following grammar:
Is the grammar ambiguous? Justify your answer with proper reasoning.
Q5a. Define syntax-directed definitions (SDD). Explain the difference between S-attributed and L-attributed definitions. Give an example of each and explain how attributes are evaluated.20247m
Module 3 : Semantic Analysis & Symbol Table
View this question on its own page →Define syntax-directed definitions (SDD). Explain the difference between S-attributed and L-attributed definitions. Give an example of each and explain how attributes are evaluated.
Q5b. Explain the process of attribute evaluation in a syntax tree. Discuss the construction and use of dependency graphs and the evaluation order of attributes. Give an example.20247m
Module 3 : Semantic Analysis & Symbol Table
View this question on its own page →Explain the process of attribute evaluation in a syntax tree. Discuss the construction and use of dependency graphs and the evaluation order of attributes. Give an example.
Q6a. What is a symbol table in a compiler? Describe its structure and how it supports semantic analysis. Explain with an example how a symbol table is constructed and maintained during compilation.20247m
Module 3 : Semantic Analysis & Symbol Table
View this question on its own page →What is a symbol table in a compiler? Describe its structure and how it supports semantic analysis. Explain with an example how a symbol table is constructed and maintained during compilation.
Q6b. Explain the different attributes stored in a symbol table for a variable and a function. Discuss how these attributes are used during type checking and semantic analysis.20247m
Module 3 : Semantic Analysis & Symbol Table
View this question on its own page →Explain the different attributes stored in a symbol table for a variable and a function. Discuss how these attributes are used during type checking and semantic analysis.
Q7a. What are the different parameter passing mechanisms in programming languages? Explain with examples the working of call-by-value, call-by-reference, and call-by-name. Also, discuss their impact on memory and scope.20247m
Module 3 : Semantic Analysis & Symbol Table
View this question on its own page →What are the different parameter passing mechanisms in programming languages? Explain with examples the working of call-by-value, call-by-reference, and call-by-name. Also, discuss their impact on memory and scope.
Q7b. Explain the process of translating an arithmetic expression into intermediate code using three-address code (TAC). Translate the expression a * -b + (c - d) * e into TAC and show the corresponding syntax tree and code.20247m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Explain the process of translating an arithmetic expression into intermediate code using three-address code (TAC). Translate the expression into TAC and show the corresponding syntax tree and code.
Q8a. Discuss the different types of code optimization techniques in compilers.20247m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Discuss the different types of code optimization techniques in compilers.
Q8b. Explain how instruction scheduling helps in pipeline optimization. Discuss how rearranging instructions improves performance and reduces stalls in pipelined architectures. Illustrate with an example.20247m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →Explain how instruction scheduling helps in pipeline optimization. Discuss how rearranging instructions improves performance and reduces stalls in pipelined architectures. Illustrate with an example.
Q9a. What is register allocation in code generation? Explain the role of graph coloring in register allocation and describe how it improves the efficiency of target code.20247m
Module 4 : Intermediate Code Generation & Code Improvement
View this question on its own page →What is register allocation in code generation? Explain the role of graph coloring in register allocation and describe how it improves the efficiency of target code.
Q9b. Discuss the compilation of object-oriented features such as inheritance, polymorphism, and dynamic method dispatch.20247m
Module 5 : Advanced topics
View this question on its own page →Discuss the compilation of object-oriented features such as inheritance, polymorphism, and dynamic method dispatch.