Package org.antlr.runtime.tree

Examples of org.antlr.runtime.tree.CommonTreeNodeStream


    //System.out.println("### build "+getGrammarTypeString()+" grammar "+name+" NFAs");
    if ( getRules().size()==0 ) {
      return;
    }

    CommonTreeNodeStream input = new CommonTreeNodeStream(getGrammarTree());
    TreeToNFAConverter nfaBuilder = new TreeToNFAConverter(input, this, nfa, factory);
    try {
      nfaBuilder.grammar_();
    }
    catch (RecognitionException re) {
View Full Code Here


  public String grammarTreeToString(GrammarAST t, boolean showActions) {
    String s = null;
    try {
      s = t.getLine()+":"+(t.getCharPositionInLine()+1)+": ";
      s += new ANTLRTreePrinter(new CommonTreeNodeStream(t)).toString(this, showActions);
    }
    catch (Exception e) {
      s = "<invalid or missing tree structure>";
    }
    return s;
View Full Code Here

    }
    return s;
  }

  public void printGrammar(PrintStream output) {
    ANTLRTreePrinter printer = new ANTLRTreePrinter(new CommonTreeNodeStream(getGrammarTree()));
    try {
      String g = printer.toString(this, false);
      output.println(g);
    }
    catch (RecognitionException re) {
View Full Code Here

            Class _return = classForName(parserName+"$"+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 = classForName(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 String text(GrammarAST t) {
    if ( t==null ) return null;
    try {
      return new ANTLRTreePrinter(new CommonTreeNodeStream(t)).toString(grammar, true);
    }
    catch (Exception e) {
      ErrorManager.error(ErrorManager.MSG_BAD_AST_STRUCTURE, e);
    }
    return null;
View Full Code Here

    if (failOnError && errors > 0Assert.fail() ;
    return errors;
  }
 
  private int parseForteASTComponent(CommonTree tree, TokenStream tokens) throws RecognitionException{
    CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
    nodes.setTokenStream(tokens);
    ForteAST walker = new ForteAST(nodes);
    walker.component_definition();
    return walker.getNumberOfSyntaxErrors();

  }
View Full Code Here

    return walker.getNumberOfSyntaxErrors();

  }
  private int parseUsingCDFTree(CommonTree tree, TokenStream tokens, String name) throws RecognitionException{
    ToolClass cls = new ToolClass(name);
    CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
    nodes.setTokenStream(tokens);
    ForteCDFTree walker = new ForteCDFTree(cls, nodes);
    walker.classDeclaration();
    return walker.getNumberOfSyntaxErrors();

  }
View Full Code Here

   
  }

  private ToolPlan parseUsingPRXTree(CommonTree tree, TokenStream tokens, String name) throws RecognitionException{
    ToolPlan plan = new ToolPlan(name);
    CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
    nodes.setTokenStream(tokens);
    FortePRXTree walker = new FortePRXTree(plan, nodes);
    walker.project();
    int errors = walker.getNumberOfSyntaxErrors();
    System.out.println(name + " completed with " + errors + " tree errors");
    if (errors > 0){
View Full Code Here

    if (failOnError && errors > 0Assert.fail() ;
    return errors;
  }
  private int parseUsingSOTree(CommonTree tree, TokenStream tokens, String name) throws RecognitionException{
    ToolServiceObject so = new ToolServiceObject(name);
    CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
    nodes.setTokenStream(tokens);
    ForteSOTree walker = new ForteSOTree(so, nodes);
    walker.serviceFile();
    int errors = walker.getNumberOfSyntaxErrors();
    System.out.println("\t" + name + " completed with " + errors + " tree errors");
    if (errors > 0){
View Full Code Here

    if (failOnError && errors > 0Assert.fail() ;
    return errors;
  }
  private int parseUsingSOTree(CommonTree tree, TokenStream tokens, String name) throws RecognitionException{
    ToolServiceObject so = new ToolServiceObject(name);
    CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
    nodes.setTokenStream(tokens);
    ForteSOTree walker = new ForteSOTree(so, nodes);
    walker.serviceFile();
    int errors = walker.getNumberOfSyntaxErrors();
    System.out.println("\t" + name + " completed with " + errors + " tree errors");
    if (errors > 0){
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.