Theory of Computation and Compilers - Syntax Analysis

21. Consider the grammar given below:
S → Aa
A → BD
B → b|ε
D → d|ε
Let a, b, d, and $ be indexed a follows:

abd$
3210
Compute the FOLLOW set of the non-terminal B and write the index values for the symbols in the FOLLOW set in the descending order. (For example, if the FOLLOW set is {a, b, d, $), then the answer should be 3210)

  • Option : A
  • Explanation :
    S → Aa
    A → BD
    B → b|ε
    D → d|ε
    Follow (B) = {d, a}
    Hence index value in descending order is 31.
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 *


22. Which of the following statements is true?

  • Option : C
  • Explanation :
    LR is power ful than LALR parsers and LALR are power ful than SLR parsers.
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 *


23. Assume that the SLR parser for a grammar G has n1 states and the LALR parser for G has n2 states. The relationship between n1 and n2 is

  • Option : B
  • Explanation :
    Number of st at e in SLR is always same as number of st ate in LALR parser.
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 *


24. Consider the grammar shown below
S → i E t S S'|α
S' → eS | ε
E → b
In the predictive parse table M, of this grammar, the entries M[S', e] and M[S', $] respectively are

  • Option : A
  • Explanation :
    S → iE tSS1\a
      S' ⇒ eS|a
      E → b
    This is left factor grammar
    Thus we may expand S to ibtSS' on input i and wait untill ibtS has been seen to decide whether to expand S' → eS|∈
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 *


25. Which of the following grammar rules violate the requirements of an operator grammar?
P, Q, R are not terminals and r, s, t are terminals.
(i) P → Q R
(ii) P → Q s R
(iii) P → ε
(iv) P → Q t R r

  • Option : B
  • Explanation :
    P → QR and P → ε is not possible for operator 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 *