本文整理汇总了Java中org.antlr.v4.runtime.tree.Tree.getChild方法的典型用法代码示例。如果您正苦于以下问题:Java Tree.getChild方法的具体用法?Java Tree.getChild怎么用?Java Tree.getChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.antlr.v4.runtime.tree.Tree
的用法示例。
在下文中一共展示了Tree.getChild方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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);
}
示例3: 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;
}
示例4: getLastChild
import org.antlr.v4.runtime.tree.Tree; //导入方法依赖的package包/类
@Override
public Tree getLastChild(Tree parentNode) {
return parentNode.getChild(parentNode.getChildCount() - 1);
}
示例5: getFirstChild
import org.antlr.v4.runtime.tree.Tree; //导入方法依赖的package包/类
@Override
public Tree getFirstChild(Tree parentNode) {
return parentNode.getChild(0);
}
示例6: fillTree
import org.antlr.v4.runtime.tree.Tree; //导入方法依赖的package包/类
private static void fillTree(TreeNodeWrapper node, Tree tree, TreeViewer viewer) {
if (tree == null) {
return;
}
for (int i = 0; i < tree.getChildCount(); i++) {
Tree childTree = tree.getChild(i);
TreeNodeWrapper childNode = new TreeNodeWrapper(childTree, viewer);
node.add(childNode);
fillTree(childNode, childTree, viewer);
}
}