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


Java ParseTree.getChild方法代码示例

本文整理汇总了Java中org.antlr.v4.runtime.tree.ParseTree.getChild方法的典型用法代码示例。如果您正苦于以下问题:Java ParseTree.getChild方法的具体用法?Java ParseTree.getChild怎么用?Java ParseTree.getChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.antlr.v4.runtime.tree.ParseTree的用法示例。


在下文中一共展示了ParseTree.getChild方法的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: next

import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
private ParseTree next(ParseTree tree) {
    ParseTree parent = up(tree);
    ParseTree child;
    boolean foundCurrent = false;
    for (int i = 0; i < parent.getChildCount(); i++) {
        child = parent.getChild(i);
        if (foundCurrent) {
            if (treeIsSeparator(child)) {
                continue;
            }
            return child;
        }

        if (child == tree) {
            foundCurrent = true;
        }
    }
    return null; // There is no next
}
 
开发者ID:nielsbasjes,项目名称:yauaa,代码行数:20,代码来源:StepNext.java

示例3: 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

示例4: 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

示例5: getNextSibling

import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
/**
 * Gets next sibling of ParseTree node.
 * @param node ParseTree node
 * @return next sibling of ParseTree node.
 */
private static ParseTree getNextSibling(ParseTree node) {
    ParseTree nextSibling = null;

    if (node.getParent() != null) {
        final ParseTree parent = node.getParent();
        int index = 0;
        while (true) {
            final ParseTree currentNode = parent.getChild(index);
            if (currentNode.equals(node)) {
                nextSibling = parent.getChild(index + 1);
                break;
            }
            index++;
        }
    }
    return nextSibling;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:23,代码来源:JavadocDetailNodeParser.java

示例6: enterParseTree

import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
private void enterParseTree(ParseTree tree){
    int cc = tree.getChildCount();
    for(int i=0;i<cc;i++){
        ParseTree c = tree.getChild(i);
        if(c instanceof RuleNode){
            enterParseTree(c);
        }else if (c instanceof TerminalNode){
            Token t = ((TerminalNode)c).getSymbol();
            index2token.put(tokenCounter, t);
            token2tree.put(t, c);
            tokenCounter ++;
        }else{
            System.err.println("unknown node:" + c);
        }
    }
}
 
开发者ID:kasonyang,项目名称:kalang,代码行数:17,代码来源:ParseTreeNavigator.java

示例7: readValues

import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
private OperatorNode<ExpressionOperator> readValues(List<Field_defContext> fieldDefs, Scope scope) {
    List<String> fieldNames;
    List<OperatorNode<ExpressionOperator>> fieldValues;
    int numPairs = fieldDefs.size();
    fieldNames = Lists.newArrayListWithExpectedSize(numPairs);
    fieldValues = Lists.newArrayListWithExpectedSize(numPairs);
    for (int j = 0; j < numPairs; j++) {
        ParseTree startNode = fieldDefs.get(j);
        while (startNode.getChildCount() < 3) {
            startNode = startNode.getChild(0);
        }
        fieldNames.add((String) convertExpr(startNode.getChild(0), scope).getArgument(1));
        fieldValues.add(convertExpr(startNode.getChild(2), scope));
    }
    return OperatorNode.create(ExpressionOperator.MAP, fieldNames, fieldValues);
}
 
开发者ID:yahoo,项目名称:yql-plus,代码行数:17,代码来源:ProgramParser.java

示例8: print

import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
public static void print(final ParseTree node, final int level, CommonTokenStream stream) {
	final Interval sourceInterval = node.getSourceInterval();

	final Token firstToken = stream.get(sourceInterval.a);

	int line = firstToken.getLine();
	int charStart = firstToken.getCharPositionInLine();

	int endLine = line;
	int endChar = charStart + firstToken.getText().length();

	String data = "@(" + line + ":" + charStart + "," + endLine + ":" + endChar + ") with text: "
			+ firstToken.getText();
	final int tmp = level + 1;
	final StringBuilder sb = new StringBuilder();
	sb.append(StringUtils.repeat("\t", level));
	sb.append(node.getClass().getSimpleName() + ": " + data + " :" + 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, stream);

	}
}
 
开发者ID:gretard,项目名称:sonar-tsql-plugin,代码行数:27,代码来源:Antlr4Utils.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: visit

import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
@Override
public Integer visit(final ParseTree tree) {

	final int n = tree.getChildCount();
	int s = 0;
	for (int i = 0; i < n; i++) {
		final ParseTree c = tree.getChild(i);
		s += visit(c);
	}
	final Class<? extends ParseTree> classz = tree.getClass();
	if (Sql_unionContext.class.equals(classz)) {
		s++;
	}
	if (Function_callContext.class.isAssignableFrom(classz)) {
		s++;
	}
	if (Join_partContext.class.equals(classz)) {
		s++;
	}
	if (Order_by_expressionContext.class.equals(classz)) {
		s++;
	}
	if (Select_list_elemContext.class.equals(classz)) {
		s++;
	}
	if (Search_condition_notContext.class.equals(classz)) {
		s++;
	}
	if (Dml_clauseContext.class.equals(classz)) {
		s++;
	}
	return s;

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

示例11: 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

示例12: 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

示例13: insertChildrenNodes

import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
/**
 * Creates child nodes for each node from 'nodes' array.
 * @param parseTreeParent original ParseTree parent node
 * @param nodes array of JavadocNodeImpl nodes
 */
private void insertChildrenNodes(final JavadocNodeImpl[] nodes, ParseTree parseTreeParent) {
    for (int i = 0; i < nodes.length; i++) {
        final JavadocNodeImpl currentJavadocNode = nodes[i];
        final ParseTree currentParseTreeNodeChild = parseTreeParent.getChild(i);
        final JavadocNodeImpl[] subChildren =
                createChildrenNodes(currentJavadocNode, currentParseTreeNodeChild);
        currentJavadocNode.setChildren((DetailNode[]) subChildren);
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:15,代码来源:JavadocDetailNodeParser.java

示例14: getTerminal

import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
public static TerminalNode getTerminal(ParseTree t, FusionTablesSqlParser parser) {
	Check.isTrue(t.getChildCount() == 1);
	ParseTree c = t.getChild(0);
	TerminalNode result = null;
	
	if (c != null){ 
		Check.isTrue(c instanceof TerminalNode);
		result = (TerminalNode) c;
	}
		
	return result;
}
 
开发者ID:curiosag,项目名称:ftc,代码行数:13,代码来源:Util.java

示例15: getSqlStatementType

import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
public static StatementType getSqlStatementType(ParseTree t, FusionTablesSqlParser parser) {
	StatementType result = StatementType.UNKNOWN;

	if (t instanceof RuleContext && t.getChildCount() > 0 && t.getChild(0) instanceof RuleContext) {
		ParseTree c = t.getChild(0);
		RuleContext r = (RuleContext) c;
		result = getSqlStatementType((parser.getRuleNames()[r.getRuleIndex()]));
	}
	return result;
}
 
开发者ID:curiosag,项目名称:ftc,代码行数:11,代码来源:Util.java


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