Question

How to prove that the grammar G is not LL(1) The grammar is: L => LE...

How to prove that the grammar G is not LL(1)

The grammar is:

L => LE | E
E => (C) | (F) | V | T
C => ifEE | ifEEE
F => +L | -L | *L | printL
V => a | b | c | d
T => 0 | 1 | 2 | 3
0 0
Add a comment Improve this question Transcribed image text
Answer #1

A grammar G is LL(1) if and only if the folowing conditions hold for distinct productions of the form A α/β i) First(α) First(B) φ ii) First(B) contains , E, then First(α) n Follow(A) φThe given grammar

L => LE | E
E => (C) | (F) | V | T
C => ifEE | ifEEE
F => +L | -L | *L | printL
V => a | b | c | d
T => 0 | 1 | 2 | 3

In this grammar there is left recursion in production

L => LE | E

Since there is left recursion the grammar G is not LL(1)

To prove the grammar G is not LL(1) we need to check for above two conditions

In Grammar G

First(E)={(,a,b,c,d,0,1,2,3}

First(LE)={First(E)}

={(,a,b,c,d,0,1,2,3}

It is clearly visible that condition 1 is violated

ie)

There for all terminals 0,1,2,3,a,b,c,d

(L,0) , (L,1), (L,2),....,(L,d)

there will be two entries in predicative parsing table

L->LE and L->E

So the given grammar G is not LL(1)

Add a comment
Know the answer?
Add Answer to:
How to prove that the grammar G is not LL(1) The grammar is: L => LE...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT