2024 question paper

Compiler Design

29 questions

  1. 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

    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) 12

    View this question on its own page →
  2. Q1b. 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

    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'

    View this question on its own page →
  3. 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)

    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) Unrestricted

    View this question on its own page →
  4. Q1d. 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)

    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 parser

    View this question on its own page →
  5. Q1e. 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

    Choose the correct option / answer the following:
    In S-attributed definitions, all attributes are:
    (i) Inherited
    (ii) Explicit
    (iii) Static
    (iv) Synthesized

    View this question on its own page →
  6. Q1f. 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

    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 grammar

    View this question on its own page →
  7. Q1g. 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

    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 Optimization

    View this question on its own page →
  8. Q1h. 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

    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 errors

    View this question on its own page →
  9. Q1i. 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

    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 hoisting

    View this question on its own page →
  10. Q1j. 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)

    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 above

    View this question on its own page →
  11. Q2a. 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

    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.

    View this question on its own page →
  12. 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

    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.

    View this question on its own page →
  13. Q3a. Design a finite automaton that accepts all binary strings that do not contain the substring "101".20247m

    Module 1 : Introduction & Lexical Analysis

    Design a finite automaton that accepts all binary strings that do not contain the substring "101".

    View this question on its own page →
  14. 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)

    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:
    SABS \rightarrow A B
    AaAϵA \rightarrow a A | \epsilon
    BbBϵB \rightarrow b B | \epsilon

    View this question on its own page →
  15. 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)

    Consider the following grammar:
    EE+TTE \rightarrow E + T | T
    TTFFT \rightarrow T * F | F
    F(E)idF \rightarrow (E) | id

    Construct the canonical collection of LR(0) items.

    View this question on its own page →
  16. 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)

    Consider the following grammar:
    EE+TTE \rightarrow E + T | T
    TTFFT \rightarrow T * F | F
    F(E)idF \rightarrow (E) | id

    Build the SLR(1) parsing table using the above items.

    View this question on its own page →
  17. 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)

    Consider the following grammar:
    EE+TTE \rightarrow E + T | T
    TTFFT \rightarrow T * F | F
    F(E)idF \rightarrow (E) | id

    Determine whether the grammar is SLR(1), clearly stating any shift-reduce or reduce-reduce conflicts.

    View this question on its own page →
  18. 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)

    Consider the following grammar:
    EE+TTE \rightarrow E + T | T
    TTFFT \rightarrow T * F | F
    F(E)idF \rightarrow (E) | id

    Parse the string id + id * id using the constructed SLR(1) table and show the parser actions step-by-step.

    View this question on its own page →
  19. 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)

    Consider the following grammar:
    EE+TTE \rightarrow E + T | T
    TTFFT \rightarrow T * F | F
    F(E)idF \rightarrow (E) | id

    Is the grammar ambiguous? Justify your answer with proper reasoning.

    View this question on its own page →
  20. 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

    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.

    View this question on its own page →
  21. 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

    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.

    View this question on its own page →
  22. 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

    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.

    View this question on its own page →
  23. 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

    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.

    View this question on its own page →
  24. 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

    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.

    View this question on its own page →
  25. 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

    Explain the process of translating an arithmetic expression into intermediate code using three-address code (TAC). Translate the expression ab+(cd)ea * -b + (c - d) * e into TAC and show the corresponding syntax tree and code.

    View this question on its own page →
  26. Q8a. Discuss the different types of code optimization techniques in compilers.20247m

    Module 4 : Intermediate Code Generation & Code Improvement

    Discuss the different types of code optimization techniques in compilers.

    View this question on its own page →
  27. 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

    Explain how instruction scheduling helps in pipeline optimization. Discuss how rearranging instructions improves performance and reduces stalls in pipelined architectures. Illustrate with an example.

    View this question on its own page →
  28. 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

    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.

    View this question on its own page →
  29. Q9b. Discuss the compilation of object-oriented features such as inheritance, polymorphism, and dynamic method dispatch.20247m

    Module 5 : Advanced topics

    Discuss the compilation of object-oriented features such as inheritance, polymorphism, and dynamic method dispatch.

    View this question on its own page →