Examples of toStringTree()


Examples of org.antlr.runtime.tree.CommonTree.toStringTree()

      if (parser.getNumberOfSyntaxErrors() > 0){
        ToolPlugin.showError(parser.getNumberOfSyntaxErrors() + " Syntax error in cursor " + getFile().getName() + "\n"
            + this.parseErrors.toString(), null);
      } else {
        CommonTree tree = (CommonTree) result.getTree();
        System.out.println(tree.toStringTree());
        CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
        nodes.setTokenStream(tokens);
        // TODO write a tree walker
        //      FortePRXTree walker = new FortePRXTree(this, nodes);
        //      walker.project();
View Full Code Here

Examples of org.antlr.runtime.tree.CommonTree.toStringTree()

                    Method[] methods = _return.getDeclaredMethods();
                    for(Method method : methods) {
                      if ( method.getName().equals("getTree") ) {
                        Method returnName = _return.getMethod("getTree");
                          CommonTree tree = (CommonTree) returnName.invoke(ruleReturn);
                          astString = tree.toStringTree();
                      }
                      else if ( method.getName().equals("getTemplate") ) {
                        Method returnName = _return.getMethod("getTemplate");
                        StringTemplate st = (StringTemplate) returnName.invoke(ruleReturn);
                        stString = st.toString();
View Full Code Here

Examples of org.antlr.runtime.tree.CommonTree.toStringTree()

                    Method[] methods = _treeReturn.getDeclaredMethods();
                  for(Method method : methods) {
                      if ( method.getName().equals("getTree") ) {
                        Method treeReturnName = _treeReturn.getMethod("getTree");
                          CommonTree returnTree = (CommonTree) treeReturnName.invoke(treeRuleReturn);
                            astString = returnTree.toStringTree();
                      }
                      else if ( method.getName().equals("getTemplate") ) {
                        Method treeReturnName = _return.getMethod("getTemplate");
                        StringTemplate st = (StringTemplate) treeReturnName.invoke(treeRuleReturn);
                        stString = st.toString();
View Full Code Here

Examples of org.antlr.runtime.tree.CommonTree.toStringTree()

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

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

Examples of org.antlr.runtime.tree.CommonTree.toStringTree()

  }

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

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

Examples of org.antlr.runtime.tree.CommonTree.toStringTree()

  }

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

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

Examples of org.antlr.runtime.tree.CommonTree.toStringTree()

  }

  @Test public void testSingleLevelTree() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t = (CommonTree)wiz.create("(A B C D)");
    String found = t.toStringTree();
    String expecting = "(A B C D)";
    assertEquals(expecting, found);
  }

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

Examples of org.antlr.runtime.tree.CommonTree.toStringTree()

  }

  @Test public void testListTree() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t = (CommonTree)wiz.create("(nil A B C)");
    String found = t.toStringTree();
    String expecting = "A B C";
    assertEquals(expecting, found);
  }

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

Examples of org.antlr.runtime.tree.CommonTree.toStringTree()

  }

  @Test public void testDoubleLevelTree() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t = (CommonTree)wiz.create("(A (B C) (B D) E)");
    String found = t.toStringTree();
    String expecting = "(A (B C) (B D) E)";
    assertEquals(expecting, found);
  }

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

Examples of org.antlr.runtime.tree.CommonTree.toStringTree()

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

  @Test public void testParseWithTextFails() throws Exception {
    TreeWizard wiz = new TreeWizard(adaptor, tokens);
    CommonTree t = (CommonTree)wiz.create("(A B C)");
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.