# Computing Follow sets of Grammar for LL(1) parser

I am trying to compute the Follow set of the following Grammar:

E -> E' E A
A -> + | *
E -> num
E' -> num


I start by adding the end of string symbol, via. some non-terminal S such that:

S -> E$E -> E' E A A -> + | * E -> num E' -> num  Becomes the Grammar. With this I get the following set constraints for the productions: Production Set Constraint S -> E$${$$} <= Follow(E) E -> E' E A First(A) <= Follow(E) A -> + | * {+,*} <= Follow(A) E -> num {num} <= Follow(E) E' -> num {num} <= Follow(E')  With the above constraints, I can solve these with the following result: set initial Iteration 1 ... Follow(E) {$$, num} {$$, num, +, *} ... Follow(A) {+,*} {+,*} ... Folloe(E') {num} {num} ...  With further iterations no changes are made to the Follow sets and thus the final result I get is: Follow(E) = {$, num, +, *}
Follow(A)  = {+,*}
Follow(E') = num


However, can anyone verify if what I have done above is correct? I just recently learned how to compute these sets - and I am exercising with LL(1) parser construction.

• Also Follow(A) contains Follow(E) checkout this page jambe.co.nz/UNI/FirstAndFollowSets.html May 27 '20 at 17:54
• @MarkRegev How come? I tried to check out the webside you provided a link to, but from what I can see, there should never be a case where an A can be followed by a E? May 27 '20 at 18:04
• Rule 3. Also how did num get into the follow set of E? The solution should be Follow(E) = {$, +, *} Follow(A) = {$, +, *} Follow(E') = {num} May 27 '20 at 18:25
• @MarkRegev Yeah I make sense of it now. The webside however, can be a bit confusing as some of the rules only applies if nullable of a predicate is true, which is clearly stated in the rules that are mentioned. Thanks for clarifying though :-) May 27 '20 at 18:37