Find an LL(2) grammar for the following language

1.2k Views Asked by At

The question asks to find both an LL(1) and an LL(2) grammar for the following language

{^ ^ ^+ | m,n ϵ N}

I have an LL(1) grammar like so

S --> aSc | T
T --> bTc | \lambda 

But what is the LL(2) grammar? I have this, but I don't feel confident in it

LL(2)
S --> aaScc | aSc | T
T --> bbTcc | bTc | $\Lambda$
1

There are 1 best solutions below

0
On

The question doesn't make sense: the $n$ in $LL(n)$ is a property of a language not a grammar.

An $LL(n)$ language is one that can be parsed by an $LL$ parser that uses at most $n$ look-ahead tokens. So any $LL(1)$ language is $LL(2)$ (because a parser can just ignore the second look-ahead token).