| SLR(1) parsing |
< 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
Follow( N ) = { xVt | A
![]()
N x
} U {
if S
![]()
N }
if the next "input" symbol is a.
Therefore, the three states with LR(0) conflicts really don't have
conflicts at all.
1 . ] and
[ M
2 . ] such that the intersection of
Follow(N) and Follow(M) is non-empty, or
1 . ] and
a shift item [ M
2 . x
2 ] such that
x
Follow(N).
when the next input symbol is "x":
if
[ N
. ] 
, and
x
Follow(N).
contains one or more items of the form
[ N
. x
].
| SLR(1) parsing |