< S >a < S > b < S > |
![]()
[ < S' >. < S > $ ]
[ < S >. a < S > b < S > ]
[ < S >.
]
[ < S >a . < S > b < S > ]
[ < S >. a < S > b < S > ]
[ < S >![]()
. ]
We can use this machine anyway, if we are willing to look ahead a bit.
1 of an
input
1 x
2 we end up in a state that contains a reduce
item [ N
. ] which conflicts with some other item.
S![]()
N x
2
![]()
x
2
![]()
1 x
2
.

(Vn U Vt)*
we define First(
) to be the set of terminals that
might appear as the first symbol in a string derived from
. First(
) will include
if
. Thus,
First() = { a
Vt |
![]()
a
, for some
( Vn U Vt )* } U {
if
![]()
![]()
}
.
).
(Vt U Vn)
First( x )FirstSet[ x ]
} for all nullable
non-terminals and to { } for all other non-terminals.
t
add
t to FirstSet[ N ].
,
write
as
= 
'
where
is a string of nullable non-terminals,
and
' is either the
or a string of terminals
and non-terminals beginning with a non-nullable symbol we will
call M.

'

, add
(FirstSet[ x ] -
) to FirstSet[ N ].
' =
then
add
to
FirstSet[ N ] otherwise add
(FirstSet[ M ] -
) to FirstSet[ N ].