On Thu, 2025-12-04 at 21:28 +0100, Jan Kończak 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'.
> 
> Regards,
> Jan
> 
> 


Consider also other parsing techniques: hand-written recursive descent parsers, 
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.
-- 

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

Reply via email to