2023 question paper

Compiler Design

27 questions

  1. Q1a. Which of the following is the most powerful parser? (i) SLR (ii) LALR (iii) Canonical LR (iv) Operator precedence20232m

    Module 2: Syntax Analysis (Parser)

    Which of the following is the most powerful parser?
    (i) SLR
    (ii) LALR
    (iii) Canonical LR
    (iv) Operator precedence

    View this question on its own page →
  2. Q1b. A top down parser generates (i) Rightmost derivation (ii) Rightmost derivation in reverse (iii) Leftmost derivation (iv) Left most derivation in reverse20232m

    Module 2: Syntax Analysis (Parser)

    A top down parser generates
    (i) Rightmost derivation
    (ii) Rightmost derivation in reverse
    (iii) Leftmost derivation
    (iv) Left most derivation in reverse

    View this question on its own page →
  3. Q1c. A shift reduce parser carries out the actions specified within braces immediately after reducing with the corresponding rule of grammar: S \to xxW {print "1"}, S \to y {print "2"}, S \to Sz {print "3"} What is the translation of xxxxyzz using the syntax directed translation scheme described by the above rules? (i) 23131 (ii) 11233 (iii) 11231 (iv) 3321120232m

    Module 3: Semantic Analysis, Symbol Table, Run-time environment

    A shift reduce parser carries out the actions specified within braces immediately after reducing with the corresponding rule of grammar:
    SxxWS \to xxW {print "1"}, SyS \to y {print "2"}, SSzS \to Sz {print "3"}
    What is the translation of xxxxyzzxxxxyzz using the syntax directed translation scheme described by the above rules?
    (i) 23131
    (ii) 11233
    (iii) 11231
    (iv) 33211

    View this question on its own page →
  4. Q1d. Three-address code involves (i) Exactly 3 address (ii) At most 3 addresses (iii) No unary operator (iv) None20232m

    Module 4: Intermediate Code Generation, Code Improvement (optimization)

    Three-address code involves
    (i) Exactly 3 address
    (ii) At most 3 addresses
    (iii) No unary operator
    (iv) None

    View this question on its own page →
  5. Q1e. Handle pruning forms the basis of........ (i) Bottom up parsing (ii) Top down parsing (iii) Predictive parsing (iv) Recursive descent parsing20232m

    Module 2: Syntax Analysis (Parser)

    Handle pruning forms the basis of........
    (i) Bottom up parsing
    (ii) Top down parsing
    (iii) Predictive parsing
    (iv) Recursive descent parsing

    View this question on its own page →
  6. Q1f. Left factoring guarantees (i) Not occurring of backtracking (ii) Cycle free parse tree (iii) Error free target code (iv) Correct LL(1) parsing table20232m

    Module 2: Syntax Analysis (Parser)

    Left factoring guarantees
    (i) Not occurring of backtracking
    (ii) Cycle free parse tree
    (iii) Error free target code
    (iv) Correct LL(1) parsing table

    View this question on its own page →
  7. Q1g. Consider a grammar A \to a S_1 | a S_2. The left factored grammar produced from the grammar is (i) A \to a A', A' \to S_1 | S_2 (ii) A' \to a A, A \to a S_1 | a S_2 (iii) A \to a A', A' \to S_1 | S_2, S_1 \to S_1, S_2 (iv) None of these20232m

    Module 2: Syntax Analysis (Parser)

    Consider a grammar AaS1aS2A \to a S_1 | a S_2. The left factored grammar produced from the grammar is
    (i) AaA,AS1S2A \to a A', A' \to S_1 | S_2
    (ii) AaA,AaS1aS2A' \to a A, A \to a S_1 | a S_2
    (iii) AaA,AS1S2,S1S1,S2A \to a A', A' \to S_1 | S_2, S_1 \to S_1, S_2
    (iv) None of these

    View this question on its own page →
  8. Q1h. Synthesized attributed are calculated (i) From the values of attributes of the children of the node (ii) From the values of attributes of the parent of the node (iii) From the values of attributes of the siblings of the node (iv) None of these20232m

    Module 3: Semantic Analysis, Symbol Table, Run-time environment

    Synthesized attributed are calculated
    (i) From the values of attributes of the children of the node
    (ii) From the values of attributes of the parent of the node
    (iii) From the values of attributes of the siblings of the node
    (iv) None of these

    View this question on its own page →
  9. Q1i. The method which merges the bodies of two loops is (i) Loop rolling (ii) Loop Jamming (iii) Constant folding (iv) None of the above20232m

    Module 4: Intermediate Code Generation, Code Improvement (optimization)

    The method which merges the bodies of two loops is
    (i) Loop rolling
    (ii) Loop Jamming
    (iii) Constant folding
    (iv) None of the above

    View this question on its own page →
  10. Q1j. For a grammar G, shift reduce (S-R) conflicts are present in LALR(1) parser, if and only if (i) The LAR (1) parser for G has S.R conflicts (ii) The LR(0) parser for G has S.R conflicts (iii) The SLR(1) parser for G has S.R conflicts (iv) The SLR(0) parser for G has S.R conflicts20232m

    Module 2: Syntax Analysis (Parser)

    For a grammar G, shift reduce (S-R) conflicts are present in LALR(1) parser, if and only if
    (i) The LAR (1) parser for G has S.R conflicts
    (ii) The LR(0) parser for G has S.R conflicts
    (iii) The SLR(1) parser for G has S.R conflicts
    (iv) The SLR(0) parser for G has S.R conflicts

    View this question on its own page →
  11. Q2a. Explain the working of each phase of compiler in detail with an example.20237m

    Module 1: Introduction, Lexical Analysis

    Explain the working of each phase of compiler in detail with an example.

    View this question on its own page →
  12. Q2b. What is an activation record? Explain how they are used to access various local and global variables.20237m

    Module 3: Semantic Analysis, Symbol Table, Run-time environment

    What is an activation record? Explain how they are used to access various local and global variables.

    View this question on its own page →
  13. Q3a. What are the advantages of LALR parsing over SLR and CLR methods?20235m

    Module 2: Syntax Analysis (Parser)

    What are the advantages of LALR parsing over SLR and CLR methods?

    View this question on its own page →
  14. Q3b. Write the algorithm to compute FIRST and FOLLOW for a given grammar.20235m

    Module 2: Syntax Analysis (Parser)

    Write the algorithm to compute FIRST and FOLLOW for a given grammar.

    View this question on its own page →
  15. Q3c. What is shift-reduce conflict?20234m

    Module 2: Syntax Analysis (Parser)

    What is shift-reduce conflict?

    View this question on its own page →
  16. Q4a. Given the Syntax-Directed Definition below with the synthesized attribute val. Draw the annotated parse tree for the expression (3+4) * (5+6) L \to E, L.val = E.val E \to T, E.val = T.val E \to E_1 + T, E.val = E_1.val + T.val T \to F, T.val = F.val T \to T_1 * F, T.val = T_1.val * F.val F \to (E), F.val = E.val F \to digit, F.val = digit.lexval20237m

    Module 3: Semantic Analysis, Symbol Table, Run-time environment

    Given the Syntax-Directed Definition below with the synthesized attribute val. Draw the annotated parse tree for the expression (3+4)(5+6)(3+4) * (5+6)

    LEL \to E, L.val=E.valL.val = E.val
    ETE \to T, E.val=T.valE.val = T.val
    EE1+TE \to E_1 + T, E.val=E1.val+T.valE.val = E_1.val + T.val
    TFT \to F, T.val=F.valT.val = F.val
    TT1FT \to T_1 * F, T.val=T1.valF.valT.val = T_1.val * F.val
    F(E)F \to (E), F.val=E.valF.val = E.val
    FdigitF \to digit, F.val=digit.lexvalF.val = digit.lexval

    View this question on its own page →
  17. Q4b. Find the FIRST an FOLLOW form the following production: S \to aBDh B \to cC C \to bC | \epsilon D \to EF E \to g | \epsilon F \to f | \epsilon20237m

    Module 2: Syntax Analysis (Parser)

    Find the FIRST an FOLLOW form the following production:
    SaBDhS \to aBDh
    BcCB \to cC
    CbCϵC \to bC | \epsilon
    DEFD \to EF
    EgϵE \to g | \epsilon
    FfϵF \to f | \epsilon

    View this question on its own page →
  18. Q5a. Construct the predictive parsing table for the following grammars: S \to AaAb | BbBa A \to \epsilon B \to \epsilon20237m

    Module 2: Syntax Analysis (Parser)

    Construct the predictive parsing table for the following grammars:
    SAaAbBbBaS \to AaAb | BbBa
    AϵA \to \epsilon
    BϵB \to \epsilon

    View this question on its own page →
  19. Q5b. Explain how type checking and error reporting are performed in compiler. Draw syntax tree and DAG for the statement: a = (a * b + c) \uparrow (b + c) * b + c20237m

    Module 3: Semantic Analysis, Symbol Table, Run-time environment

    Explain how type checking and error reporting are performed in compiler. Draw syntax tree and DAG for the statement:
    a=(ab+c)(b+c)b+ca = (a * b + c) \uparrow (b + c) * b + c

    View this question on its own page →
  20. Q6a. What is handle? Consider the grammar: E \to E + E | E * E | id Find the handles of the right sentential forms of the reduction for the string id + id * id.20235m

    Module 2: Syntax Analysis (Parser)

    What is handle? Consider the grammar:
    EE+EEEidE \to E + E | E * E | id
    Find the handles of the right sentential forms of the reduction for the string id+ididid + id * id.

    View this question on its own page →
  21. Q6b. When a grammar is called ambiguous? Is there any technique to remove ambiguity? Justify whether the grammar is ambiguous or not? A \to AA | (A) | a20234m

    Module 2: Syntax Analysis (Parser)

    When a grammar is called ambiguous? Is there any technique to remove ambiguity? Justify whether the grammar is ambiguous or not?
    AAA(A)aA \to AA | (A) | a

    View this question on its own page →
  22. Q6c. Discuss about operator precedence parser.20235m

    Module 2: Syntax Analysis (Parser)

    Discuss about operator precedence parser.

    View this question on its own page →
  23. Q7a. Differentiate between S-attribute SDT and L-attribute SDT with suitable examples.20237m

    Module 3: Semantic Analysis, Symbol Table, Run-time environment

    Differentiate between S-attribute SDT and L-attribute SDT with suitable examples.

    View this question on its own page →
  24. Q7b. Consider the following grammar: E \to E + T | T T \to T * F | F F \to td Draw a SLR state transition diagram for the above grammar. Also draw the SLR parse table.20237m

    Module 2: Syntax Analysis (Parser)

    Consider the following grammar:
    EE+TTE \to E + T | T
    TTFFT \to T * F | F
    FtdF \to td
    Draw a SLR state transition diagram for the above grammar. Also draw the SLR parse table.

    View this question on its own page →
  25. Q8a. Consider the following grammar: S \to CC C \to cC | d Find the LR(1) set of items.20235m

    Module 2: Syntax Analysis (Parser)

    Consider the following grammar:
    SCCS \to CC
    CcCdC \to cC | d
    Find the LR(1) set of items.

    View this question on its own page →
  26. Q8b. Translate the expression a = (a + b) * (c + d) + (a + b + c) into (i) Quadruple (ii) Triple (iii) Indirect triple20239m

    Module 4: Intermediate Code Generation, Code Improvement (optimization)

    Translate the expression a=(a+b)(c+d)+(a+b+c)a = (a + b) * (c + d) + (a + b + c) into
    (i) Quadruple
    (ii) Triple
    (iii) Indirect triple

    View this question on its own page →
  27. Q9. Write short notes on any two of the following: (a) LEX and YACC (b) Peephole Optimization (c) Symbol Table (d) Predictive parser202314m

    Module 1: Introduction, Lexical Analysis

    Write short notes on any two of the following:
    (a) LEX and YACC
    (b) Peephole Optimization
    (c) Symbol Table
    (d) Predictive parser

    View this question on its own page →