Examples of TreeWizard


Examples of org.antlr.runtime.tree.TreeWizard

    String expecting = "A";
    assertEquals(expecting, found);
  }

  @Test public void testSingleLevelTree() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t = (CommonTree)wiz.create("(A B C D)");
    String found = t.toStringTree();
    String expecting = "(A B C D)";
    assertEquals(expecting, found);
  }
View Full Code Here

Examples of org.antlr.runtime.tree.TreeWizard

    String expecting = "(A B C D)";
    assertEquals(expecting, found);
  }

  @Test public void testListTree() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t = (CommonTree)wiz.create("(nil A B C)");
    String found = t.toStringTree();
    String expecting = "A B C";
    assertEquals(expecting, found);
  }
View Full Code Here

Examples of org.antlr.runtime.tree.TreeWizard

    String expecting = "A B C";
    assertEquals(expecting, found);
  }

  @Test public void testInvalidListTree() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t = (CommonTree)wiz.create("A B C");
    assertTrue(t==null);
  }
View Full Code Here

Examples of org.antlr.runtime.tree.TreeWizard

    CommonTree t = (CommonTree)wiz.create("A B C");
    assertTrue(t==null);
  }

  @Test public void testDoubleLevelTree() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t = (CommonTree)wiz.create("(A (B C) (B D) E)");
    String found = t.toStringTree();
    String expecting = "(A (B C) (B D) E)";
    assertEquals(expecting, found);
  }
View Full Code Here

Examples of org.antlr.runtime.tree.TreeWizard

    String expecting = "(A (B C) (B D) E)";
    assertEquals(expecting, found);
  }

  @Test public void testSingleNodeIndex() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t = (CommonTree)wiz.create("ID");
    Map m = wiz.index(t);
    String found = m.toString();
    String expecting = "{10=[ID]}";
    assertEquals(expecting, found);
  }
View Full Code Here

Examples of org.antlr.runtime.tree.TreeWizard

    String expecting = "{10=[ID]}";
    assertEquals(expecting, found);
  }

  @Test public void testNoRepeatsIndex() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t = (CommonTree)wiz.create("(A B C D)");
    Map m = wiz.index(t);
    String found = sortMapToString(m);
        String expecting = "{5=[A], 6=[B], 7=[C], 8=[D]}";
    assertEquals(expecting, found);
  }
View Full Code Here

Examples of org.antlr.runtime.tree.TreeWizard

        String expecting = "{5=[A], 6=[B], 7=[C], 8=[D]}";
    assertEquals(expecting, found);
  }

  @Test public void testRepeatsIndex() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t = (CommonTree)wiz.create("(A B (A C B) B D D)");
    Map m = wiz.index(t);
    String found =  sortMapToString(m);
        String expecting = "{5=[A, A], 6=[B, B, B], 7=[C], 8=[D, D]}";
    assertEquals(expecting, found);
  }
View Full Code Here

Examples of org.antlr.runtime.tree.TreeWizard

        String expecting = "{5=[A, A], 6=[B, B, B], 7=[C], 8=[D, D]}";
    assertEquals(expecting, found);
  }

  @Test public void testNoRepeatsVisit() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t = (CommonTree)wiz.create("(A B C D)");
    final List elements = new ArrayList();
    wiz.visit(t, wiz.getTokenType("B"), new TreeWizard.Visitor() {
      public void visit(Object t) {
        elements.add(t);
      }
    });
    String found = elements.toString();
View Full Code Here

Examples of org.antlr.runtime.tree.TreeWizard

    String expecting = "[B]";
    assertEquals(expecting, found);
  }

  @Test public void testNoRepeatsVisit2() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t = (CommonTree)wiz.create("(A B (A C B) B D D)");
    final List elements = new ArrayList();
    wiz.visit(t, wiz.getTokenType("C"),
             new TreeWizard.Visitor() {
              public void visit(Object t) {
                elements.add(t);
              }
             });
View Full Code Here

Examples of org.antlr.runtime.tree.TreeWizard

    String expecting = "[C]";
    assertEquals(expecting, found);
  }

  @Test public void testRepeatsVisit() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t = (CommonTree)wiz.create("(A B (A C B) B D D)");
    final List elements = new ArrayList();
    wiz.visit(t, wiz.getTokenType("B"),
             new TreeWizard.Visitor() {
              public void visit(Object t) {
                elements.add(t);
              }
             });
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.