> On 3 Dec 2025, at 22:31, Jan K. <[email protected]> wrote: > > I'm trying to use the yyreport_syntax_error function to report syntax > errors in a grammar that has some optional components. In such case > the yypcontext_expected_tokens does not list the optional components > among the expected. How can I make it do that?
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. See the section 5.8 “Tuning LR” in the Bison manual. The command is %define lr.type type where type is one of lalr, ielr, canonical-lr, the first is the default.
