Compiler Design
105601Module 2: Syntax Analysis (Parser)
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 reverseQ1e. 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 theseQ1j. 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 conflictsQ3a. 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?
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:
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.
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.