[antlr-interest] Re: Exception issues

Eric Mahurin eric_mahurin at yahoo.com
Tue Aug 24 09:06:02 PDT 2004


I just figured out a partial workaround for the SemanticException.  If
you have a semantic predicate not used to qualify an alternative:

{condition}?

just change this to:

( {condition}? | {false}? )

This makes it throw NoViableAltException instead which does have line
number info.  Unfortunately, the message isn't useful - but the
line/column numbers are right.

It looks like the best solution is to try to move all of the semantic
predicates to be qualifiers on alternatives (or loops?) wherever possible.

Eric

--- In antlr-interest at yahoogroups.com, "Eric Mahurin"
<eric_mahurin at y...> wrote:
> Here are a few things I don't know how to resolve with the current
> antlr code with regard to exceptions:
> 
> 1. SemanticException is constructed without any line, column, or
> filename.  Why?  It is not a very useful message - especially to the
> end-user that sees an expression with internal variables.
> 
> 2. Ability to override the exception classes used for exception
> construction.  In my case, I have include files so that the filename
> is not constant.  I have another means of finding the filename (lookup
> table - ignores lexer/parser filename) and would like to use exception
> classes that use this method.
> 
> Eric



 
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