Question

The grammar is this:

S -> e (epsilon)

S -> TS

T -> (S)

I think it is indeed LL(1), my justification is that for a grammar to be LL(1), for each nonterminal that has more than 1 production rule, the director symbol sets of the rules must be disjoint, thus in this case:

DS(S->e) =

First(S->e) U Follow(S->e) = { ) }

And,

DS(S->TS) = First(S->TS) = { ( }

And since { ) } and { ( } are disjoint, therefore the grammar is LL(1).

Is my justification correct ?

Was it helpful?

Solution

Yes, this grammar is LL(1). Note that

FIRST(S) = { ε, ( }

FOLLOW(S) = { ), $ }

FIRST(T) = { ( }

Therefore, the parsing table is

    (     )     $
S   TS    e     e
T   (S)

Since there are no conflicts here, the grammar is LL(1).

Hope this helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top