> On 4 Dec 2025, at 21:28, Jan Kończak <[email protected]> wrote: > >> It could be that using a parser based on IELR or LR fixes it. The default >> is LALR, which does not always see the error tokens immediately, but may >> perform some reductions first. > > Thanks for the pointers, it really did help me to find the right solution. > While switching to LR parser indeed yielded expected results in the example, > I believe the thing that I was missing was enabling 'Lookahead Correction' > by the '%define parse.lac full' directive, which is in the manual section > that you mentioned. Having that, yypcontext_expected_tokens provides me with > complete list of expected tokens regardless of 'lr.type'.
Actually, I already had it in my own grammar. 🙂 Its addition was discussed on the Bison lists and added at some point. The precedence rules, including %nonaasoc, look at the tokens immediately before and after the parser position in a state and make decisions based on that, so it depends on the parser algorithm used. I made a different method that prohibits grammar expansions instead, which possibly might do better here if implemented.
