How can I put nodes back into the AST even though there's a recognition error?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Peter_DePasquale
Posted On:   Saturday, September 14, 2002 02:35 PM

In my application, I'm recognizing C++ code (more or less....). However, when a recoginition error comes along, we call an overidden reportError method to create our error list (for display to the user). What I've found is that the RECOGNITION ERROR messages are nearly useless to the user (1st semester programming students), and I'd like to do (try) the following: let the parser skip the message and put SOMETHING in the AST where the error occured and let the semantic checker take a swing at it. I'm realizing this may be too vague to put something back into the AST, so the other way to ask this is how do I make the parser's error messages more useful? Thanks.    More>>

In my application, I'm recognizing C++ code (more or less....). However, when a recoginition error comes along, we call an overidden reportError method to create our error list (for display to the user).

What I've found is that the RECOGNITION ERROR messages are nearly useless to the user (1st semester programming students), and I'd like to do (try) the following: let the parser skip the message and put SOMETHING in the AST where the error occured and let the semantic checker take a swing at it.

I'm realizing this may be too vague to put something back into the AST, so the other way to ask this is how do I make the parser's error messages more useful?

Thanks.

   <<Less

Re: How can I put nodes back into the AST even though there's a recognition error?

Posted By:   Adam_McClure  
Posted On:   Saturday, September 14, 2002 05:31 PM

There's a number of facilities you can use. First, try supplementing your rules with the 'paraphrase' option to deliver more user-friendly errors.


Second, you can create your own error handler and override the default error handler.


If you want the parser to continue reading past the error then I think you will need to have some sort of semantic checker that knows when to stop consuming tokens on the input stream and allow regular parsing to continue. This is clearly some extra work and is usually only done for commercial compilers that are used within an IDE or command-line.

About | Sitemap | Contact