I'm making my own compiler and I've gotten stuck with an error.
I have the grammar:
A -> + | -
B -> A C
C -> B
Now, following the rules I found here and here, the First and Follow Sets would be:
First(A) = {+, -}
First(B) = First(A) = {+, -}
First(C) = First(B) = First(A) = {+, -}
Follow(A) = First(C) = {+, -}
Follow(B) = Follow(C) = Follow(B) = ...
Follow(C) = Follow(B) = Follow(C) = ...
As you might notice, Follow(B)
and Follow(C)
loop back on themselves and cause me a StackOverflowError.
My question is: what to do when this happens, do we just say that Follow(B) = {}
or do we do something else? Is this just bad grammar?