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) |
From: | nandu@longs.dr.lucent.com |
Newsgroups: | comp.compilers |
Date: | 25 May 1997 13:40:19 -0400 |
Organization: | Compilers Central |
References: | 97-05-153 |
Keywords: | parse, errors |
<MarkAGr> Wrote:
! The one thing we rarely get around here are questions concerning
!error recovery while parsing. What systems exist already for error
!recovery, and what form do they take? What would be the ideal and how
!can we implement them? I have very few ideas in this area and would be
!happy for any suggestions.
One of the fundamental requirements to perform any form of error
recovery is to atleast obtain the erroneous tokens while parsing. I
have been using PCYACC and PCLEX (from Abraxas Software) lately and
there is no direct way to obtain the erroneous tokens. I believe this
is true of lex and yacc in general.
Here is what I mean: Suppose I have a production to parse out valid
user names in a given environment, WORD being an alphabetical string
terminal containing the username.
UserName : '"' WORD '"'
{
valid($3) ? printf("%s valid", $3) : printf("%s unknown", $3);
}
| '" error '"'
{
printf("%s not a valid username format", $3);
}
what I would like to do in the 'error' production is to tell the user
what the error string was. However, the parser reduces the first
unknown token in the input stream to 'error', discards all the
following tokens until a " is seen in the input stream and reduces to
the error production. I have no way of retrieving the discarded
tokens. Wouldn't it be nice to store the discarded tokens in the
'error' terminal?
I guess one of the reasons why this is not being done by default is
because it precludes any custom error recovery that a user might
prefer. Maybe a command line option to the parser could choose between
the default and user defined error recovery.
Nandakumar SANKARAN
nandu@lucent.com
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.