Consider the following grammar S → m | mn | mno Choose correct statement from…

2020

Consider the following grammar

S → m | mn | mno

Choose correct statement from the following:

  1. A.

    The grammar is LL(4)

  2. B.

    The grammar is LL(3)

  3. C.

    The grammar is LL(2)

  4. D.

    The grammar is LL(1)

Attempted by 80 students.

Show answer & explanation

Correct answer: B

To determine if the grammar S m | mn | mno is LL(k), we find the minimum lookahead k to distinguish productions.

  • FIRST3(m) = {m}

  • FIRST3(mn) = {mn}

  • FIRST3(mno) = {mno}

Since all three lookahead sets of length 3 are completely disjoint, a parser needs exactly 3 symbols of lookahead to make a unique decision. Thus, it is LL(3).

Correct Answer: The grammar is LL(3) (Option B).

Explore the full course: Niacl Ao It Specialist