Package org.antlr.runtime.tree

Examples of org.antlr.runtime.tree.CommonTree


    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


    assertEquals(expecting, found);
  }

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

    assertNull(t);
  }

  @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

    assertEquals(expecting, found);
  }

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

    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<Integer, List<Object>> 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

    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<Integer, List<Object>> 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

    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<Object> elements = new ArrayList<Object>();
    wiz.visit(t, wiz.getTokenType("B"), new TreeWizard.Visitor() {
      @Override
      public void visit(Object t) {
        elements.add(t);
View Full Code Here

    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<Object> elements = new ArrayList<Object>();
    wiz.visit(t, wiz.getTokenType("C"),
             new TreeWizard.Visitor() {
              @Override
              public void visit(Object t) {
View Full Code Here

    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<Object> elements = new ArrayList<Object>();
    wiz.visit(t, wiz.getTokenType("B"),
             new TreeWizard.Visitor() {
              @Override
              public void visit(Object t) {
View Full Code Here

    assertEquals(expecting, found);
  }

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

TOP

Related Classes of org.antlr.runtime.tree.CommonTree

Copyright © 2018 www.massapicom. 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.