LL(1) Grammar:
(1) Var -> ID DimList
(2) DimList -> ε DimList'
(3) DimList' -> Dim DimList'
(4) DimList' -> ε
(5) Dim -> [ CONST ]
And, in the script that I am reading, it says that the function FIRST(ε DimList')
gives {#, [}
. But, how?
My guess is that since the right side of (2) begins with ε
, it skips epsilon and takes FIRST(DimList')
which is, considering (3) and (5), equal to {[}
, BUT also, because of (4), takes FOLLOW(DimList')
which is {#}
.
Other way it could be is that, since (2) begins with ε
it skips epsilon and takes FIRST(DimList')
BUT ALSO takes FOLLOW(DimList) from (2)...
First one makes more sense to me, though I'm still in the process of learning basics of LL(1) grammars so I would appreciate if someone takes the time to make this clear, thank you.
EDIT: And, of course, it could be that neither of these is true.