Package org.antlr.runtime.tree

Examples of org.antlr.runtime.tree.CommonTreeNodeStream


    }
  }

  private PackageDescr walk(TokenStream tokenStream, Tree resultTree)
      throws RecognitionException {
    CommonTreeNodeStream nodes = new CommonTreeNodeStream(resultTree);
    // AST nodes have payload that point into token stream
    nodes.setTokenStream(tokenStream);
    // Create a tree walker attached to the nodes stream
    walker = new DescrBuilderTree(nodes);
    walker.compilation_unit();
    return walker.getPackageDescr();
  }
View Full Code Here


        }
    }

    private PackageDescr walk(TokenStream tokenStream,
                              Tree resultTree) throws RecognitionException {
        CommonTreeNodeStream nodes = new CommonTreeNodeStream( resultTree );
        // AST nodes have payload that point into token stream
        nodes.setTokenStream( tokenStream );
        // Create a tree walker attached to the nodes stream
        walker = new DescrBuilderTree( nodes );
        walker.compilation_unit();
        return walker.getPackageDescr();
    }
View Full Code Here

                Class _return = Class.forName( "org.drools.lang.DRLParser" + "$" + testRuleName + "_return" );
                Method returnName = _return.getMethod( "getTree" );
                DroolsTree tree = (DroolsTree) returnName.invoke( ruleReturn );

                // Walk resulting tree; create tree nodes stream first
                CommonTreeNodeStream nodes = new CommonTreeNodeStream( tree );
                // AST nodes have payload that point into token stream
                nodes.setTokenStream( tokens );
                // Create a tree walker attached to the nodes stream
                this.walker = new DescrBuilderTree( nodes );
                /** Invoke the tree rule, and store the return value if there is */
                Method treeRuleName = Class.forName( "org.drools.lang.DescrBuilderTree" ).getMethod( testTreeRuleName );
                treeRuleReturn = treeRuleName.invoke( walker );
View Full Code Here

      if (parser.getNumberOfSyntaxErrors() > 0){
        ToolPlugin.showError(parser.getNumberOfSyntaxErrors() + " Syntax error in project " + getFile().getName() + "\n"
            + this.parseErrors.toString(), null);
      } else {
        tree = (CommonTree) result.getTree();
        CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
        nodes.setTokenStream(tokens);
        ForteSOTree walker = new ForteSOTree(this, nodes);
        walker.serviceDeclaration();
      }
    } catch (RecognitionException e) {
      ToolPlugin.showError("Cannot parse service "  + getFile().getName(), e);
View Full Code Here

        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();
      }
    } catch (RecognitionException e) {
View Full Code Here

      if (parser.getNumberOfSyntaxErrors() > 0){
        ToolPlugin.showError(parser.getNumberOfSyntaxErrors() + " Syntax error in project " + getFile().getName() + "\n"
            + this.parseErrors.toString(), null);
      } else {
        tree = (CommonTree) result.getTree();
        CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
        nodes.setTokenStream(tokens);
        FortePRXTree walker = new FortePRXTree(this, nodes);
        walker.project();
      }
    } catch (RecognitionException e) {
      ToolPlugin.showError("Cannot parse project "  + getFile().getName(), e);
View Full Code Here

//    return walker.getNumberOfSyntaxErrors();
//
//  }

  private int createPRXTree(CommonTree tree, TokenStream tokens, File cdf) throws RecognitionException{
    CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
    nodes.setTokenStream(tokens);
    FortePRXTree walker = new FortePRXTree(nodes);
    walker.project();
   
    return walker.getNumberOfSyntaxErrors();
View Full Code Here

            Class _return = Class.forName(parserPath+"$"+testRuleName+"_return");             
          Method returnName = _return.getMethod("getTree");
          CommonTree tree = (CommonTree) returnName.invoke(ruleReturn);

          // Walk resulting tree; create tree nodes stream first
          CommonTreeNodeStream nodes;
          if ( customTreeAdaptor!=null ) {
            nodes = new CommonTreeNodeStream(customTreeAdaptor, tree);
          }
          else {
            nodes = new CommonTreeNodeStream(tree);
          }
          // AST nodes have payload that point into token stream
          nodes.setTokenStream(tokens);
          // Create a tree walker attached to the nodes stream
          treeParser = Class.forName(treeParserPath);
            Class[] treeParArgTypes = new Class[]{TreeNodeStream.class};    // assign type to tree parser's args
            Constructor treeParConstructor = treeParser.getConstructor(treeParArgTypes);
            Object[] treeParArgs = new Object[]{nodes};              // assign value to tree parser's args 
View Full Code Here

        }
    }

  public void translateLeftRecursiveRule(GrammarAST ruleAST) {
    //System.out.println(ruleAST.toStringTree());
    CommonTreeNodeStream input = new CommonTreeNodeStream(ruleAST);
    LeftRecursiveRuleAnalyzer leftRecursiveRuleWalker =
      new LeftRecursiveRuleAnalyzer(input, this, ruleAST.enclosingRuleName);
    boolean isLeftRec = false;
    try {
      //System.out.println("TESTING "+ruleAST.enclosingRuleName);
View Full Code Here

      System.out.println(grammarTree.toStringList());
    }

    // DEFINE RULES
    //System.out.println("### define "+name+" rules");
    DefineGrammarItemsWalker defineItemsWalker = new DefineGrammarItemsWalker(new CommonTreeNodeStream(getGrammarTree()));
    try {
      defineItemsWalker.grammar_(this);
    }
    catch (RecognitionException re) {
      ErrorManager.error(ErrorManager.MSG_BAD_AST_STRUCTURE,
View Full Code Here

TOP

Related Classes of org.antlr.runtime.tree.CommonTreeNodeStream

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.