What is the FIRST and FOLLOW sets for this grammar...

157 Views Asked by At

With the definitions of FIRST being the set of terminal symbols that begin strings derived from α, and FOLLOW being:

FOLLOW(A) = { a | S ⇒* αAaβ }

What are the FIRST and the FOLLOW sets for the following grammar?

E1 → E2F1end 
F1 → +E1 | ε 
E2 → numF2 
F2 → *E2 | ε

I'm thinking:

FIRST(E1) is {num}
FIRST(F1) is {+, ε}
FIRST(E2) is {num}
FIRST(F2) is {*, ε}

Not a clue for the the follow sets though.