Re: yypcontext_expected_tokens does not list optional components in grammar

Basile Starynkevitch <[email protected]> Fri, 05 Dec 2025 10:42:13 +0100
Newsgroups gmane.comp.parsers.bison.general
Message-ID <[email protected]>
On Thu, 2025-12-04 at 21:28 +0100, Jan Ko=C5=84czak wrote:
> > It could be that using a parser based on IELR or LR fixes it. The defau=
lt
> > is LALR, which does not always see the error tokens immediately, but ma=
y
> > perform some reductions first.
>=20
> 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 examp=
le,
> 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 w=
ith=20
> complete list of expected tokens regardless of 'lr.type'.
>=20
> Regards,
> Jan
>=20
>=20


Consider also other parsing techniques: hand-written recursive descent pars=
ers, or
using parsers generated by https://www.antlr3.org/ or by https://carburetta=
.com/

Define also how do you want to recover from syntax or lexical errors.

Regards.
--=20

Basile STARYNKEVITCH                    basile AT starynkevitch DOT net
8 rue de la Fa=C3=AFencerie                       http://starynkevitch.net/=
Basile/ =20
92340 Bourg-la-Reine                         https://github.com/bstarynk
France                                https://github.com/RefPerSys/RefPerSy=
s
                  https://orcid.org/0000-0003-0908-5250