Theory of Computation and Compilers - Syntax Analysis

26. Consider the grammar
S → (S) | a
Let the number of states in SLR (1), LR (1) and LALR(l) parsers for the grammar be n1 n2 and n3 respectively. The following relationship holds good

  • Option : B
  • Explanation :
    Always the case SLR and LALR have same number of states.
    While LR have more states than these two.
    Because for any Bottom-up paring number of ‘CORES’ is always same while for LR() only other thing is lookahead is different.
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 *


27. Consider the following grammar.
S → S × E
S → E
E → F + E
E → F
F → id
Consider the following LR(0) items corresponding to the grammar above.
(i) S → S ×.E
(ii) E → F.+ E
(iii) E → F + .E
Given the items above, which two of them will appear in the same set in the canonical sets-of items for the grammar?

  • Option : D
  • Explanation :
    Go to Graph is:-

    So all are in different set.
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 *


28. Consider the following grammar
S → FR
R → S*|ε
F → id
In the predictive parser table, M, of the grammar the entries M[S, id] and M[R, $] respectively

  • Option : A
  • Explanation :
     FirstFollow
    id$
    Rid, E$
    Fidid, $
    So table Entries are as follows
    M [S, id] = {S → FR}
    M[R, $] = {R → ε}
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 *


29. Which one of the following grammars generates the language L = {ai bj | i ≠ j}?

  • Option : D
  • Explanation :
    The grammar is
    S → AC/CB
    C → aCb/null
    A → aA/a
    B → Bb/b
    it generate set of all strings generated by above grammar
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 *


30. Which of the following describes a handle (as applicable to LR-parsing) appropriately?

  • Option : D
  • Explanation :
    According to definition, handle is a production rule A → β and a position in the sentential form where string β may be found and replaced to produce the previous right sentential form in a rightmost derivation of sentential form.
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 *