This ignores the lookahead token when deciding what to reduce, we always reduce
unconditionally. The main effects are:
- all potential partial parses are visible e.g. to error recovery. (In error scenarios, the intended reduction may not occur with SLR1 when the error occurs at the lookahead token).
- the size of the LR table is much smaller (In this patch we go from 340kB => 120kB, and the encoding isn't efficient)
- we explore more dead-ends due to lack of lookahead, and parser runs slower
- with this patch, the LR0 table parses ~1/3 slower than the SLR1. (LR0 allows code simplifications so we may win some of this back)
This patch uses eod as a dummy lookahead token for reduce actions:
i.e. reduces are Actions[State, eod]. The structure of glrParse is preserved:
we still track heads as "pending actions". To allow either LR0 or SLR1 to be
used, we perform lookups for both the actual lookahead token and eod.
In a real implementation we'd probably want to:
- switch glrParse to track head nodes, instead of pending actions on them. This should simplify the code there somewhat.
- use a separate storage in LRTable for reduce actions, like a parallel vector<RuleID> (sorted by stateid) and vector<size_t> (indexed by stateid)