Using exceptions for error reporting/recovery?

Geoff Elgey <>
2 Jun 1999 01:39:04 -0400

          From comp.compilers

Related articles
Using exceptions for error reporting/recovery? (Geoff Elgey) (1999-06-02)
| List of all articles for this month |

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


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...
        } // catch
        try {
            expression = recognizeExpression();
        } // try
        catch(ParseException e) {
            // error in parsing an expression...
        } // 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?


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?


Post a followup to this message

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