本文整理汇总了Java中org.antlr.v4.runtime.tree.ParseTree.getChildCount方法的典型用法代码示例。如果您正苦于以下问题:Java ParseTree.getChildCount方法的具体用法?Java ParseTree.getChildCount怎么用?Java ParseTree.getChildCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.antlr.v4.runtime.tree.ParseTree
的用法示例。
在下文中一共展示了ParseTree.getChildCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: walk
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
@Override
public WalkResult walk(ParseTree tree, String value) {
String actualValue = getActualValue(tree, value);
String filteredValue;
if (tree.getChildCount() == 1 && (
tree.getChild(0) instanceof SingleVersionContext ||
tree.getChild(0) instanceof SingleVersionWithCommasContext)) {
filteredValue = VersionSplitter.getInstance().getSplitRange(actualValue, firstWord, lastWord);
} else {
filteredValue = WordSplitter.getInstance().getSplitRange(actualValue, firstWord, lastWord);
}
if (filteredValue == null) {
return null;
}
return walkNextStep(tree, filteredValue);
}
示例2: prev
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
private ParseTree prev(ParseTree tree) {
ParseTree parent = up(tree);
int lastChildIndex = -1;
ParseTree child = null;
int i;
for (i = 0; i < parent.getChildCount(); i++) {
if (!treeIsSeparator(child)) {
lastChildIndex++;
children[lastChildIndex] = child;
}
child = parent.getChild(i);
if (child == tree) {
if (lastChildIndex < steps) {
break; // There is no previous
}
return children[lastChildIndex - steps + 1];
}
}
return null; // There is no previous
}
示例3: prev
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
private ParseTree prev(ParseTree tree) {
ParseTree parent = up(tree);
ParseTree prevChild = null;
ParseTree child = null;
int i;
for (i = 0; i < parent.getChildCount(); i++) {
if (!treeIsSeparator(child)) {
prevChild = child;
}
child = parent.getChild(i);
if (child == tree) {
return prevChild;
}
}
return null; // This should never happen
}
示例4: next
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
private ParseTree next(ParseTree tree) {
ParseTree parent = up(tree);
ParseTree child;
boolean foundCurrent = false;
int stepsToDo = steps;
for (int i = 0; i < parent.getChildCount(); i++) {
child = parent.getChild(i);
if (foundCurrent) {
if (treeIsSeparator(child)) {
continue;
}
stepsToDo--;
if (stepsToDo == 0) {
return child;
}
}
if (child == tree) {
foundCurrent = true;
}
}
return null; // There is no next
}
示例5: getTokenType
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
/**
* Gets token type of ParseTree node from JavadocTokenTypes class.
* @param node ParseTree node.
* @return token type from JavadocTokenTypes
*/
private static int getTokenType(ParseTree node) {
final int tokenType;
if (node.getChildCount() == 0) {
tokenType = ((TerminalNode) node).getSymbol().getType();
}
else {
final String className = getNodeClassNameWithoutContext(node);
final String typeName =
CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, className);
tokenType = JavadocUtils.getTokenId(typeName);
}
return tokenType;
}
示例6: printTree
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
private void printTree(ExpressionsForSquid2Parser parser, ParseTree tree, List<String> parsed) {
if (tree.getChildCount() < 1) {
parsed.add(tree.toStringTree(parser));
} else {
for (int i = 0; i < tree.getChildCount(); i++) {
printTree(parser, tree.getChild(i), parsed);
}
}
}
示例7: _exitLogical_expression
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
private void _exitLogical_expression(ParseTree ctx) {
if (ctx.getChildCount() ==3) {
Stack expstack =(Stack) model.current.tempCache.get("expstack");
LogicalExpression node = (LogicalExpression) expstack.pop();
System.out.println("########### POP " + node.getString());
}
}
示例8: has
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
public static boolean has(Class nodeType, ParseTree node) {
if(node == null) return false;
if(node.getClass() == nodeType) return true;
for(int i = 0; i < node.getChildCount(); i++) {
if(has(nodeType, node.getChild(i))) return true;
}
return false;
}
示例9: findChildrenByType
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
private ParseTree findChildrenByType(ParseTree parseTree, Class<?> classtype) {
for(int i=0; i<parseTree.getChildCount(); i++) {
ParseTree chl = parseTree.getChild(i);
if(chl.getClass().equals(classtype)) {
return chl;
}
}
return null;
}
示例10: enterProductVersion
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
private void enterProductVersion(ParseTree ctx) {
if (ctx.getChildCount() != 1) {
// These are the specials with multiple children like keyvalue, etc.
inform(ctx, "version");
return;
}
ParseTree child = ctx.getChild(0);
// Only for the SingleVersion edition we want to have splits of the version.
if (child instanceof SingleVersionContext || child instanceof SingleVersionWithCommasContext) {
return;
}
inform(ctx, "version");
}
示例11: getStartNode
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
private static TerminalNode getStartNode(ParseTree tree) {
if (tree instanceof TerminalNode) {
return (TerminalNode) tree;
}
Deque<ParseTree> workList = new ArrayDeque<ParseTree>();
IntegerStack workIndexStack = new IntegerStack();
workList.push(tree);
workIndexStack.push(0);
while (!workList.isEmpty()) {
ParseTree currentTree = workList.peek();
int currentIndex = workIndexStack.peek();
if (currentIndex == currentTree.getChildCount()) {
workList.pop();
workIndexStack.pop();
continue;
}
// move work list to next child
workIndexStack.push(workIndexStack.pop() + 1);
// process the current child
ParseTree child = currentTree.getChild(currentIndex);
if (child instanceof TerminalNode) {
return (TerminalNode) child;
}
workList.push(child);
workIndexStack.push(0);
}
return null;
}
示例12: getFirstTypeIdentifier
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
private String getFirstTypeIdentifier(ParseTree tree) {
if (tree instanceof SwiftParser.STypeContext) {
return tree.getText();
}
int childCount = tree.getChildCount();
String result = "";
for (int i = 0; result.equals("") && i< childCount; i++){
result = getFirstTypeIdentifier(tree.getChild(i));
}
return result;
}
示例13: createRootJavadocNode
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
/**
* Creates root JavadocNodeImpl node base on ParseTree root node.
* @param parseTreeNode ParseTree root node
* @return root Javadoc node
*/
private JavadocNodeImpl createRootJavadocNode(ParseTree parseTreeNode) {
final JavadocNodeImpl rootJavadocNode = createJavadocNode(parseTreeNode, null, -1);
final int childCount = parseTreeNode.getChildCount();
final DetailNode[] children = rootJavadocNode.getChildren();
for (int i = 0; i < childCount; i++) {
final JavadocNodeImpl child = createJavadocNode(parseTreeNode.getChild(i),
rootJavadocNode, i);
children[i] = child;
}
rootJavadocNode.setChildren(children);
return rootJavadocNode;
}
示例14: print
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
public static void print(final ParseTree node, final int level) {
final int tmp = level + 1;
final StringBuilder sb = new StringBuilder();
sb.append(StringUtils.repeat("\t", level));
sb.append(node.getClass().getSimpleName() + "@" + level + ": " + node.getText());
System.out.println(sb.toString());
final int n = node.getChildCount();
for (int i = 0; i < n; i++) {
final ParseTree c = node.getChild(i);
print(c, tmp);
}
}
示例15: containsTypeCast
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
private boolean containsTypeCast(ParseTree tree) {
if (tree.toString().equals("as")) {
return true;
}
int childCount = tree.getChildCount();
boolean result = false;
for (int i = 0; !result && i < childCount; i++){
result = containsTypeCast(tree.getChild(i));
}
return result;
}