Package org.antlr.runtime.tree

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


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


    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 elements = new ArrayList();
    wiz.visit(t, wiz.getTokenType("B"),
       new TreeWizard.ContextVisitor() {
         public void visit(Object t, Object parent, int childIndex, Map labels) {
           elements.add(adaptor.getText(t)+"@"+
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 elements = new ArrayList();
    wiz.visit(t, wiz.getTokenType("A"),
       new TreeWizard.ContextVisitor() {
         public void visit(Object t, Object parent, int childIndex, Map labels) {
           elements.add(adaptor.getText(t)+"@"+
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 elements = new ArrayList();
    wiz.visit(t, "(A B)",
             new TreeWizard.Visitor() {
              public void visit(Object t) {
                elements.add(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 elements = new ArrayList();
    wiz.visit(t, "(A B)",
             new TreeWizard.ContextVisitor() {
               public void visit(Object t, Object parent, int childIndex, Map labels) {
                 elements.add(adaptor.getText(t)+"@"+
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 elements = new ArrayList();
    wiz.visit(t, "(%a:A %b:B)",
             new TreeWizard.ContextVisitor() {
               public void visit(Object t, Object parent, int childIndex, Map labels) {
                 elements.add(adaptor.getText(t)+"@"+
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);
  }

  @Test public void testParseSingleNode() throws Exception {
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);
  }

  @Test public void testParseFlatTree() throws Exception {
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);
  }

  @Test public void testWildcard() throws Exception {
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);
  }

  @Test public void testParseWithText() throws Exception {
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.