I have the following grammar:
S -> aXab
S -> Y
X -> bYa
X -> epsilon
Y -> Sc
I have computed the first and follow sets for this grammar and I would like to know if it is correct. Here is my solution:
First Sets:
S -> {a}
X -> {b,epsilon}
Y -> {a}
Follow Sets:
S -> {$,c}
X -> {a}
Y -> {c,a}
Any help is appreciated. Thanks.
FIRST sets are correct. FOLLOW(Y) should be {$,c,a}
FOLLOW(A) definition is
FOLLOW(Y), check where it is there in the right-hand side
when this production is taken for derivation what follows Y is 'a'
when this production is taken for derivation what follows Y is, What ever that was following S. FOLLOW(S)={$,c}