Package org.antlr.runtime.tree

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


        ANTLRv3Lexer lex = new ANTLRv3Lexer(input);
        tokens = new TokenRewriteStream(lex);
        ANTLRv3Parser g = new ANTLRv3Parser(tokens);
        ANTLRv3Parser.grammarDef_return r = g.grammarDef();
        CommonTree t = (CommonTree)r.getTree();
        if (tree_option) System.out.println(t.toStringTree());
        rewrite(g.getTreeAdaptor(),t,g.getTokenNames());
    }

    public void rewrite(TreeAdaptor adaptor, CommonTree t, String[] tokenNames) throws Exception {
        TreeWizard wiz = new TreeWizard(adaptor, tokenNames);
View Full Code Here


      printTree(t, 0);
     
      //ASTFrame af = new ASTFrame("Tree", t);
      //af.setVisible(true);
     
      System.out.println(t.toStringTree());
     
      /*
      DOTTreeGenerator gen = new DOTTreeGenerator();
      StringTemplate st = gen.toDOT(t);
      System.out.println(st);
View Full Code Here

      final boolean debugEnabled = log.isDebugEnabled();
      for ( AstProcessor processor : processingChain ) {
        tree = processor.process( tokens, tree );

        if ( debugEnabled ) {
          log.debug( "Processed tree: " + tree.toStringTree() );
        }
      }

      return processingChain.getResult();
    }
View Full Code Here

            throw new ParserException(msg2);
        }

        CommonTree ast = (CommonTree)result.getTree();
       
        LOG.debug("AST for macro '" + name + "':\n" + ast.toStringTree());
           
        List<CommonTree> macroDefNodes = new ArrayList<CommonTree>();
        traverseMacro(ast, macroDefNodes, "MACRO_DEF");
        if (!macroDefNodes.isEmpty()) {
            String fname = ((PigParserNode)ast).getFileName();
View Full Code Here

        }
       
        commonTree = result2.tree;

        LOG.debug("AST for masked macro '" + name + "':\n"
                + commonTree.toStringTree());
        return commonTree;
    }
   
    private static void setInvocationStack(Tree ast, List<InvocationPoint> stack) {       
View Full Code Here

            throw new ParserException(msg2);
        }

        CommonTree ast = (CommonTree)result.getTree();
       
        LOG.debug("AST for macro '" + name + "':\n" + ast.toStringTree());
           
        List<CommonTree> macroDefNodes = new ArrayList<CommonTree>();
        traverseMacro(ast, macroDefNodes, "MACRO_DEF");
        if (!macroDefNodes.isEmpty()) {
            String fname = ((PigParserNode)ast).getFileName();
View Full Code Here

        }
       
        commonTree = result2.tree;

        LOG.debug("AST for masked macro '" + name + "':\n"
                + commonTree.toStringTree());
        return commonTree;
    }
   
    private static void setInvocationStack(Tree ast, List<InvocationPoint> stack) {       
View Full Code Here

   * representation.
   **/
  CommonTree substLogicalSink(String sink) throws RecognitionException,
      FlumeSpecException {
    CommonTree lsnkTree = FlumeBuilder.parseSink(sink);
    LOG.debug(lsnkTree.toStringTree());
    PatternMatch p = recursive(var("lsnk", kind("DECO").child(
        kind("SINK").child(kind("logicalSink")))));
    Map<String, CommonTree> matches = p.match(lsnkTree);

    if (matches == null) {
View Full Code Here

   * substitutes in a physical source.
   */
  CommonTree substLogicalSource(String ln, String source)
      throws RecognitionException {
    CommonTree lsrcTree = FlumeBuilder.parseSource(source);
    LOG.debug(lsrcTree.toStringTree());
    PatternMatch p = FlumePatterns.source("logicalSource");
    Map<String, CommonTree> matches = p.match(lsrcTree);

    if (matches == null) {
      // if was previously a logical source, unregister it.
View Full Code Here

  @Test
  public void testRecursive() throws RecognitionException {
    CommonTree sink = FlumeBuilder
        .parseSink("roll (200) { < null ? [ console, { test => { test2 =>  { batch(10) => logicalNode(\"collector\")  } } } ] > }");
    LOG.info(sink.toStringTree());

    PatternMatch pp = recursive(var("batchsize", kind("DEC")));
    //
    Map<String, CommonTree> m = pp.match(sink);
    assertNotNull(m);
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.