Package org.antlr.runtime.tree

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


  }

  @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

  }

  @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

    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

                    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

                    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

      CommonTree tree = (CommonTree) result.getTree();
      errors = parser.getNumberOfSyntaxErrors();

      if (errors == 0){
        if (PRINT_TREE)
          System.out.println("Tree==>"+tree.toStringTree());
        CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
        nodes.setTokenStream(tokens);
        walker = new ForteAST(nodes);
        walker.statement();
      }
View Full Code Here

    parser.setErrorReporter(reporter);
//    parser.setTokenStream(tokens);
    statement_return result = parser.statement();
    CommonTree tree = (CommonTree) result.getTree();
    if (PRINT_TREE)
        System.out.println("Tree==>"+tree.toStringTree());
//      printTree(tree, 0);
    errors = parser.getNumberOfSyntaxErrors();

    if (errors == 0){
      CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
View Full Code Here

      CommonTree tree = (CommonTree) result.getTree();
      errors = parser.getNumberOfSyntaxErrors();

      if (errors == 0){
        if (PRINT_TREE)
          System.out.println("Tree==>"+tree.toStringTree());
        CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
        nodes.setTokenStream(tokens);
        walker = new ForteAST(nodes);
        walker.expression();
      }
View Full Code Here

      CommonTree tree = (CommonTree) result.getTree();
      errors = parser.getNumberOfSyntaxErrors();

      if (errors == 0){
        if (PRINT_TREE)
          System.out.println("Tree==>"+tree.toStringTree());
        CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
        nodes.setTokenStream(tokens);
        walker = new ForteAST(nodes);
        walker.qualifiedName();
      }
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.