Package org.antlr.runtime.tree

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


        }
       
        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


      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

                    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

        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

                    Method[] methods = _return.getDeclaredMethods();
                    for(Method method : methods) {
                        if ( method.getName().equals("getTree") ) {
                            Method returnName = _return.getMethod("getTree");
                            CommonTree tree = (CommonTree) returnName.invoke(ruleReturn);
                            result = tree.toStringTree();
                        }
                        else if ( method.getName().equals("getTemplate") ) {
                            Method returnName = _return.getMethod("getTemplate");
                            StringTemplate st = (StringTemplate) returnName.invoke(ruleReturn);
                            result = st.toString();
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

     * .child( tuple(var("deco", kind("SINK")), var("child", wild())));
     */
    PatternMatch psink = tuple(kind("SINK"), var("name", wild()), var("sink",
        kind("STRING")));
    PatternMatch pp = or(psink, pdeco);
    LOG.info(sink.toStringTree());

    Map<String, CommonTree> m = pp.match(sink);
    assertNotNull(m);
    assertTrue(m.containsKey("deco"));
    dumpMatches(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.