[antlr-interest] Re: exceptions in the lexer

Terence Parr parrt at cs.usfca.edu
Sat Dec 11 10:16:39 PST 2004



On Dec 10, 2004, at 5:11 PM, Colm McHugh wrote:
>> Agreed, though I'm afraid it would break something.
>> I'll add to list
>> to examine for 2.7.5, which I hope to jump on next
>> week around
>> thursday.
>>
> Might that 'something' be related to syntactic
> predicate?
Hi Colm. :)  Nice to hear from you.

Nope...not syn pred stuff.  Recognition problems should be caught by 
the syn pred and ignored; then the next viable alternative should be 
attempted.

>
> I've been grappling with this exact same problem for
> the past week, namely trapping bad character (or
> lexical) errors.
>
> I switched all catches of TokenRecognitionException in
> my parser to catch ANTLRException (I want to do my own
> exception handling), and that traps all bad characters
> except for one case, and that is when a bad character
> is found while in syntactic predicate guess mode; the
> exception does not get trapped and causes the process
> to abort [this is bad]. The same bad character error
> is trapped when it's not part of a syntactic
> predicate, hence my finger-pointing at syn preds.
>
Ah.  Well, no the syn preds are using recognition errors to say "oh, 
that alt won't match; try again with next alt."

> I've looked at the generated code for the parser, and
> a catch block is only executed if guessing is not on,
> otherwise it does a 'throw'. Why is this ? Is there a
> good reason to not do the user's exception-handling if
> we are in guess mode ?
>
Yes, all catches are turned off except for one generated for the syn 
pred.
>
Ter
--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
Cofounder, http://www.knowspam.net enjoy email again!





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list