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


Java ParseTree.getChildCount方法代码示例

本文整理汇总了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);
}
 
开发者ID:nielsbasjes,项目名称:yauaa,代码行数:17,代码来源:StepWordRange.java

示例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
}
 
开发者ID:nielsbasjes,项目名称:yauaa,代码行数:22,代码来源:StepPrevN.java

示例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
}
 
开发者ID:nielsbasjes,项目名称:yauaa,代码行数:18,代码来源:StepPrev.java

示例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
}
 
开发者ID:nielsbasjes,项目名称:yauaa,代码行数:24,代码来源:StepNextN.java

示例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;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:21,代码来源:JavadocDetailNodeParser.java

示例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);
        }
    }
}
 
开发者ID:CIRDLES,项目名称:Squid,代码行数:10,代码来源:ExpressionParser.java

示例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());
	}

}
 
开发者ID:sabotage,项目名称:SQLParser,代码行数:9,代码来源:MyListener.java

示例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;
}
 
开发者ID:marcelganczak,项目名称:ts-swift-transpiler,代码行数:9,代码来源:WalkerUtil.java

示例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;
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:10,代码来源:GroovyNameBuilder.java

示例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");
}
 
开发者ID:nielsbasjes,项目名称:yauaa,代码行数:16,代码来源:UserAgentTreeFlattener.java

示例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;
}
 
开发者ID:XiaoMi,项目名称:linden,代码行数:34,代码来源:BQLCompiler.java

示例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;
	}
 
开发者ID:SwiftAnalysis,项目名称:SwiftAnalyzer,代码行数:16,代码来源:OverallMetricsListener.java

示例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;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:20,代码来源:JavadocDetailNodeParser.java

示例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);

	}
}
 
开发者ID:gretard,项目名称:sonar-tsql-plugin,代码行数:15,代码来源:Antlr4Utils.java

示例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;
	}
 
开发者ID:SwiftAnalysis,项目名称:SwiftAnalyzer,代码行数:16,代码来源:OverallMetricsListener.java


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