Examples of TreeWizard


Examples of org.antlr.runtime.tree.TreeWizard

    boolean valid = wiz.parse(t, "(nil A B C)");
    assertTrue(valid);
  }

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

Examples of org.antlr.runtime.tree.TreeWizard

    boolean valid = wiz.parse(t, "(A . .)");
    assertTrue(valid);
  }

  @Test public void testParseWithText() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t = (CommonTree)wiz.create("(A B[foo] C[bar])");
    // C pattern has no text arg so despite [bar] in t, no need
    // to match text--check structure only.
    boolean valid = wiz.parse(t, "(A B[foo] C)");
    assertTrue(valid);
  }
View Full Code Here

Examples of org.antlr.runtime.tree.TreeWizard

    boolean valid = wiz.parse(t, "(A B[foo] C)");
    assertTrue(valid);
  }

  @Test public void testParseWithText2() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t = (CommonTree)wiz.create("(A B[T__32] (C (D E[a])))");
    // C pattern has no text arg so despite [bar] in t, no need
    // to match text--check structure only.
    boolean valid = wiz.parse(t, "(A B[foo] C)");
    assertEquals("(A T__32 (C (D a)))", t.toStringTree());
  }
View Full Code Here

Examples of org.antlr.runtime.tree.TreeWizard

    boolean valid = wiz.parse(t, "(A B[foo] C)");
    assertEquals("(A T__32 (C (D a)))", t.toStringTree());
  }

  @Test public void testParseWithTextFails() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t = (CommonTree)wiz.create("(A B C)");
    boolean valid = wiz.parse(t, "(A[foo] B C)");
    assertTrue(!valid); // fails
  }
View Full Code Here

Examples of org.antlr.runtime.tree.TreeWizard

    boolean valid = wiz.parse(t, "(A[foo] B C)");
    assertTrue(!valid); // fails
  }

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

Examples of org.antlr.runtime.tree.TreeWizard

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

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

Examples of org.antlr.runtime.tree.TreeWizard

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

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

Examples of org.antlr.runtime.tree.TreeWizard

  protected static final String[] tokens =
    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

Examples of org.antlr.runtime.tree.TreeWizard

    String expecting = "ID";
    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

Examples of org.antlr.runtime.tree.TreeWizard

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

  @Test public void testSingleNodeTree() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t = (CommonTree)wiz.create("(A)");
    String found = t.toStringTree();
    String expecting = "A";
    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.