|
Boost : |
From: Joel de Guzman (djowel_at_[hidden])
Date: 2002-10-20 19:35:06
----- Original Message -----
From: "Larry Evans" <jcampbell3_at_[hidden]>
> Juan Carlos Arevalo-Baeza wrote:
>
> >On Sat, 19 Oct 2002 11:02:04 -0700, Carl Daniel wrote:
> >
> >
> >
> >>One concern I have, which I belive is based mostly in ignorance, is the
> >>ability of a Spirit-generated parser to perform error recovery and issue
> >>
> >>
> >>
> > Try the cpp_grammar test/thingy that I have here:
> >
> >http://home.JCABs-Rumblings.com/ftp/SpiritX/
> >
> [snip]
>
> >for display of the parser call-stack, so to speak, as in:
> >
> >cpp_grammar.cpp:285:9: Error: Expecting '}'
> > cpp_grammar.cpp:284:5: While parsing the member declarator
> > cpp_grammar.cpp:282:14: While parsing member template declaration
> > cpp_grammar.cpp:275:10: While parsing template declaration
> >
> This looks great. What about the possibility of resynchronizing the
> input for the next error message? There are some methods like skipping
> all input to the next, for example, closing paren or curly brace before
> restarting the parse. The purpose of these is to diagnose as many mistakes
> as possible. Does anybody have any ideas about doing this next?
This is certainly possible. The error handler can:
fail: quit and fail. Return a no_match
retry: attempt error recovery, possibly moving the scanner
accept: force success returning a matching length, moving the scanner
appropriately and returning an attribute value
rethrow rethrows the error
I guess JCAB answered this question quite well. I just want to add
that another interesting method for error handling is inserting tokens.
For instance, when the parser expects a close-paren ')' a recovery
attempt can be done by (issuing an error and) assuming the missing
token, after which, attempting to "retry" from that point.
Regards,
--Joel
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk