[antlr-interest] Re: Request enhancement ANTLR

Dennis Marsa drm at xilinx.com
Tue Jun 25 09:12:05 PDT 2002


Silvain Piree wrote:
> 
> > You're right that getFilename() may not return something
> > useful, but it could return something indicating that the
> > filename is not there, either an empty string, or "<no file>",
> > or something.
> 
> Sounds reasonable, but wouldn't it impact existing users,
> who depend on the getFilename() behaviour?

I don't think so.

To be explicit, I'm suggesting adding a new NoViableAltException
constructor.  The existing two argument (token, filename) constructor 
could stay for compatibility reasons.

public class NoViableAltException extends RecognitionException {

    // suggested new constructor
    public NoViableAltException(Token t) {
        super("NoViableAlt", t.getFilename(), t.getLine(), t.getColumn());
        token = t;
    }

    // existing constructor
    public NoViableAltException(Token t, String fileName_) {
        super("NoViableAlt", fileName_, t.getLine(), t.getColumn());
        token = t;
    }

    <remainder of class definition omitted for brevity>
}


But, it seems most NoViableAltException constructions are generated by
ANTLR, so it could easily be updated to use the new single-argument
constructor without impacting users.

Any existing explicit NoViableAltException constructions made by the
user would still get the two-argument version, but could be updated
to use the single-argument version.

Dennis

 

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



More information about the antlr-interest mailing list