0% found this document useful (0 votes)
39 views20 pages

LL1 Parsing Table

Uploaded by

bca.deepak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views20 pages

LL1 Parsing Table

Uploaded by

bca.deepak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

A revised lecture

LL(1) Parser
LL(1) parsing table:
Step 1: Compute First() & Follow().
Step 2: LL(1) parsing table:
LL(1) parser:

Question: For the given grammar Check whether it is LL(1) or not. Also
construct its parsing table. Parse the string i+i*i using LL(1) parser.
LL(1) parser:
LL(1) parser:
LL(1) parser:
Let us take an example:

Question 1: Consider the grammar-


S-> Aa | b
A-> Ac | Sd | є
Check whether the given grammar
is LL(1) or not. Construct the LL(1)
parsing table.

Solution1:
For the construction of LL1 parsing
table. Firstly we need to find First()
Let us take an example:

The given grammar is-


S-> Aa | b
A-> Ac | Sd | є
For calculating First and follow, we firstly
need to check whether the grammar is
left recursive or not. If yes then
eliminate this indirect left recursion.
We see that A->Ac| Aad| bd| є only the
production having left recursion. So we
must remove LR.
Let us take an example:

The rule for eliminating Lrec is


If A->Aα | β Then production after LR removal will be-
A-> βA’
A’-> αA’ | є

So the required grammar will be-


S-> Aa | b
A->bdA’ | A’
A’->cA’ | adA’ |є
Now calculate First() and Follow():
First(S)= { a, b, c} Follow(S)={ $}
First(A)= { a, b, c, є} Follow(A)={a}
First(A’)={a,c,є} Follow(A’)={a}
Costruction ofLL(1) table:

a b c d $
T
NT
S S->Aa S->b A’->cA’ A’->є

A A’->adA’ A->bdA’ A’->cA’


A’->є
A’ A’->adA’ A’->cA
A’->є
What happened?

The given grammar is not LL(1)


because one section contains more
than one production.
LL Parser:
LL Parser:
Input Buffering:
Input Buffering:
Input Buffering:
Input Buffering:
Input Buffering:
Input Buffering:

You might also like