本文整理汇总了Java中org.antlr.v4.runtime.tree.RuleNode.getChild方法的典型用法代码示例。如果您正苦于以下问题:Java RuleNode.getChild方法的具体用法?Java RuleNode.getChild怎么用?Java RuleNode.getChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.antlr.v4.runtime.tree.RuleNode
的用法示例。
在下文中一共展示了RuleNode.getChild方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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();
}
}
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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());
}
}
}
示例9: getRuleTagToken
import org.antlr.v4.runtime.tree.RuleNode; //导入方法依赖的package包/类
/** Is {@code t} {@code (expr <expr>)} subtree? */
protected RuleTagToken getRuleTagToken(ParseTree t) {
if ( t instanceof RuleNode ) {
RuleNode r = (RuleNode)t;
if ( r.getChildCount()==1 && r.getChild(0) instanceof TerminalNode ) {
TerminalNode c = (TerminalNode)r.getChild(0);
if ( c.getSymbol() instanceof RuleTagToken ) {
// System.out.println("rule tag subtree "+t.toStringTree(parser));
return (RuleTagToken)c.getSymbol();
}
}
}
return null;
}