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


Java RuleNode.getChildCount方法代码示例

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


在下文中一共展示了RuleNode.getChildCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitChildren

import org.antlr.v4.runtime.tree.RuleNode; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Object visitChildren(final RuleNode node) {

	final int n = node.getChildCount();

	for (int i = 0; i < n; i++) {
		final ParseTree c = node.getChild(i);
		c.accept(this);

	}
	final String textToFind = node.getText();
	if (StringUtils.containsIgnoreCase(textToFind, tempText)
			|| StringUtils.containsIgnoreCase(tempText, textToFind)) {
		nodes.add(new ParsedNode(node));
	}
	return null;

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

示例2: walk

import org.antlr.v4.runtime.tree.RuleNode; //导入方法依赖的package包/类
public void walk(ParseTreeListener listener, ParseTree t) {
	if ( t instanceof ErrorNode) {
		listener.visitErrorNode((ErrorNode)t);
		return;
	}
	else if ( t instanceof TerminalNode) {
		listener.visitTerminal((TerminalNode)t);
		return;
	}
	RuleNode r = (RuleNode)t;
	enterRule(listener, r);
	int n = r.getChildCount();
	for (int i = 0; i<n; i++) {
		walk(listener, r.getChild(i));
	}
	exitRule(listener, r);

}
 
开发者ID:holycrap872,项目名称:green-solver,代码行数:19,代码来源:KleeParseTreeWalker.java

示例3: visitChildren

import org.antlr.v4.runtime.tree.RuleNode; //导入方法依赖的package包/类
public String visitChildren(RuleNode node) {
int n = node.getChildCount();
if (n > 1) {
    StringBuilder result = new StringBuilder();
    ParseTree child;
    String childResult;
    for (int i = 0; i < n; i++) {
	child = node.getChild(i);
	childResult = child.accept(this);
	if (childResult != null) {
	    if (i > 0) {
		result.append(' ');
	    }
	    result.append(childResult);
	}
    }
    return result.toString();
} else {
    if (n == 1) {
	return node.getChild(0).accept(this);
    } else {
	return node.getText();
    }
}
   }
 
开发者ID:dice-group,项目名称:Cetus,代码行数:26,代码来源:StringCreatingVisitor.java

示例4: visitChildren

import org.antlr.v4.runtime.tree.RuleNode; //导入方法依赖的package包/类
public List<String> visitChildren(RuleNode node) {
List<String> result = defaultResult();
List<String> childResult;
ParseTree child;
int n = node.getChildCount();
for (int i = 0; i < n; i++) {
    if (!shouldVisitNextChild(node, result)) {
	break;
    }

    child = node.getChild(i);
    childResult = child.accept(this);
    if (childResult != null) {
	if (result != null) {
	    result.addAll(childResult);
	} else {
	    result = childResult;
	}
    }
}
return result;
   }
 
开发者ID:dice-group,项目名称:Cetus,代码行数:23,代码来源:TypeStringCreatingVisitor.java

示例5: visitChildren

import org.antlr.v4.runtime.tree.RuleNode; //导入方法依赖的package包/类
@Override
public Integer visitChildren(RuleNode arg0) {
	int iHash = 1;
	boolean bVisit = false;
	
	for (int i = arg0.getChildCount() - 1; i >= 0; i--) {
		Integer iVisit = visit(arg0.getChild(i));
		
		// If the visit resulted no hash ignore the hash.
		if (iVisit != null) {
			iHash = iHash * PRIME + iVisit;
			bVisit = true;
		}
	}
	
	if (bVisit) {
		return iHash;
	} else {
		return defaultResult(); // No result.
	}
}
 
开发者ID:ArjanO,项目名称:Purify,代码行数:22,代码来源:HashVisitor.java

示例6: visitChildren

import org.antlr.v4.runtime.tree.RuleNode; //导入方法依赖的package包/类
public String visitChildren(RuleNode node, List<Integer> withoutNodes) {
    if(node == null) return "";
    String result = this.defaultResult();
    int n = node.getChildCount();

    for(int i = 0; i < n && this.shouldVisitNextChild(node, result); ++i) {
        if(withoutNodes != null && withoutNodes.contains(i)) continue;
        ParseTree c = node.getChild(i);
        String childResult = c instanceof TerminalNode ? printTerminalNode((TerminalNode) c) : c.accept(this);
        result = this.aggregateResult(result, childResult);
    }

    return result;
}
 
开发者ID:marcelganczak,项目名称:ts-swift-transpiler,代码行数:15,代码来源:Visitor.java

示例7: visitWithoutTerminals

import org.antlr.v4.runtime.tree.RuleNode; //导入方法依赖的package包/类
public String visitWithoutTerminals(RuleNode node) {
    String result = this.defaultResult();
    int n = node.getChildCount();

    for(int i = 0; i < n && this.shouldVisitNextChild(node, result); ++i) {
        ParseTree c = node.getChild(i);
        if(c instanceof TerminalNode) continue;
        String childResult = c.accept(this);
        result = this.aggregateResult(result, childResult);
    }

    return result;
}
 
开发者ID:marcelganczak,项目名称:ts-swift-transpiler,代码行数:14,代码来源:Visitor.java

示例8: visitWithoutStrings

import org.antlr.v4.runtime.tree.RuleNode; //导入方法依赖的package包/类
public String visitWithoutStrings(RuleNode node, String string) {
    String result = this.defaultResult();
    int n = node.getChildCount();

    for(int i = 0; i < n && this.shouldVisitNextChild(node, result); ++i) {
        ParseTree c = node.getChild(i);
        if(string.contains(c.getText())) continue;
        String childResult = c instanceof TerminalNode ? printTerminalNode((TerminalNode) c) : c.accept(this);
        result = this.aggregateResult(result, childResult);
    }

    return result;
}
 
开发者ID:marcelganczak,项目名称:ts-swift-transpiler,代码行数:14,代码来源:Visitor.java

示例9: visitWithoutClasses

import org.antlr.v4.runtime.tree.RuleNode; //导入方法依赖的package包/类
public String visitWithoutClasses(RuleNode node, Class nodeType) {
    String result = this.defaultResult();
    int n = node.getChildCount();

    for(int i = 0; i < n && this.shouldVisitNextChild(node, result); ++i) {
        ParseTree c = node.getChild(i);
        if(c.getClass() == nodeType) continue;
        String childResult = c instanceof TerminalNode ? printTerminalNode((TerminalNode) c) : c.accept(this);
        result = this.aggregateResult(result, childResult);
    }

    return result;
}
 
开发者ID:marcelganczak,项目名称:ts-swift-transpiler,代码行数:14,代码来源:Visitor.java

示例10: visitChildren

import org.antlr.v4.runtime.tree.RuleNode; //导入方法依赖的package包/类
@Override
public String visitChildren(final RuleNode arg0) {
  String visitString = "";
  for (int i = 0; i < arg0.getChildCount(); i++) {
    visitString += this.visit(arg0.getChild(i));
  }
  return visitString;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:9,代码来源:PrettyPrinter.java

示例11: parseTreeWalker

import org.antlr.v4.runtime.tree.RuleNode; //导入方法依赖的package包/类
private static void parseTreeWalker(ParseTree node, Consumer<RuleNode> f) {
    RuleNode rule = checkNode(node, RuleNode.class);
    if (rule == null) {
        return;
    }
    f.accept(rule);
    for (int i = 0; i < rule.getChildCount(); i++) {
        parseTreeWalker(rule.getChild(i), f);
    }
}
 
开发者ID:shunfei,项目名称:indexr,代码行数:11,代码来源:IndexRQL.java

示例12: visitChildren

import org.antlr.v4.runtime.tree.RuleNode; //导入方法依赖的package包/类
public String visitChildren(RuleNode arg0) {
	int childrenCount = arg0.getChildCount();
	StringBuilder builder = new StringBuilder();
	increaseIndentationLevel();
	for(int i = 0; i < childrenCount; i++){
		builder.append(arg0.getChild(i).accept(this));
	}
	decreaseIndentationLevel();
	return builder.toString();
}
 
开发者ID:Rospaccio,项目名称:learnantlr,代码行数:11,代码来源:TextTreeDumpVisitor.java

示例13: parse

import org.antlr.v4.runtime.tree.RuleNode; //导入方法依赖的package包/类
/**
 * Parse the AST constant node and return Object value.
 *
 * @param node - parse node for which to parse the string value
 * @return value matching AST node type
 */
public static Object parse(ParseTree node) {
    if (node instanceof TerminalNode) {
        TerminalNode terminal = (TerminalNode) node;
        switch (terminal.getSymbol().getType()) {
            case EsperEPL2GrammarParser.BOOLEAN_TRUE:
                return BoolValue.parseString(terminal.getText());
            case EsperEPL2GrammarParser.BOOLEAN_FALSE:
                return BoolValue.parseString(terminal.getText());
            case EsperEPL2GrammarParser.VALUE_NULL:
                return null;
            default:
                throw ASTWalkException.from("Encountered unexpected constant type " + terminal.getSymbol().getType(), terminal.getSymbol());
        }
    } else {
        RuleNode ruleNode = (RuleNode) node;
        int ruleIndex = ruleNode.getRuleContext().getRuleIndex();
        if (ruleIndex == EsperEPL2GrammarParser.RULE_number) {
            return parseNumber(ruleNode, 1);
        } else if (ruleIndex == EsperEPL2GrammarParser.RULE_numberconstant) {
            RuleNode number = findChildRuleByType(ruleNode, EsperEPL2GrammarParser.RULE_number);
            if (ruleNode.getChildCount() > 1) {
                if (ASTUtil.isTerminatedOfType(ruleNode.getChild(0), EsperEPL2GrammarLexer.MINUS)) {
                    return parseNumber(number, -1);
                }
                return parseNumber(number, 1);
            } else {
                return parseNumber(number, 1);
            }
        } else if (ruleIndex == EsperEPL2GrammarParser.RULE_stringconstant) {
            return StringValue.parseString(node.getText());
        } else if (ruleIndex == EsperEPL2GrammarParser.RULE_constant) {
            return parse(ruleNode.getChild(0));
        }
        throw ASTWalkException.from("Encountered unrecognized constant", node.getText());
    }
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:43,代码来源:ASTConstantHelper.java

示例14: visitChildren

import org.antlr.v4.runtime.tree.RuleNode; //导入方法依赖的package包/类
@Override
public String visitChildren(RuleNode node) {
	StringBuilder builder = new StringBuilder();
	builder.append(System.lineSeparator());
	int childrenCount = node.getChildCount();
	increaseIndentation();
	for (int i = 0; i < childrenCount; i++) {
		builder.append(node.getChild(i).accept(this));
	}
	decreaseIndentation();
	return builder.toString();
}
 
开发者ID:Rospaccio,项目名称:arithmetic,代码行数:13,代码来源:ParseTreeDumperVisitor.java

示例15: appendSpaceToAggregateField

import org.antlr.v4.runtime.tree.RuleNode; //导入方法依赖的package包/类
private void appendSpaceToAggregateField(final StringBuilder sb, final RuleNode ctx) {
  for (int i = 0; i < ctx.getChildCount(); i++) {
    final ParseTree child = ctx.getChild(i);

    if (child instanceof RuleNode) {
      appendSpaceToAggregateField(sb, (RuleNode) child);

      if (child instanceof OptionAggregateValueFieldContext) {
        sb.append(AGREGATE_VALUE_FIELD_DELIMITER);
      }
    } else {
      sb.append(child.getText());
    }
  }
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:16,代码来源:ProtoFileParser.java


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