2023 question paper
Compiler Design
27 questions
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)
View this question on its own page →Which of the following is the most powerful parser?
(i) SLR
(ii) LALR
(iii) Canonical LR
(iv) Operator precedenceQ1b. 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)
View this question on its own page →A top down parser generates
(i) Rightmost derivation
(ii) Rightmost derivation in reverse
(iii) Leftmost derivation
(iv) Left most derivation in reverseQ1c. 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
View this question on its own page →A shift reduce parser carries out the actions specified within braces immediately after reducing with the corresponding rule of grammar:
{print "1"}, {print "2"}, {print "3"}
What is the translation of using the syntax directed translation scheme described by the above rules?
(i) 23131
(ii) 11233
(iii) 11231
(iv) 33211Q1d. 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)
View this question on its own page →Three-address code involves
(i) Exactly 3 address
(ii) At most 3 addresses
(iii) No unary operator
(iv) NoneQ1e. 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)
View this question on its own page →Handle pruning forms the basis of........
(i) Bottom up parsing
(ii) Top down parsing
(iii) Predictive parsing
(iv) Recursive descent parsingQ1f. 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)
View this question on its own page →Left factoring guarantees
(i) Not occurring of backtracking
(ii) Cycle free parse tree
(iii) Error free target code
(iv) Correct LL(1) parsing tableQ1g. 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)
View this question on its own page →Consider a grammar . The left factored grammar produced from the grammar is
(i)
(ii)
(iii)
(iv) None of theseQ1h. 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
View this question on its own page →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 theseQ1i. 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)
View this question on its own page →The method which merges the bodies of two loops is
(i) Loop rolling
(ii) Loop Jamming
(iii) Constant folding
(iv) None of the aboveQ1j. 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)
View this question on its own page →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 conflictsQ2a. Explain the working of each phase of compiler in detail with an example.20237m
Module 1: Introduction, Lexical Analysis
View this question on its own page →Explain the working of each phase of compiler in detail with an example.
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
View this question on its own page →What is an activation record? Explain how they are used to access various local and global variables.
Q3a. What are the advantages of LALR parsing over SLR and CLR methods?20235m
Module 2: Syntax Analysis (Parser)
View this question on its own page →What are the advantages of LALR parsing over SLR and CLR methods?
Q3b. Write the algorithm to compute FIRST and FOLLOW for a given grammar.20235m
Module 2: Syntax Analysis (Parser)
View this question on its own page →Write the algorithm to compute FIRST and FOLLOW for a given grammar.
Q3c. What is shift-reduce conflict?20234m
Module 2: Syntax Analysis (Parser)
View this question on its own page →What is shift-reduce conflict?
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
View this question on its own page →Given the Syntax-Directed Definition below with the synthesized attribute val. Draw the annotated parse tree for the expression
,
,
,
,
,
,
,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)
View this question on its own page →Find the FIRST an FOLLOW form the following production:
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)
View this question on its own page →Construct the predictive parsing table for the following grammars:
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
View this question on its own page →Explain how type checking and error reporting are performed in compiler. Draw syntax tree and DAG for the statement:
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)
View this question on its own page →What is handle? Consider the grammar:
Find the handles of the right sentential forms of the reduction for the string .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)
View this question on its own page →When a grammar is called ambiguous? Is there any technique to remove ambiguity? Justify whether the grammar is ambiguous or not?
Q6c. Discuss about operator precedence parser.20235m
Module 2: Syntax Analysis (Parser)
View this question on its own page →Discuss about operator precedence parser.
Q7a. Differentiate between S-attribute SDT and L-attribute SDT with suitable examples.20237m
Module 3: Semantic Analysis, Symbol Table, Run-time environment
View this question on its own page →Differentiate between S-attribute SDT and L-attribute SDT with suitable examples.
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)
View this question on its own page →Consider the following grammar:
Draw a SLR state transition diagram for the above grammar. Also draw the SLR parse table.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)
View this question on its own page →Consider the following grammar:
Find the LR(1) set of items.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)
View this question on its own page →Translate the expression into
(i) Quadruple
(ii) Triple
(iii) Indirect tripleQ9. 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
View this question on its own page →Write short notes on any two of the following:
(a) LEX and YACC
(b) Peephole Optimization
(c) Symbol Table
(d) Predictive parser