Example
Consider the following grammar
S' S
S CC
C cC | d
Compute closure(I) where I={[S' .S, $]}
S' .S, |
|
$
|
S .CC, |
|
$
|
C .cC, |
|
c
|
C .cC, |
|
d
|
C .d, |
|
c |
C .d, |
|
d |
For the given grammar:
S ' S
S CC
C cC | d
I : closure([S ' S, $])
S ' .S |
$ |
as first( e $) = {$}
|
S .CC |
$ |
as first(C$) = first(C) = {c, d}
|
C .cC |
c |
as first(Cc) = first(C) = {c, d}
|
C .cC |
d |
as first(Cd) = first(C) = {c, d}
|
C .d |
c |
as first( e c) = {c}
|
C .d |
d |
as first( e d) = {d}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|