Package org.antlr.v4.tool.ast

Examples of org.antlr.v4.tool.ast.GrammarRootAST.toStringTree()


      try {
        Method startRule = parserClass.getMethod(startRuleName);
        ParserRuleContext tree = (ParserRuleContext)startRule.invoke(parser, (Object[])null);

        if ( printTree ) {
          System.out.println(tree.toStringTree(parser));
        }
        if ( gui ) {
          tree.inspect(parser);
        }
        if ( psFile!=null ) {
View Full Code Here


      // start parsing at the compilationUnit rule
      ParserRuleContext t = parser.compilationUnit();
      if ( notree ) parser.setBuildParseTree(false);
      if ( gui ) t.inspect(parser);
      if ( printTree ) System.out.println(t.toStringTree(parser));
    }
    catch (Exception e) {
      System.err.println("parser exception: "+e);
      e.printStackTrace();   // so we can get stack trace
    }
View Full Code Here

      // start parsing at the compilationUnit rule
      ParserRuleContext t = parser.compilationUnit();
      if ( notree ) parser.setBuildParseTree(false);
      if ( gui ) t.inspect(parser);
      if ( printTree ) System.out.println(t.toStringTree(parser));
    }
    catch (Exception e) {
      System.err.println("parser exception: "+e);
      e.printStackTrace();   // so we can get stack trace
    }
View Full Code Here

  {
    LexerInterpreter lexEngine = lg.createLexerInterpreter(new ANTLRInputStream(input));
    CommonTokenStream tokens = new CommonTokenStream(lexEngine);
    ParserInterpreter parser = g.createParserInterpreter(tokens);
    ParseTree t = parser.parse(g.rules.get(startRule).index);
    System.out.println("parse tree: "+t.toStringTree(parser));
    assertEquals(parseTree, t.toStringTree(parser));
  }
}
View Full Code Here

    LexerInterpreter lexEngine = lg.createLexerInterpreter(new ANTLRInputStream(input));
    CommonTokenStream tokens = new CommonTokenStream(lexEngine);
    ParserInterpreter parser = g.createParserInterpreter(tokens);
    ParseTree t = parser.parse(g.rules.get(startRule).index);
    System.out.println("parse tree: "+t.toStringTree(parser));
    assertEquals(parseTree, t.toStringTree(parser));
  }
}
View Full Code Here

  }

  public void process() {
    GrammarRootAST root = g.ast;
    if ( root==null ) return;
        tool.log("grammar", "before: "+root.toStringTree());

        integrateImportedGrammars(g);
    reduceBlocksToSets(root);
        expandParameterizedLoops(root);
View Full Code Here

        integrateImportedGrammars(g);
    reduceBlocksToSets(root);
        expandParameterizedLoops(root);

        tool.log("grammar", "after: "+root.toStringTree());
  }

  public void reduceBlocksToSets(GrammarAST root) {
    CommonTreeNodeStream nodes = new CommonTreeNodeStream(new GrammarASTAdaptor(), root);
    GrammarASTAdaptor adaptor = new GrammarASTAdaptor();
View Full Code Here

    lexerAST.sanityCheckParentAndChildIndexes();
    combinedAST.sanityCheckParentAndChildIndexes();
//    tool.log("grammar", combinedAST.toTokenString());

        combinedGrammar.tool.log("grammar", "after extract implicit lexer ="+combinedAST.toStringTree());
        combinedGrammar.tool.log("grammar", "lexer ="+lexerAST.toStringTree());

    if ( lexerRulesRoot.getChildCount()==0 return null;
    return lexerAST;
  }
View Full Code Here

      r.alt[1].labelDefs.map(labelNode.getText(), lp);
    }
    // copy to rule from walker
    r.leftRecursiveRuleRefLabels = leftRecursiveRuleWalker.leftRecursiveRuleRefLabels;

    tool.log("grammar", "added: "+t.toStringTree());
    return true;
  }

  public RuleAST parseArtificialRule(final Grammar g, String ruleText) {
    ANTLRLexer lexer = new ANTLRLexer(new ANTLRStringStream(ruleText));
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.