Consider the grammar: A → AB ∣ a B → *AC | Cb | e C → +ABc | e We are…

Consider the grammar:

A   →  AB  ∣  a

B   → *AC | Cb | e

C   →  +ABc | e

We are constructing a Canonical LR(1) (CLR(1)) parser for the above grammar.

Let I₀ be the initial state of the LR(1) parser.

When the parser reads symbol A from state I₀, it moves to a new state.
What is the next state reached on input A from state I₀, and what are the productions (items) contained in that state?

  1. A.

    S' → A•, $

    A → A • B, $  

    B → • *AC, $

    B → • Cb, $

    B → • e, b

    C → • +ABc, b

    C → • e, b

  2. B.

    S' → A•, {$}

    A → A • B, {$,*,+}  

    B → • AC, {$,,+}

    B → • Cb, {$,*,+}

    B → • e, {$,*,+}

    C → • +ABc, {b}

    C → • e, {b}

  3. C.

    S' → A•, {$}

    A → A • B, {$,*,+,e}  

    B → • AC, {$,,+,e}

    B → • Cb, {$,*,+,e}

    B → • e, {$,*,+,e}

    C → • +ABc, {b}

    C → • e, {b}

  4. D.

    S' → A•, {$}

    A → A • B, {$,*,+,e}  

    B → • AC, {$,,+,e}

    B → • Cb, {$,*,+,e}

    B → • e, {$,*,+,e}

    C → • +ABc, {$,b}

    C → • e, {$,b}

Attempted by 72 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…