当前位置: 首页>>代码示例>>Java>>正文


Java Tree.getChildCount方法代码示例

本文整理汇总了Java中org.antlr.v4.runtime.tree.Tree.getChildCount方法的典型用法代码示例。如果您正苦于以下问题:Java Tree.getChildCount方法的具体用法?Java Tree.getChildCount怎么用?Java Tree.getChildCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.antlr.v4.runtime.tree.Tree的用法示例。


在下文中一共展示了Tree.getChildCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toStringTree

import org.antlr.v4.runtime.tree.Tree; //导入方法依赖的package包/类
/** Print out a whole tree in LISP form. Arg nodeTextProvider is used on the
 *  node payloads to get the text for the nodes.
 *
 *  @since 4.5.1
 */
public static String toStringTree(Tree t, TreeTextProvider nodeTextProvider) {
	if ( t==null ) return "null";
	String s = Utils.escapeWhitespace(nodeTextProvider.getText(t), false);
	if ( t.getChildCount()==0 ) return s;
	StringBuilder buf = new StringBuilder();
	buf.append("(");
	s = Utils.escapeWhitespace(nodeTextProvider.getText(t), false);
	buf.append(s);
	buf.append(' ');
	for (int i = 0; i<t.getChildCount(); i++) {
		if ( i>0 ) buf.append(' ');
		buf.append(toStringTree(t.getChild(i), nodeTextProvider));
	}
	buf.append(")");
	return buf.toString();
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:22,代码来源:Trees.java

示例2: toStringTree

import org.antlr.v4.runtime.tree.Tree; //导入方法依赖的package包/类
private String toStringTree(Tree tree, List<String> ruleNames) {
    String s = Utils.escapeWhitespace(getNodeText(tree, ruleNames), false);
    if(tree.getChildCount() == 0) return s;
    
    StringBuilder buf = new StringBuilder();
    buf.append("(");
    s = Utils.escapeWhitespace(getNodeText(tree, ruleNames), false);
    buf.append(s);
    buf.append(' ');
    for(int i = 0; i < tree.getChildCount(); i++)
    {
        if(i > 0)
            buf.append(' ');
        buf.append(toStringTree(tree.getChild(i), ruleNames));
    }

    buf.append(")");
    return buf.toString();
}
 
开发者ID:processquerying,项目名称:PQL,代码行数:20,代码来源:AbstractPQLQuery.java

示例3: dumpAST

import org.antlr.v4.runtime.tree.Tree; //导入方法依赖的package包/类
public static void dumpAST(PrintWriter printer, Tree ast, int ident) {
    char[] identChars = new char[ident];
    Arrays.fill(identChars, ' ');

    if (ast == null) {
        renderNode(identChars, null, printer);
        return;
    }
    for (int i = 0; i < ast.getChildCount(); i++) {
        Tree node = ast.getChild(i);
        if (node == null) {
            throw new NullPointerException("Null AST node");
        }
        renderNode(identChars, node, printer);
        dumpAST(printer, node, ident + 2);
    }
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:18,代码来源:ASTUtil.java

示例4: toStringTree

import org.antlr.v4.runtime.tree.Tree; //导入方法依赖的package包/类
private String toStringTree(@NotNull final Tree t, @Nullable final List<String> ruleNames) {
  if (t.getChildCount() == 0) {
    return Utils.escapeWhitespace(getNodeText(t, ruleNames), true);
  }
  StringBuilder buf = new StringBuilder();
  buf.append(" ( ");
  String s = Utils.escapeWhitespace(getNodeText(t, ruleNames), true);
  buf.append(s);
  buf.append(' ');
  for (int i = 0; i < t.getChildCount(); i++) {
    if (i > 0) {
      buf.append(' ');
    }
    buf.append(toStringTree(t.getChild(i), ruleNames));
  }
  buf.append(" ) ");
  return buf.toString();
}
 
开发者ID:antlr4ide,项目名称:antlr4ide,代码行数:19,代码来源:ParseTreeCommand.java

示例5: wrap

import org.antlr.v4.runtime.tree.Tree; //导入方法依赖的package包/类
private MutableTreeNode wrap(final Tree tree) {
	if (tree == null) {
		return null;
	}
	DefaultMutableTreeNode root = new DefaultMutableTreeNode(tree) {
		@Override
		public String toString() {
			String name = treeTextProvider.getText((Tree) getUserObject());

			if (tree instanceof TerminalNode) {
				return name.equals("<EOF>") ? name : "\"" + name + "\"";
			}

			return name;
		}


	};

	for (int i = 0; i < tree.getChildCount(); i++) {
		root.add(wrap(tree.getChild(i)));
	}
	return root;
}
 
开发者ID:antlr,项目名称:intellij-plugin-v4,代码行数:25,代码来源:JTreeViewer.java

示例6: _getAllLeaves

import org.antlr.v4.runtime.tree.Tree; //导入方法依赖的package包/类
public static void _getAllLeaves(Tree t, List<? super Tree> leaves,
							final int startIndex,
							final int stopIndex)
{
	int n = t.getChildCount();
	if ( n==0 ) { // must be leaf
		Token tok = ((TerminalNode)t).getSymbol();
		int i = tok.getTokenIndex();
		if ( i>=startIndex && i<=stopIndex && tok.getType() != Token.INVALID_TYPE ) {
			leaves.add(t);
		}
		return;
	}
	for (int i = 0 ; i < n ; i++){
		_getAllLeaves(t.getChild(i), leaves, startIndex, stopIndex);
	}
}
 
开发者ID:antlr,项目名称:intellij-plugin-v4,代码行数:18,代码来源:ParsingUtils.java

示例7: patternCollectAddSubnodesAddParentNode

import org.antlr.v4.runtime.tree.Tree; //导入方法依赖的package包/类
public static void patternCollectAddSubnodesAddParentNode(EvalFactoryNode evalNode, Tree node, Map<Tree, EvalFactoryNode> astPatternNodeMap) {
    if (evalNode == null) {
        throw ASTWalkException.from("Invalid null expression node for '" + ASTUtil.printNode(node) + "'");
    }
    for (int i = 0; i < node.getChildCount(); i++) {
        Tree childNode = node.getChild(i);
        EvalFactoryNode childEvalNode = patternGetRemoveTopNode(childNode, astPatternNodeMap);
        if (childEvalNode != null) {
            evalNode.addChildNode(childEvalNode);
        }
    }
    astPatternNodeMap.put(node, evalNode);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:14,代码来源:ASTExprHelper.java

示例8: patternGetRemoveTopNode

import org.antlr.v4.runtime.tree.Tree; //导入方法依赖的package包/类
public static EvalFactoryNode patternGetRemoveTopNode(Tree node, Map<Tree, EvalFactoryNode> astPatternNodeMap) {
    EvalFactoryNode pattern = astPatternNodeMap.get(node);
    if (pattern != null) {
        astPatternNodeMap.remove(node);
        return pattern;
    }
    for (int i = 0; i < node.getChildCount(); i++) {
        pattern = patternGetRemoveTopNode(node.getChild(i), astPatternNodeMap);
        if (pattern != null) {
            return pattern;
        }
    }
    return null;
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:15,代码来源:ASTExprHelper.java

示例9: regExApplyActionRecursive

import org.antlr.v4.runtime.tree.Tree; //导入方法依赖的package包/类
public static void regExApplyActionRecursive(Tree node, Map<Tree, RowRegexExprNode> astRegExNodeMap, RegExAction action) {
    RowRegexExprNode expr = astRegExNodeMap.get(node);
    if (expr != null) {
        action.found(expr, astRegExNodeMap, node);
        return;
    }
    for (int i = 0; i < node.getChildCount(); i++) {
        regExApplyActionRecursive(node.getChild(i), astRegExNodeMap, action);
    }
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:11,代码来源:ASTExprHelper.java

示例10: recursiveFindRemoveChildExprNode

import org.antlr.v4.runtime.tree.Tree; //导入方法依赖的package包/类
private static void recursiveFindRemoveChildExprNode(Tree node, Map<Tree, ExprNode> astExprNodeMap, ExprAction action) {
    ExprNode expr = astExprNodeMap.get(node);
    if (expr != null) {
        action.found(expr, astExprNodeMap, node);
        return;
    }
    for (int i = 0; i < node.getChildCount(); i++) {
        recursiveFindRemoveChildExprNode(node.getChild(i), astExprNodeMap, action);
    }
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:11,代码来源:ASTExprHelper.java

示例11: regExGetRemoveTopNode

import org.antlr.v4.runtime.tree.Tree; //导入方法依赖的package包/类
public static RowRegexExprNode regExGetRemoveTopNode(Tree node, Map<Tree, RowRegexExprNode> astRowRegexNodeMap) {
    RowRegexExprNode regex = astRowRegexNodeMap.get(node);
    if (regex != null) {
        astRowRegexNodeMap.remove(node);
        return regex;
    }
    for (int i = 0; i < node.getChildCount(); i++) {
        regex = regExGetRemoveTopNode(node.getChild(i), astRowRegexNodeMap);
        if (regex != null) {
            return regex;
        }
    }
    return null;
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:15,代码来源:ASTExprHelper.java

示例12: findChildRuleByType

import org.antlr.v4.runtime.tree.Tree; //导入方法依赖的package包/类
private static RuleNode findChildRuleByType(Tree node, int ruleNum) {
    for (int i = 0; i < node.getChildCount(); i++) {
        Tree child = node.getChild(i);
        if (isRuleOfType(child, ruleNum)) {
            return (RuleNode) child;
        }
    }
    return null;
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:10,代码来源:ASTConstantHelper.java

示例13: process

import org.antlr.v4.runtime.tree.Tree; //导入方法依赖的package包/类
private String process(final Tree t, final List<String> ruleNames) {
	if (t.getChildCount() == 0) return Utils.escapeWhitespace(Trees.getNodeText(t, ruleNames), false);
	StringBuilder sb = new StringBuilder();
	sb.append(lead(level));
	level++;
	String s = Utils.escapeWhitespace(Trees.getNodeText(t, ruleNames), false);
	sb.append(s + ' ');
	for (int i = 0; i < t.getChildCount(); i++) {
		sb.append(process(t.getChild(i), ruleNames));
	}
	level--;
	sb.append(lead(level));
	return sb.toString();
}
 
开发者ID:grosenberg,项目名称:SnippetsTest,代码行数:15,代码来源:TestBase.java

示例14: countTree

import org.antlr.v4.runtime.tree.Tree; //导入方法依赖的package包/类
/** Recursive call to compute the complexity of this (sub)tree. */
protected void countTree(@NotNull Tree t, Long depth) {
  if (treeDepth < depth) treeDepth = depth;
	for (int i = 0; i<t.getChildCount(); i++) {
		countTree(t.getChild(i), depth+1);
		numNodes++;
	}
}
 
开发者ID:fandianpf,项目名称:antlr4-regressionTestRig,代码行数:9,代码来源:TreeCounter.java

示例15: printTree

import org.antlr.v4.runtime.tree.Tree; //导入方法依赖的package包/类
/** 
 * Recursive call to print out a sub-tree in indented form.
 * {@link #appendNodeText} is used on the node payloads to get the text for the
 * nodes. Detect parse trees and extract data appropriately.
 */
protected void printTree(@NotNull Tree t, String indent) {
	buf.append("\n");
	buf.append(indent);
	appendNodeText(t);
	String childIndent = newIndent(indent);
	for (int i = 0; i<t.getChildCount(); i++) {
		printTree(t.getChild(i), childIndent);
	}
}
 
开发者ID:fandianpf,项目名称:antlr4-regressionTestRig,代码行数:15,代码来源:TreePrinter.java


注:本文中的org.antlr.v4.runtime.tree.Tree.getChildCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。