Which of the following is FALSE?

2016

Which of the following is FALSE?

Answer: B. SLR is more powerful than LALRCONCEPT: SLR(1) and LALR(1) are bottom-up LR parsers built with one token of lookahead. Parser-class power is compared by containment: one class is more…

  1. A.

    The grammar S → aSb | bSa | SS | ε, where S is the only non-terminal symbol and ε is the null string, is ambiguous

  2. B.

    SLR is more powerful than LALR

  3. C.

    An LL(1) parser is a top-down parser

  4. D.

    YACC tool is an LALR(1) parser generator

Attempted by 168 students.

Show answer & explanation

Correct answer: B

CONCEPT: SLR(1) and LALR(1) are bottom-up LR parsers built with one token of lookahead. Parser-class power is compared by containment: one class is more powerful when it parses every grammar in the other class without conflict and also parses some additional grammars.

Both constructions have the same LR(0) state cores and therefore the same number of parser states. SLR(1) assigns reductions using a non-terminal’s grammar-wide FOLLOW set, whereas LALR(1) retains more precise state-specific lookaheads while merging compatible LR(1) states. Those more precise lookaheads remove some conflicts that remain in SLR(1), so every SLR(1) grammar is LALR(1), but not conversely.

APPLICATION: The statement “SLR is more powerful than LALR” reverses the actual containment relation. LALR(1), not SLR(1), is the strictly more powerful parser class; therefore that statement is false.

CROSS-CHECK: The remaining statements agree with their defining rules:

  • For S → aSb | bSa | SS | ε, even ε has two distinct parse trees: S ⇒ ε and S ⇒ SS ⇒ εε. Hence the grammar is ambiguous.

  • An LL(1) parser starts from the grammar’s start symbol and selects productions using one lookahead token, so it is a predictive top-down parser.

  • YACC accepts a grammar specification and generates an LALR(1) shift-reduce parser.

RESULT: The false statement is “SLR is more powerful than LALR”; the saved key is therefore correct.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor Computer Science Paper 2

Loading lesson…