Re: Error Recovery
25 May 1997 13:40:19 -0400

          From comp.compilers

Related articles
Re: error recovery (1989-04-30)
Error recovery (Cayot Robert-Olivier) (1997-03-21)
Re: Error recovery (Gord Cormack) (1997-03-22)
Re: Error recovery (Peter Whillance) (1997-03-27)
Error Recovery (1997-05-12)
Re: Error Recovery (1997-05-25)
Re: Error Recovery (Thomas W. Christopher) (1997-05-25)
Re: Error Recovery (Mark Gregory) (1997-05-27)
Re: Error Recovery (Michael Roach) (1997-05-31)
| List of all articles for this month |

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

Post a followup to this message

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