[antlr-interest] Bug: CommonTreeNodeStream not passing adaptor to TreeIterator

Kaleb Pederson kaleb.pederson at gmail.com
Mon Nov 9 13:55:23 PST 2009


The CommonTreeNodeStream constructor fails to pass 'adaptor' into the
TreeIterator:

	public CommonTreeNodeStream(TreeAdaptor adaptor, Object tree) {
        super(adaptor.create(Token.EOF, "EOF")); // set EOF
		this.root = tree;
		this.adaptor = adaptor;
        it = new TreeIterator(root);
        it.eof = this.eof; // make sure tree iterator returns the EOF we want
	}

This results in the following constructor being called:

    public TreeIterator(Object tree) {
        this(new CommonTreeAdaptor(),tree);
    }

Which results in the UP, DOWN, and EOF tokens not being of the correct
class as created by the other TreeIterator constructor:

    public TreeIterator(TreeAdaptor adaptor, Object tree) {
        this.adaptor = adaptor;
        this.tree = tree;
        this.root = tree;
        nodes = new FastQueue();
        down = adaptor.create(Token.DOWN, "DOWN");
        up = adaptor.create(Token.UP, "UP");
        eof = adaptor.create(Token.EOF, "EOF");
    }

Thanks.

--
Kaleb Pederson

Blog - http://kalebpederson.com
Twitter - http://twitter.com/kalebpederson


More information about the antlr-interest mailing list