I'm new to LL(1) parsing and am currently trying to figure out how to create a parse table for the language:
S → Saa|b
and
S-> A|B
A-> aa
B-> bb
and
S → AB
A → aa
B → bb
I'm new to LL(1) parsing and am currently trying to figure out how to create a parse table for the language:
S → Saa|b
and
S-> A|B
A-> aa
B-> bb
and
S → AB
A → aa
B → bb
I'll show you the complete procedure for the first grammar. Tell me if there are any aspects you would like to examine in greater depth.
S → Saa | b
S → bS'
S' → aaS' | ε
No need for this grammar.
------------------------------------
| A → α | FIRST(α) | FOLLOW(A) |
------------------------------------
| S → bS' | a | $ |
------------------------------------
| S' → aaS' | a | $ |
------------------------------------
| S' → ε | ε | $ |
------------------------------------
for each prodution A → α
for each a ∈ FIRST(α)
add production A → α to M[A,a]
if ε ∈ FIRST(α) then
for each b ∈ FOLLOW(A)
add A → α to M[A,b]
Result:
-------------------------------------
| | a | b | $ |
-------------------------------------
| S | | S → bS' | |
-------------------------------------
| S' | S → aaS' | | S' → ε |
-------------------------------------
The grammar is LL(1). Here the results of the other grammars.
1.
-------------------------------------
| | a | b | $ |
-------------------------------------
| S | S → A | S → B | |
-------------------------------------
| A | A → aa | | |
-------------------------------------
| B | | B → bb | |
-------------------------------------
2.
-------------------------------------
| | a | b | $ |
-------------------------------------
| S | S → AB | | |
-------------------------------------
| A | A → aa | | |
-------------------------------------
| B | | B → bb | |
-------------------------------------