本文整理汇总了Java中org.antlr.runtime.tree.CommonTree.deleteChild方法的典型用法代码示例。如果您正苦于以下问题:Java CommonTree.deleteChild方法的具体用法?Java CommonTree.deleteChild怎么用?Java CommonTree.deleteChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.antlr.runtime.tree.CommonTree
的用法示例。
在下文中一共展示了CommonTree.deleteChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createGroupByNode
import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
public static CommonTree createGroupByNode(List<String> names)
{
CommonTree groupByNode = createGenericNode(GENERIC_NODE);
groupByNode.token.setText(GROUP_BY_NODE);
//groupByNode.token.setType(80);
groupByNode.token.setType(findType(GROUP_BY_NODE));
groupByNode.deleteChild(0);
for (String name : names) {
CommonTree genericNode = createGenericNode(name);
genericNode.setParent(groupByNode);
groupByNode.addChild(genericNode);
}
return groupByNode;
}
示例2: patchTreeByTree
import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
public static void patchTreeByTree(CommonTree srcTree, String target, CommonTree goalTree)
{
if (srcTree.getChildCount() == 0) {
// leaf
//System.out.println("leaf " + srcTree.getToken().getText());
if (srcTree.getToken().getText().equals(target)) {
srcTree.deleteChild(0);
srcTree.addChild(goalTree);
System.out.println("Found 1!!!");
}
return;
}
// process node
System.out.println("node " + srcTree.getToken().getText());
if (srcTree.getToken().getText().equals(target)) {
srcTree.deleteChild(0);
srcTree.addChild(goalTree);
//System.out.println("Found 2!!!");
}
// process children
for (Tree t : children(srcTree)) {
patchTreeByTree((CommonTree)t, target, goalTree);
}
return;
}