1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
{-
This example demonstrates that the computation of the look-ahead
information must use a stack of transitions (rather than a single
transition). If we have several epsilon-reductions in a row, we must
be able to backtrack to the original state.
frown LA.g
-}
module LA
where
type Terminal = Char
type Result = []
%{
Terminal = 'a' | 'b' | 'c' | 'x' | 'y';
Nonterminal = s | a | b | c | e1 | e2;
s : 'a', a, 'x';
| 'a', c, 'y';
| 'b', a, 'y';
| 'b', c, 'x';
a : b, e1, e2;
b : 'c';
c : 'c';
e1 : ;
e2 : ;
}%
frown ts = fail "syntax error"
|