[antlr-interest] Why does ASTFactory.create(Token tok) creates new token instead of using token passed as a parameter

Vladmir Kvashin Vladimir.Kvashin at Sun.COM
Mon Mar 20 21:15:47 PST 2006


Hi,

Could anybody answer my, why TokenFactory behaves in a following way.

In method create(Token tok) it creates a new token and then just copies 
(via initialize() method) values from the token that is passes as a 
parameter.

    public AST create(Token tok) {
        AST t = create(tok.getType());
        if ( t!=null ) {
            t.initialize(tok);
        }
        return t;
    }

My idea is to make my own extension of AstFactory, which would hold the 
initial token instead of creation new one. Are some drawbacks of such 
decision? I don't see any.

If there are no, then probably it's worth to make this behaviour default?

Thanks,
Vladimir




More information about the antlr-interest mailing list