本文整理汇总了Java中org.antlr.runtime.tree.CommonTree.addChild方法的典型用法代码示例。如果您正苦于以下问题:Java CommonTree.addChild方法的具体用法?Java CommonTree.addChild怎么用?Java CommonTree.addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.antlr.runtime.tree.CommonTree
的用法示例。
在下文中一共展示了CommonTree.addChild方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: patchTreeByTreesGroupBy
import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
public static void patchTreeByTreesGroupBy(CommonTree srcTree, CommonTree targetTree)
{
//System.out.println("Text = " + srcTree.getText() + " ChildCount = " + srcTree.getChildCount() + " Type = " + srcTree.getType());
if (srcTree.getChildCount() == 0) {
return;
}
// process node
if (srcTree.getText().equals(QUERY_SPEC_NODE)) {
// patch
targetTree.setParent(srcTree);
srcTree.addChild(targetTree);
return;
}
// process children
for (Tree t : children(srcTree)) {
patchTreeByTreesGroupBy((CommonTree)t, targetTree);
}
return;
}
示例2: 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;
}
示例3: 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;
}
示例4: copy
import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
static private CommonTree copy(CommonTree source)
{
CommonTree newNode = new CommonTree(source);
if (source.getChildCount() > 0)
{
for (Object current : source.getChildren())
{
CommonTree child = (CommonTree) current;
CommonTree newChild = copy(child);
newNode.addChild(newChild);
}
}
return newNode;
}