LR(1) grammar/parser and lookahead-restrictions

Michael Dyck jmdyck at
Sun Feb 12 14:21:23 UTC 2017

On 17-02-07 06:02 PM, Waldemar Horwat wrote:
> Lookahead restrictions fit very well into an LR(1) engine [...]
> it's directly tied into the generation of the automaton states. Each
> automaton state contains a collection of possible places in the
> expansions of grammar rules that the state can represent. Following a
> terminal symbol T from a state A leads to a state B. A lookahead
> restriction prevents state B's collection from including expansions that
> would have been prohibited by the lookahead restriction on T. If that
> generates an inconsistency (for example, if there are two ways to get to
> an identical state, one with a lookahead restriction and one without),
> the grammar validation fails.

So that sounds like you form the closure of state A in the standard way, and 
then use the lookahead-restriction to limit the transitions out of A (and 
the items that A contributes to the kernel of B). But it seems to me that 
forming the closure is also affected by the lookahead-restriction. Is that 
true in your validator?


More information about the es-discuss mailing list