Package org.antlr.runtime.tree

Examples of org.antlr.runtime.tree.CommonTree


    assertEquals(expecting, found);
  }

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


    assertEquals(expecting, found);
  }

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

    assertEquals(expecting, found);
  }

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

    assertEquals(expecting, found);
  }

  @Test public void testVisitPatternMultiple() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t = (CommonTree)wiz.create("(A B C (A B) (D (A B)))");
    final List<String> elements = new ArrayList<String>();
    wiz.visit(t, "(A B)",
             new TreeWizard.ContextVisitor() {
               @Override
               public void visit(Object t, Object parent, int childIndex, Map<String, Object> labels) {
View Full Code Here

    assertEquals(expecting, found);
  }

  @Test public void testVisitPatternMultipleWithLabels() 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<String> elements = new ArrayList<String>();
    wiz.visit(t, "(%a:A %b:B)",
             new TreeWizard.ContextVisitor() {
               @Override
               public void visit(Object t, Object parent, int childIndex, Map<String, Object> labels) {
View Full Code Here

    assertEquals(expecting, found);
  }

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

    assertTrue(valid);
  }

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

    assertTrue(valid);
  }

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

    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

    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

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.