# Calculating LL(1) grammar

I am trying to calculate the First and Follow of the following grammar

S->ABC
A->Aa
A->aB
B->Bb
B-> epsilon
C-> Cc
C-> Epsilon

I have calculated the firsts and it is all good

Follow(A) = {a,b,c,$} What is confusing me is the follow of B, I get Follow(B) = Follow(A) But on the other hand, I have a solution for the grammar that states that the follow(B) = {b,c,$}

So which one is the right one?

• Why do you think that $Follow(A)$ should be the same as $Follow(B)$? – Rick Decker Jul 13 at 19:38
• According to a rule that says * For any production rule A → αB, Follow(B) = Follow(A) – Athl1n3 Jul 15 at 5:53

It is evident that $$B$$ can be followed by $$a$$ — in other words, that $$a\in \text{FOLLOW}(B)$$ — as shown by the partial derivation
\begin{align}S&\to A B C&(S\to ABC)\\ &\to AaBC &(A\to Aa)\\&\to aBaBC&(A\to aB) \\ \end{align}