Theory of Computation and Compilers - Syntax Analysis

36. Which one of the following is TRUE at any valid state in shift-reduce parsing?

  • Option : C
  • Explanation :
    In shift-reduce parser, the stack contains only a set of variable prefix.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


37. Among simple LR (SLR), canonical LR, and lookahead LR (LALR), which of the following pairs identify the method that is very easy to implement and the method that is the most powerful, in that order?

  • Option : C
  • Explanation :
    SLR and CLR are easy to implement. CLR is more power full to any of the parsec.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


38. Consider the following grammar G.
S → F | H
F → p | c
H → d | c
Where S, F and H are non-terminal symbols, p, d and c are terminal symbols. Which of the following statement(s) is/are correct?
S1: LL(1) can parse all strings that are generated using grammar G.
S2: LR(1) can parse all strings that are generated using grammar G.

  • Option : D
  • Explanation :
    The given grammar is ambiguous so neither LL(1) nor LR(1).
    First Leftmost Derivation
    S → F
    F → c
    Second Leftmost Derivation
    S → H
    H → c
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


39. Which of the following statements about parser is/are CORRECT?
I. Canonical LR is more powerful than SLR.
II. SLR is more powerful than LALR.
III.SLR is more powerful than Canonical LR.

  • Option : A
  • Explanation :
    LR parsers in term of power CLR > LALR > SLR > LR(0)
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


40. A shift-reduce parser carries out the actions specified within braces immediately after reducing with the corresponding rule of grammar
S → xxW{print"1"}
S → y {print"2"}
W → Sz{print"3M}
What is the translation of xxxxyzz using the syntax-directed translation scheme described by the above rules?

  • Option : A
  • Explanation :
    S → XXW{Print + 1}
    S → Y {Print + 2}
    W → SZ {Print + 3}
    Translation of XXXXYZZ
    S → XXW   1
    → XXSZ   3
    → XXXXWZ   1
    → XXXXSZZ   3
    → XXXXYZZ   2
    Syntax directed translation scheme described by 23131
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *