help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Print expected tokens in yyerror function.


From: Claudio Saavedra
Subject: Re: Print expected tokens in yyerror function.
Date: Sat, 29 Mar 2008 09:22:23 -0300

El sáb, 29-03-2008 a las 13:05 +0100, Hans Aberg escribió:
> On 29 Mar 2008, at 12:50, Claudio Saavedra wrote:
> >> It prints something like that (or used to), but the LALR(1) that
> >> Bison uses compacts the statements in a way that when an error token
> >> appears in the input, additional reduction can be performed. So to
> >> get a fully correct error handling, including tokens, LR without this
> >> type of compaction, or some search algorithm would be needed.
> >
> > The Burke-Fisher technique uses a deferred parsing mechanism to  
> > simulate
> > a limited degree of unparsing. With this, errors, that are detected
> > after some reductions and shifts take place, can still be detected and
> > properly diagnosed and fixed.
> >
> > This do works with Bison's LALR algorithm and table compactation. I  
> > have
> > a bison skeleton that works this way, and I'll be publishing it pretty
> > soon.
> 
> The problem is that after an error token has arrived in the input,  
> additional reductions can take place before an error is issued by the  
> parser. So, although errors are detected, they are issued at a point  
> hampering good error recovery.

That's exactly what the deferred parsing mechanism takes care of. If an
implementation, with a deferral level of k tokens, detects an error at
certain point, the state of the parser is restored to the state it was
before the last k tokens were shifted, "undoing" as well the
corresponding reductions. Then, the error diagnosis and correction
mechanism is invoked.

I recommend reading 2.1.3 and 2.3.1 from [BF87], where this is explained
in complete detail.

[If I'm moving OT, please say]

Greetings,

Claudio

[BF87] http://portal.acm.org/citation.cfm?id=22719.22720

-- 
Claudio Saavedra <address@hidden>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]