Package org.antlr.runtime.tree

Examples of org.antlr.runtime.tree.CommonTree.addChild()


    t.addChild(new CommonTree(new CommonToken(99, "b")));
    t.addChild(new CommonTree(new CommonToken(99, "c")));
    t.addChild(new CommonTree(new CommonToken(99, "d")));

    CommonTree newChildren = (CommonTree)adaptor.nil();
    newChildren.addChild(new CommonTree(new CommonToken(99,"x")));
    newChildren.addChild(new CommonTree(new CommonToken(99,"y")));

    t.replaceChildren(2, 2, newChildren);
    String expecting = "(a b c x y)";
    assertEquals(expecting, t.toStringTree());
View Full Code Here


    t.addChild(new CommonTree(new CommonToken(99, "c")));
    t.addChild(new CommonTree(new CommonToken(99, "d")));

    CommonTree newChildren = (CommonTree)adaptor.nil();
    newChildren.addChild(new CommonTree(new CommonToken(99,"x")));
    newChildren.addChild(new CommonTree(new CommonToken(99,"y")));

    t.replaceChildren(2, 2, newChildren);
    String expecting = "(a b c x y)";
    assertEquals(expecting, t.toStringTree());
    t.sanityCheckParentAndChildIndexes();
View Full Code Here

    t.sanityCheckParentAndChildIndexes();
  }

  @Test public void testReplaceOneWithTwoInMiddle() throws Exception {
    CommonTree t = new CommonTree(new CommonToken(99, "a"));
    t.addChild(new CommonTree(new CommonToken(99, "b")));
    t.addChild(new CommonTree(new CommonToken(99, "c")));
    t.addChild(new CommonTree(new CommonToken(99, "d")));

    CommonTree newChildren = (CommonTree)adaptor.nil();
    newChildren.addChild(new CommonTree(new CommonToken(99,"x")));
View Full Code Here

  }

  @Test public void testReplaceOneWithTwoInMiddle() throws Exception {
    CommonTree t = new CommonTree(new CommonToken(99, "a"));
    t.addChild(new CommonTree(new CommonToken(99, "b")));
    t.addChild(new CommonTree(new CommonToken(99, "c")));
    t.addChild(new CommonTree(new CommonToken(99, "d")));

    CommonTree newChildren = (CommonTree)adaptor.nil();
    newChildren.addChild(new CommonTree(new CommonToken(99,"x")));
    newChildren.addChild(new CommonTree(new CommonToken(99,"y")));
View Full Code Here

  @Test public void testReplaceOneWithTwoInMiddle() throws Exception {
    CommonTree t = new CommonTree(new CommonToken(99, "a"));
    t.addChild(new CommonTree(new CommonToken(99, "b")));
    t.addChild(new CommonTree(new CommonToken(99, "c")));
    t.addChild(new CommonTree(new CommonToken(99, "d")));

    CommonTree newChildren = (CommonTree)adaptor.nil();
    newChildren.addChild(new CommonTree(new CommonToken(99,"x")));
    newChildren.addChild(new CommonTree(new CommonToken(99,"y")));
View Full Code Here

    t.addChild(new CommonTree(new CommonToken(99, "b")));
    t.addChild(new CommonTree(new CommonToken(99, "c")));
    t.addChild(new CommonTree(new CommonToken(99, "d")));

    CommonTree newChildren = (CommonTree)adaptor.nil();
    newChildren.addChild(new CommonTree(new CommonToken(99,"x")));
    newChildren.addChild(new CommonTree(new CommonToken(99,"y")));

    t.replaceChildren(1, 1, newChildren);
    String expecting = "(a b x y d)";
    assertEquals(expecting, t.toStringTree());
View Full Code Here

    t.addChild(new CommonTree(new CommonToken(99, "c")));
    t.addChild(new CommonTree(new CommonToken(99, "d")));

    CommonTree newChildren = (CommonTree)adaptor.nil();
    newChildren.addChild(new CommonTree(new CommonToken(99,"x")));
    newChildren.addChild(new CommonTree(new CommonToken(99,"y")));

    t.replaceChildren(1, 1, newChildren);
    String expecting = "(a b x y d)";
    assertEquals(expecting, t.toStringTree());
    t.sanityCheckParentAndChildIndexes();
View Full Code Here

    t.sanityCheckParentAndChildIndexes();
  }

  @Test public void testReplaceTwoWithOneAtLeft() throws Exception {
    CommonTree t = new CommonTree(new CommonToken(99, "a"));
    t.addChild(new CommonTree(new CommonToken(99, "b")));
    t.addChild(new CommonTree(new CommonToken(99, "c")));
    t.addChild(new CommonTree(new CommonToken(99, "d")));

    CommonTree newChild = new CommonTree(new CommonToken(99,"x"));
View Full Code Here

  }

  @Test public void testReplaceTwoWithOneAtLeft() throws Exception {
    CommonTree t = new CommonTree(new CommonToken(99, "a"));
    t.addChild(new CommonTree(new CommonToken(99, "b")));
    t.addChild(new CommonTree(new CommonToken(99, "c")));
    t.addChild(new CommonTree(new CommonToken(99, "d")));

    CommonTree newChild = new CommonTree(new CommonToken(99,"x"));

    t.replaceChildren(0, 1, newChild);
View Full Code Here

  @Test public void testReplaceTwoWithOneAtLeft() throws Exception {
    CommonTree t = new CommonTree(new CommonToken(99, "a"));
    t.addChild(new CommonTree(new CommonToken(99, "b")));
    t.addChild(new CommonTree(new CommonToken(99, "c")));
    t.addChild(new CommonTree(new CommonToken(99, "d")));

    CommonTree newChild = new CommonTree(new CommonToken(99,"x"));

    t.replaceChildren(0, 1, newChild);
    String expecting = "(a x d)";
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.