First and Follow Sets for a Grammar
- by Aimee Jones
I'm studying for a Compiler Construction module I'm doing and I have a sample question as follows:
Calculate the FIRST and FOLLOW sets for the following grammar..
S -> uBDz
B -> Bv
B -> w
D -> EF
E -> y
E -> e
F -> x
F -> e
I have tried to figure it out so far but I'm a bit unsure if I'm correct. Could someone verify if I'm doing it right, and if not, what am I missing? My answer is below:
FIRST | FOLLOW
S | {u} | {$}
B | {w} | {y,x,v,z}
D | {y,e,x} | {z}
E | {y,e} | {x,z}
F | {x,e} | {z}