Compiler Design

106501
Back to Compiler Design

Module 2 : Syntax Analysis (Parser)

  1. Q1b. Choose the correct answer of the following: A bottom-up parser generates (i) right-most derivation (ii) right-most derivation in reverse (iii) left-most derivation (iv) left-most derivation in reverse20222m

    Module 2 : Syntax Analysis (Parser)

    Choose the correct answer of the following:
    A bottom-up parser generates
    (i) right-most derivation
    (ii) right-most derivation in reverse
    (iii) left-most derivation
    (iv) left-most derivation in reverse

    View this question on its own page →
  2. Q1b. Choose the correct answer of the following: Which one of the following statements is true? (i) Canonical LR parser is more powerful than LALR parser. (ii) SLR parser is more powerful than LALR. (iii) LALR parser is more powerful than canonical LR parser. (iv) SLR parser, canonical LR parser and LALR parser all have the same power.20192m

    Module 2 : Syntax Analysis (Parser)

    Choose the correct answer of the following:
    Which one of the following statements is true?
    (i) Canonical LR parser is more powerful than LALR parser.
    (ii) SLR parser is more powerful than LALR.
    (iii) LALR parser is more powerful than canonical LR parser.
    (iv) SLR parser, canonical LR parser and LALR parser all have the same power.

    View this question on its own page →
  3. Q1c. Choose the correct answer of the following: Which of the following statement is true? (i) Every left recursive grammar can be LL(1) (ii) LL(1) grammar can be ambiguous (iii) both (i) and (ii) (iv) None of these20232m

    Module 2 : Syntax Analysis (Parser)

    Choose the correct answer of the following:
    Which of the following statement is true?
    (i) Every left recursive grammar can be LL(1)
    (ii) LL(1) grammar can be ambiguous
    (iii) both (i) and (ii)
    (iv) None of these

    View this question on its own page →
  4. 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 →
  5. Q1c. Choose the correct answer of the following: A grammar that produces more than one parse tree for some sentence is said to be (i) Ambiguous (ii) context free (iii) disambiguous (iv) regular20222m

    Module 2 : Syntax Analysis (Parser)

    Choose the correct answer of the following:
    A grammar that produces more than one parse tree for some sentence is said to be
    (i) Ambiguous
    (ii) context free
    (iii) disambiguous
    (iv) regular

    View this question on its own page →
  6. Q1d. Choose the correct answer of the following: A bottom-up parser generates (i) right most derivation (ii) right most derivation in reverse (iii) right most derivation (iv) left most derivation in reverse20232m

    Module 2 : Syntax Analysis (Parser)

    Choose the correct answer of the following:
    A bottom-up parser generates
    (i) right most derivation
    (ii) right most derivation in reverse
    (iii) right most derivation
    (iv) left most derivation in reverse

    View this question on its own page →
  7. 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 →
  8. Q1d. Which parser uses leftmost derivation? (i) LL parser (ii) Bottom-up parser (iii) LR parser (iv) Operator precedence parser20252m

    Module 2 : Syntax Analysis (Parser)

    Which parser uses leftmost derivation?

    (i) LL parser
    (ii) Bottom-up parser
    (iii) LR parser
    (iv) Operator precedence parser

    View this question on its own page →
  9. Q1d. Choose the correct answer of the following: For a grammar G, shift reduce (S-R) conflicts are present in LALR(1) parser, if and only if (i) the LR(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 conflicts20192m

    Module 2 : Syntax Analysis (Parser)

    Choose the correct answer of the following:
    For a grammar G, shift reduce (S-R) conflicts are present in LALR(1) parser, if and only if
    (i) the LR(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 →
  10. Q1d. Choose the correct answer of the following: Consider the following grammar: S \rightarrow cAd A \rightarrow ab | ac | a. For input string *cad*, how many times the recursive descent parser will backtrack? (i) 2 (ii) 3 (iii) 4 (iv) 520222m

    Module 2 : Syntax Analysis (Parser)

    Choose the correct answer of the following:
    Consider the following grammar:
    ScAdS \rightarrow cAd
    Aabaca.A \rightarrow ab | ac | a.
    For input string cad, how many times the recursive descent parser will backtrack?
    (i) 2
    (ii) 3
    (iii) 4
    (iv) 5

    View this question on its own page →
  11. Q1e. Choose the correct answer of the following: Grammar of the programming is checked in ......... phase of compiler. (i) semantic analysis (ii) code generation (iii) syntax analysis (iv) code optimization20232m

    Module 2 : Syntax Analysis (Parser)

    Choose the correct answer of the following:
    Grammar of the programming is checked in ......... phase of compiler.
    (i) semantic analysis
    (ii) code generation
    (iii) syntax analysis
    (iv) code optimization

    View this question on its own page →
  12. Q1e. LR parsing is a (i) Top-down parsing (ii) Bottom-up parsing (iii) Recursive parsing (iv) Predictive parsing20252m

    Module 2 : Syntax Analysis (Parser)

    LR parsing is a

    (i) Top-down parsing
    (ii) Bottom-up parsing
    (iii) Recursive parsing
    (iv) Predictive parsing

    View this question on its own page →
  13. Q1f. Choose the correct answer of the following: ________ is a top-down parser. (i) Operator precedence parser (ii) An LALR (k) parser (iii) An LR (k) parser (iv) Recursive descent parser20192m

    Module 2 : Syntax Analysis (Parser)

    Choose the correct answer of the following:
    ________ is a top-down parser.
    (i) Operator precedence parser
    (ii) An LALR (k) parser
    (iii) An LR (k) parser
    (iv) Recursive descent parser

    View this question on its own page →
  14. Q1f. Choose the correct answer of the following: Arrange the following parser according to their power (low to high): SLR, CLR, LALR. (i) LALR, CLR, SLR (ii) LALR, SLR, CLR (iii) CLR, LALR, SLR (iv) CLR, SLR, LALR20232m

    Module 2 : Syntax Analysis (Parser)

    Choose the correct answer of the following:
    Arrange the following parser according to their power (low to high): SLR, CLR, LALR.
    (i) LALR, CLR, SLR
    (ii) LALR, SLR, CLR
    (iii) CLR, LALR, SLR
    (iv) CLR, SLR, LALR

    View this question on its own page →
  15. Q1f. Which parsing technique is most powerful? (i) LL(1) (ii) Recursive descent (iii) LR(1) (iv) Operator precedence20252m

    Module 2 : Syntax Analysis (Parser)

    Which parsing technique is most powerful?

    (i) LL(1)
    (ii) Recursive descent
    (iii) LR(1)
    (iv) Operator precedence

    View this question on its own page →
  16. Q1g. Choose the correct answer of the following: What is the similarity between LR, LALR and SLR? (i) Use of same algorithm, but different parsing table (ii) Same parsing table, but different algorithm (iii) Their parsing tables and algorithms are similar but use top-down approach (iv) Both parsing tables and algorithms are different.20222m

    Module 2 : Syntax Analysis (Parser)

    Choose the correct answer of the following:
    What is the similarity between LR, LALR and SLR?
    (i) Use of same algorithm, but different parsing table
    (ii) Same parsing table, but different algorithm
    (iii) Their parsing tables and algorithms are similar but use top-down approach
    (iv) Both parsing tables and algorithms are different.

    View this question on its own page →
  17. Q1h. Choose the correct answer of the following: After removing left recursion from A \rightarrow A\alpha / \beta , the resulting grammar will be (i) A \rightarrow \beta A' (ii) A \rightarrow \alpha A' (iii) A \rightarrow \alpha \beta A'' (iv) A \rightarrow \beta \alpha A'20222m

    Module 2 : Syntax Analysis (Parser)

    Choose the correct answer of the following:
    After removing left recursion from AAα/βA \rightarrow A\alpha / \beta , the resulting grammar will be
    (i) AβAA \rightarrow \beta A'
    (ii) AαAA \rightarrow \alpha A'
    (iii) AαβAA \rightarrow \alpha \beta A''
    (iv) AβαAA \rightarrow \beta \alpha A'

    View this question on its own page →
  18. Q1h. Choose the correct answer of the following: 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)

    Choose the correct answer of the following:
    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 →
  19. Q1i. Choose the correct answer of the following: To convert an arbitrary CFG to an LL(1) grammar (i) factor the grammar alone (ii) remove left recursion alone (iii) remove left recursion and factor the grammar (iv) None of the above20192m

    Module 2 : Syntax Analysis (Parser)

    Choose the correct answer of the following:
    To convert an arbitrary CFG to an LL(1) grammar
    (i) factor the grammar alone
    (ii) remove left recursion alone
    (iii) remove left recursion and factor the grammar
    (iv) None of the above

    View this question on its own page →
  20. Q1i. Choose the correct answer of the following: If x is a terminal then FIRST(x) is (i) \epsilon (ii) {x} (iii) x* (iv) xx*20222m

    Module 2 : Syntax Analysis (Parser)

    Choose the correct answer of the following:
    If x is a terminal then FIRST(x) is
    (i) ϵ\epsilon
    (ii) {x}
    (iii) x*
    (iv) xx*

    View this question on its own page →
  21. Q1i. Choose the correct answer of the following: 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)

    Choose the correct answer of the following:
    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 →
  22. Q1j. Choose the correct answer of the following: If a grammar is LALR(1), then it is necessarily (i) SLR(1) (ii) LR(1) (iii) LL(1) (iv) None of the above20222m

    Module 2 : Syntax Analysis (Parser)

    Choose the correct answer of the following:
    If a grammar is LALR(1), then it is necessarily
    (i) SLR(1)
    (ii) LR(1)
    (iii) LL(1)
    (iv) None of the above

    View this question on its own page →
  23. 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 →
  24. Q2b. What is bottom-up parsing? Discuss shift reduce parsing technique in brief. What is a handle?20197m

    Module 2 : Syntax Analysis (Parser)

    What is bottom-up parsing? Discuss shift reduce parsing technique in brief. What is a handle?

    View this question on its own page →
  25. Q3. Consider the following grammar: S \rightarrow 0S0 | 1S1 | 10 (a) Find LR(0) collection of items for the above grammar. (b) Construct SLR parsing table. (c) Trace whether the string "01100" is accepted or not.202214m

    Module 2 : Syntax Analysis (Parser)

    Consider the following grammar:
    S0S01S110S \rightarrow 0S0 | 1S1 | 10
    (a) Find LR(0) collection of items for the above grammar.
    (b) Construct SLR parsing table.
    (c) Trace whether the string "01100" is accepted or not.

    View this question on its own page →
  26. Q3a. What is left recursion? Eliminate the left recursion from the following grammar : E \rightarrow E+T|T T \rightarrow T*F|F F \rightarrow (E)|id20197m

    Module 2 : Syntax Analysis (Parser)

    What is left recursion? Eliminate the left recursion from the following grammar :
    EE+TTE \rightarrow E+T|T
    TTFFT \rightarrow T*F|F
    F(E)idF \rightarrow (E)|id

    View this question on its own page →
  27. Q3a. Consider the following grammar: S \rightarrow S(S)S/\epsilon (i) Left factor this grammar. (ii) Eliminate left recursion from original grammar. (iii) Is the resulting grammar suitable for top-down parsing?20237m

    Module 2 : Syntax Analysis (Parser)

    Consider the following grammar:
    SS(S)S/ϵS \rightarrow S(S)S/\epsilon
    (i) Left factor this grammar.
    (ii) Eliminate left recursion from original grammar.
    (iii) Is the resulting grammar suitable for top-down parsing?

    View this question on its own page →
  28. Q3a. Prove that the following grammar is ambiguous on string 'aab': S \rightarrow aS \mid aSbS \mid \varepsilon20257m

    Module 2 : Syntax Analysis (Parser)

    Prove that the following grammar is ambiguous on string 'aab':

    SaSaSbSεS \rightarrow aS \mid aSbS \mid \varepsilon

    View this question on its own page →
  29. 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 →
  30. Q3b. Explain top-down and bottom-up parsing techniques.20257m

    Module 2 : Syntax Analysis (Parser)

    Explain top-down and bottom-up parsing techniques.

    View this question on its own page →
  31. Q4. Construct LALR(1) parsing table for the following grammar. Also prove that this is not SLR(1). S \rightarrow Aa | bAc | dc | bda A \rightarrow d202214m

    Module 2 : Syntax Analysis (Parser)

    Construct LALR(1) parsing table for the following grammar. Also prove that this is not SLR(1).
    SAabAcdcbdaS \rightarrow Aa | bAc | dc | bda
    AdA \rightarrow d

    View this question on its own page →
  32. Q4a. Show that the following grammar is LL(1) but not SLR(1). S \rightarrow AaAb/BbBa A \rightarrow \epsilon B \rightarrow \epsilon20236m

    Module 2 : Syntax Analysis (Parser)

    Show that the following grammar is LL(1) but not SLR(1).
    SAaAb/BbBaS \rightarrow AaAb/BbBa
    AϵA \rightarrow \epsilon
    BϵB \rightarrow \epsilon

    View this question on its own page →
  33. 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 →
  34. Q4a. Describe the working of LL(1) parser. Draw the LL(1) parsing table for the given grammar: S \rightarrow aA \mid bB A \rightarrow a B \rightarrow b20257m

    Module 2 : Syntax Analysis (Parser)

    Describe the working of LL(1) parser. Draw the LL(1) parsing table for the given grammar:

    SaAbBS \rightarrow aA \mid bB
    AaA \rightarrow a
    BbB \rightarrow b

    View this question on its own page →
  35. Q4b. Explain architecture and algorithm for the non-recursive predictive parser.20197m

    Module 2 : Syntax Analysis (Parser)

    Explain architecture and algorithm for the non-recursive predictive parser.

    View this question on its own page →
  36. Q4b. What is shift-Reduce conflict?20234m

    Module 2 : Syntax Analysis (Parser)

    What is shift-Reduce conflict?

    View this question on its own page →
  37. 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 →
  38. 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 →
  39. 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 →
  40. 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 →
  41. Q5a. Check whether the following grammar is CLR or not : S \rightarrow Aa | bBa | Ba | bAc A \rightarrow c B \rightarrow d20197m

    Module 2 : Syntax Analysis (Parser)

    Check whether the following grammar is CLR or not :
    SAabBaBabAcS \rightarrow Aa | bBa | Ba | bAc
    AcA \rightarrow c
    BdB \rightarrow d

    View this question on its own page →
  42. Q5a. Consider the following grammar: S \rightarrow CC C \rightarrow cC/d Construct CLR(1) and LALR(1) parsing table.20239m

    Module 2 : Syntax Analysis (Parser)

    Consider the following grammar:
    SCCS \rightarrow CC
    CcC/dC \rightarrow cC/d
    Construct CLR(1) and LALR(1) parsing table.

    View this question on its own page →
  43. Q5b. When a grammar is called ambiguous? Is there any technique to remove ambiguity? Justify whether the following grammar is ambiguous or not? S \rightarrow aS/Sa/a20235m

    Module 2 : Syntax Analysis (Parser)

    When a grammar is called ambiguous? Is there any technique to remove ambiguity? Justify whether the following grammar is ambiguous or not?
    SaS/Sa/aS \rightarrow aS/Sa/a

    View this question on its own page →
  44. Q6a. Consider the context free grammar: S \rightarrow SS + | SS * | a; eliminate left factoring and left recursion from the grammar. Does these removals make the grammar suitable for top-down parsing? Justify.20227m

    Module 2 : Syntax Analysis (Parser)

    Consider the context free grammar: SSS+SSaS \rightarrow SS + | SS * | a; eliminate left factoring and left recursion from the grammar. Does these removals make the grammar suitable for top-down parsing? Justify.

    View this question on its own page →
  45. Q6a. Consider the following grammar: E \rightarrow E+T/T T \rightarrow T*F/F F \rightarrow (E)/id Obtain FIRST and FOLLOW sets of the above grammar.20236m

    Module 2 : Syntax Analysis (Parser)

    Consider the following grammar:
    EE+T/TE \rightarrow E+T/T
    TTF/FT \rightarrow T*F/F
    F(E)/idF \rightarrow (E)/id

    Obtain FIRST and FOLLOW sets of the above grammar.

    View this question on its own page →
  46. Q6b. Compute FIRST and FOLLOW for the given grammar. Also derive the LL(1) parsing table. E \rightarrow TE' E' \rightarrow + TE' / \epsilon T \rightarrow FT' T' \rightarrow * FT' / \epsilon F \rightarrow (E) / id20227m

    Module 2 : Syntax Analysis (Parser)

    Compute FIRST and FOLLOW for the given grammar. Also derive the LL(1) parsing table.
    ETEE \rightarrow TE'
    E+TE/ϵE' \rightarrow + TE' / \epsilon
    TFTT \rightarrow FT'
    TFT/ϵT' \rightarrow * FT' / \epsilon
    F(E)/idF \rightarrow (E) / id

    View this question on its own page →
  47. Q6b. Consider the following grammar: E \rightarrow E+T/T T \rightarrow T*F/F F \rightarrow (E)/id Construct Predictive Parsing Table of the above grammar.20238m

    Module 2 : Syntax Analysis (Parser)

    Consider the following grammar:
    EE+T/TE \rightarrow E+T/T
    TTF/FT \rightarrow T*F/F
    F(E)/idF \rightarrow (E)/id

    Construct Predictive Parsing Table of the above grammar.

    View this question on its own page →
  48. Q7b. Describe the role of shift-reduce parsing with an example.20257m

    Module 2 : Syntax Analysis (Parser)

    Describe the role of shift-reduce parsing with an example.

    View this question on its own page →
  49. Q7c. Draw the syntax tree for the following arithmetic expression: a * -(b + c/d)20233m

    Module 2 : Syntax Analysis (Parser)

    Draw the syntax tree for the following arithmetic expression:
    a(b+c/d)a * -(b + c/d)

    View this question on its own page →
  50. Q8a. Check whether the following grammar is LL(1) grammar or not : S \rightarrow iEtSA | a A \rightarrow eS | \epsilon E \rightarrow b20197m

    Module 2 : Syntax Analysis (Parser)

    Check whether the following grammar is LL(1) grammar or not :
    SiEtSAaS \rightarrow iEtSA | a
    AeSϵA \rightarrow eS | \epsilon
    EbE \rightarrow b

    View this question on its own page →