More correct and robust EOF handling.
[gazelle.git] / sketches / eof_problem.gzl
blobd6f87ebd4d14e4cd27730cf8c601ddcbcb031bd6
2 // Providing eof_ok information is problematic for this grammar
3 // because if we've seen "XZ" the stack looks like this:
4 //
5 // +---------------------+
6 // | Rule: a             |
7 // |  Current State      |
8 // |  |                  |
9 // |  V                  |
10 // |  ,-x1-> o -y-,      |
11 // |  o           *      |
12 // |  `-x2-> o -z-'      |
13 // +---------------------+
14 // | GLA                 |
15 // |  Current State      |
16 // |       \             |
17 // |        \,-y-> *     |
18 // |  o -x-> o           |
19 // |         `-z-> *     |
20 // +---------------------+
21 // | IntFA               |
22 // |         ,-.         |
23 // |  ,-Y-> *<--Y        |
24 // |  o                  |
25 // |  `-Z-> *<--Z        |
26 // |        ^`-'         |
27 // |        |            |
28 // | Current State       |
29 // +---------------------+
31 // The problem is that to know that we are in an eof_ok state,
32 // we have to:
33 // 1. recognize that the IntFA is in a final state (no prob -- we do this already)
34 // 2. speculatively assume the token is finished
35 // 3. speculatively transition the GLA to its final state
36 // 4. speculatively take the x2 transition in rule a
37 // 5. speculatively take the z transition in rule a
39 // Of course this is possible, but it's complicated both in terms of programming
40 // effort and run-time efficiency.
42 x: /X+/;
43 y: /Y+/;
44 z: /Z+/;
46 a -> .x1=x y | .x2=x z;