[antlr-interest] Re: Request enhancement ANTLR
Silvain Piree
s.piree at enneya.com
Thu Jun 20 23:30:14 PDT 2002
Terence,
> I like this concept by the way, but I'm nervous about adding
> 4 bytes to every single token. 'course you can just make a
> subclass of CommonToken and then tell antlr to build those,
> right?
It is true that you can subclass the CommonToken class,
but there is one problem: the generated parser uses
parser.getFilename() when throwing a NoViableAltException.
I have a suggestion to solve this problem:
1. add:
class Parser {
public getFilename(Token token) {
return inputState.filename;
}
}
2. change JavaCodeGenerator (and CppCodeGenerator) to:
throw new NoViableAltException(LT(1), getFilename(LT(1)))
3. now everything works the way it did, but I have the
possiblity the redefine getFilename(Token token) and get
the filename from my (subclassed) token.
Silvain
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list