本文整理汇总了Java中org.antlr.v4.runtime.tree.RuleNode.getText方法的典型用法代码示例。如果您正苦于以下问题:Java RuleNode.getText方法的具体用法?Java RuleNode.getText怎么用?Java RuleNode.getText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.antlr.v4.runtime.tree.RuleNode
的用法示例。
在下文中一共展示了RuleNode.getText方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: parseNumber
import org.antlr.v4.runtime.tree.RuleNode; //导入方法依赖的package包/类
private static Object parseNumber(RuleNode number, int factor) {
int tokenType = getSingleChildTokenType(number);
if (tokenType == EsperEPL2GrammarLexer.IntegerLiteral) {
return parseIntLongByte(number.getText(), factor);
} else if (tokenType == EsperEPL2GrammarLexer.FloatingPointLiteral) {
String numberText = number.getText();
if (numberText.endsWith("f") || numberText.endsWith("F")) {
return Float.parseFloat(number.getText()) * factor;
} else {
return Double.parseDouble(number.getText()) * factor;
}
}
throw ASTWalkException.from("Encountered unrecognized constant", number.getText());
}
示例4: visitChildren
import org.antlr.v4.runtime.tree.RuleNode; //导入方法依赖的package包/类
@Override
public TqlElement visitChildren(RuleNode node) {
throw new TqlException("Unhandled children node: " + node.getText());
}