Package org.antlr.runtime.tree

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


    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

    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);
  }

  @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

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.