Package org.antlr.runtime.tree

Examples of org.antlr.runtime.tree.TreeWizard.create()


    assertEquals("C", labels.get("c").toString());
  }

  @Test public void testParseLabelsInNestedTree() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t = (CommonTree)wiz.create("(A (B C) (D E))");
    Map<String, Object> labels = new HashMap<String, Object>();
    boolean valid = wiz.parse(t, "(%a:A (%b:B %c:C) (%d:D %e:E) )", labels);
    assertTrue(valid);
    assertEquals("A", labels.get("a").toString());
    assertEquals("B", labels.get("b").toString());
View Full Code Here


    assertEquals("E", labels.get("e").toString());
  }

  @Test public void testEquals() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t1 = (CommonTree)wiz.create("(A B C)");
    CommonTree t2 = (CommonTree)wiz.create("(A B C)");
    boolean same = TreeWizard.equals(t1, t2, adaptor);
    assertTrue(same);
  }
View Full Code Here

  }

  @Test public void testEquals() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t1 = (CommonTree)wiz.create("(A B C)");
    CommonTree t2 = (CommonTree)wiz.create("(A B C)");
    boolean same = TreeWizard.equals(t1, t2, adaptor);
    assertTrue(same);
  }

  @Test public void testEqualsWithText() throws Exception {
View Full Code Here

    assertTrue(same);
  }

  @Test public void testEqualsWithText() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t1 = (CommonTree)wiz.create("(A B[foo] C)");
    CommonTree t2 = (CommonTree)wiz.create("(A B[foo] C)");
    boolean same = TreeWizard.equals(t1, t2, adaptor);
    assertTrue(same);
  }
 
View Full Code Here

  }

  @Test public void testEqualsWithText() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t1 = (CommonTree)wiz.create("(A B[foo] C)");
    CommonTree t2 = (CommonTree)wiz.create("(A B[foo] C)");
    boolean same = TreeWizard.equals(t1, t2, adaptor);
    assertTrue(same);
  }
 
  @Test public void testEqualsWithMismatchedText() throws Exception {
View Full Code Here

    assertTrue(same);
  }
 
  @Test public void testEqualsWithMismatchedText() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t1 = (CommonTree)wiz.create("(A B[foo] C)");
    CommonTree t2 = (CommonTree)wiz.create("(A B C)");
    boolean same = TreeWizard.equals(t1, t2, adaptor);
    assertTrue(!same);
  }
View Full Code Here

  }
 
  @Test public void testEqualsWithMismatchedText() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t1 = (CommonTree)wiz.create("(A B[foo] C)");
    CommonTree t2 = (CommonTree)wiz.create("(A B C)");
    boolean same = TreeWizard.equals(t1, t2, adaptor);
    assertTrue(!same);
  }

  @Test public void testFindPattern() throws Exception {
View Full Code Here

    assertTrue(!same);
  }

  @Test public void testFindPattern() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t = (CommonTree)wiz.create("(A B C (A[foo] B[bar]) (D (A[big] B[dog])))");
    final List<? extends Object> subtrees = wiz.find(t, "(A B)");
    List<? extends Object> elements = subtrees;
    String found = elements.toString();
    String expecting = "[foo, big]";
    assertEquals(expecting, found);
View Full Code Here

    new String[] {"", "", "", "", "", "A", "B", "C", "D", "E", "ID", "VAR"};
  protected static final TreeAdaptor adaptor = new CommonTreeAdaptor();

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

    assertEquals(expecting, found);
  }

  @Test public void testSingleNodeWithArg() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t = (CommonTree)wiz.create("ID[foo]");
    String found = t.toStringTree();
    String expecting = "foo";
    assertEquals(expecting, found);
  }
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.