Using exceptions for error reporting/recovery?

Geoff Elgey <elgey@dstc.qut.edu.au>
2 Jun 1999 01:39:04 -0400

          From comp.compilers

Related articles
Using exceptions for error reporting/recovery? elgey@dstc.qut.edu.au (Geoff Elgey) (1999-06-02)
| List of all articles for this month |

From: Geoff Elgey <elgey@dstc.qut.edu.au>
Newsgroups: comp.compilers
Date: 2 Jun 1999 01:39:04 -0400
Organization: Distributed Systems Technology CRC
Keywords: errors, parse, question

G'day,


I'm wrting a recursive descent parser in Java, and I'd like to use
exceptions to handle error reporting and recovery, rather than supplying
halting symbols to my production recognition methods.


Something like:


    public void recognizeAssignment() {
        Designator designator = null;
        Expression expression = null;
        try {
            designator = recognizeDesignator();
        } // try
        catch(ParseException e) {
              // error in parsing designator...
              skipTo(AssignmentSymbol,SemicolonSymbol);
        } // catch
        expect(AssighnmentSymbol);
        try {
            expression = recognizeExpression();
        } // try
        catch(ParseException e) {
            // error in parsing an expression...
            skipTo(SemicolonSymbol);
        } // catch
        return new Assignment(designator,expression);
    }


I suspect there might be a paper or body of theory describing the proper
method of doing this, but I cannot find anything on the web at the
moment. Does anyone have any more info on this?


Also:


For an unrelated project, I'm looking for a grammar for the English
language (or for a structured form of English). Does anyone know where I
can find one?


Cheers,
Geoff


Post a followup to this message

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