Package org.antlr.runtime.tree

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


  }

  @Test public void testReplaceAtLeft() throws Exception {
    CommonTree t = new CommonTree(new CommonToken(99, "a"));
    t.addChild(new CommonTree(new CommonToken(99, "b"))); // index 0
    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, 0, newChild);
    String expecting = "(a x c d)";
View Full Code Here


  @Test public void testReplaceAtLeft() throws Exception {
    CommonTree t = new CommonTree(new CommonToken(99, "a"));
    t.addChild(new CommonTree(new CommonToken(99, "b"))); // index 0
    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, 0, newChild);
    String expecting = "(a x c d)";
    assertEquals(expecting, t.toStringTree());
View Full Code Here

    t.sanityCheckParentAndChildIndexes();
  }

  @Test public void testReplaceAtRight() 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"))); // index 2

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

  }

  @Test public void testReplaceAtRight() 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"))); // index 2

    CommonTree newChild = new CommonTree(new CommonToken(99,"x"));
    t.replaceChildren(2, 2, newChild);
    String expecting = "(a b c x)";
View Full Code Here

  @Test public void testReplaceAtRight() 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"))); // index 2

    CommonTree newChild = new CommonTree(new CommonToken(99,"x"));
    t.replaceChildren(2, 2, newChild);
    String expecting = "(a b c x)";
    assertEquals(expecting, t.toStringTree());
View Full Code Here

    t.sanityCheckParentAndChildIndexes();
  }

  @Test public void testReplaceOneWithTwoAtLeft() 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 testReplaceOneWithTwoAtLeft() 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 testReplaceOneWithTwoAtLeft() 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(0, 0, newChildren);
    String expecting = "(a x y c 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(0, 0, newChildren);
    String expecting = "(a x y c d)";
    assertEquals(expecting, t.toStringTree());
    t.sanityCheckParentAndChildIndexes();
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.