Re: Error Recovery

Mark Gregory <mag01@jvcam.northern.co.uk>
27 May 1997 23:49:43 -0400

          From comp.compilers

Related articles
Re: error recovery hankd@ee.ecn.purdue.edu (1989-04-30)
Error recovery cayot@essi.fr (Cayot Robert-Olivier) (1997-03-21)
Re: Error recovery gvcormac@plg.uwaterloo.ca (Gord Cormack) (1997-03-22)
Re: Error recovery P.Whillance@ncl.ac.uk (Peter Whillance) (1997-03-27)
Error Recovery markagr@aol.com (1997-05-12)
Re: Error Recovery nandu@longs.dr.lucent.com (1997-05-25)
Re: Error Recovery tc@charlie.cns.iit.edu (Thomas W. Christopher) (1997-05-25)
Re: Error Recovery mag01@jvcam.northern.co.uk (Mark Gregory) (1997-05-27)
Re: Error Recovery mcr@visi.com (Michael Roach) (1997-05-31)
| List of all articles for this month |
From: Mark Gregory <mag01@jvcam.northern.co.uk>
Newsgroups: comp.compilers
Date: 27 May 1997 23:49:43 -0400
Organization: Bell Northern Research
References: 97-05-153 97-05-293
Keywords: parse, errors

Thomas W. Christopher wrote:
>
> A fiducial symbol is a terminal symbol that ends or separates
> significant sections of program, e.g. ";", "end", "else".


Hello Thomas ...


      I'm MarkAGr ( when I'm at home )


The LL(k) generator I'm building needs a little more than the error
recovery function ( "exit(-1);" ) that it already has ... and the
system you described is the closest to that that I have already
envisaged ... ie. when an error occurs ... the input stream is
absorbed until a "guardian production" ( instead of "fiducial symbol"
) is found. The parser then continues from a given production as if no
error has occured. This type of error recovery can ( relatively easily
) be generated automatically, by pushing the
"end-of-current-production" production onto a "guardian
production-stack" prior to any sub-production being entered, and
popped if the sub-production resolves successfully. ( However an
implementation is possible with no stack required for a
recursive-descent parser. ) Finding a way to incorporate this
guardian-production into the meta-syntax is another problem. My first
attempt will be in the production declatation ...


KEY
"..." ... literal
{ ... } . optional
; ....... expression terminator
blaBla .. sample of a sub-production
[n] ..... inline code


        production := [0]
                productionIdent { "<" guardianProductionIdent[1] ">" } ":="
productionBody ";"[2] ;


instead of the usual


        production := productionIdent ":=" productionBody ";" ;




with the following code inserts ...




[0] int guardianPushed=0;
[1] pushGuardianFunction( theLexeme() );
        guardianPushed=1;
[2] if( guardianPushed )
        {
                popGuardian();
        }


and the inline error recovery function is no longer ...


        exit( -1 );


but ...


        if( errorCondition )
        {
                int (*guard)() = popGuardian();


                guardianPushed = 0;
                errorDisplayRoutine();
                errorCount++;
                while( !guard() )
{
                        disguardLexeme();
                }
                return VALID_PRODUCTION;
                        /* assuming that a production function returns production
recognition */
        }




Please forgive the implementation specific details ... but sometimes it
help's me to clarify my thoughts, far more than prose ...


--
MarkAGr@aol.com
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.