[antlr-interest] Attributes on AST nodes
Andy Tripp
antlr at jazillian.com
Thu Mar 23 07:02:37 PST 2006
Priya wrote:
>Is there a way to directly encode the precision and width information as
>a.precision , b.precision a.width b.width etc directly in the node itself?
>
>
>
Yes, just make your own subclass of antlr.Token.
There's some method to tell the lexer to create instances of your
subclass rather than antlr.Token objects.
I can't remember offhand what that method is, as I've done it the way it
should be done...
Have this interface:
interface TokenFactory {
antlr.Token makeToken(int type);
}
Have this method in the lexer:
public void setTokenFactory(TokenFactory tokenFactory) {
...
}
I hope that ANTLR v3 does it this way (maybe it already does it this way
- I'm still on 2.7.2)
More information about the antlr-interest
mailing list