[antlr-interest] Pattern for returning errors from ANTLR in data structures, not STDERR
Terence Parr
parrt at cs.usfca.edu
Tue Nov 30 17:20:19 PST 2010
Check ANTLRToolListener in antlr source or whatever. it has a similar problem to solve.
Ter
On Nov 30, 2010, at 5:13 PM, Arthur Goldberg wrote:
> Hello All
>
> My ANTLR parser is embedded in other code. I've decided that reporting
> errors out of the parser would be better handled as a list of errors,
> not exceptions, so that the parse is allowed to recover from errors and
> complete, if possible.
> Does anyone have a working pattern for returning errors from ANTLR in a
> list, not STDERR?
> In more detail, I'd run it in two modes:
> 1) testing: call some rule other than the root
> In this case, I will let the rule report an error via an exception.
>
> 2) production: call the root rule
> In this case, a newReportError() in
>
> catch (RecognitionException re) {
> newReportError(re);
> recover(input,re);
> }
>
> would catch exceptions thrown by other rules, and store them in a list.
> When the root rule returns, it returns the list of errors, along with
> the results of the parse.
>
> If someone can help me with this, I'll make it worth your while. I'm
> running out of time for messing with ANTLR.
>
> Thanks
> Arthur
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
More information about the antlr-interest
mailing list