in Compiler Design retagged by
222 views
0 votes
0 votes
Compute FIRST and FOLLOW sets:

S→ aAC | bB

A→ Abc| Abd | e

B→ f | g

C→ h | i
in Compiler Design retagged by
222 views

1 Answer

0 votes
0 votes
Non terminal First Follow
S {a,b} {$}
A {e} {b,h,i}
B {f,g} {$}
C {h,i} {$}

 

4 Comments

isn’t this grammar left recursive? (production number 2)

and in LL(1) we can’t have left recursion and non-determinism, right?
0
0
Yes the grammar is left recursive so it cant be LL(1).

 

You can check it  by creating the LL(1) parsing table for this production.
0
0
i am aware of that. what i really meant was if the grammar itself isn’t LL(1) itself then are the first and follow you calculated valid?
0
0

@juniorG  Before calculating the first and follow functions, eliminate Left Recursion from the grammar, if present.

0
0