本文整理匯總了Java中org.antlr.v4.runtime.tree.ErrorNode類的典型用法代碼示例。如果您正苦於以下問題:Java ErrorNode類的具體用法?Java ErrorNode怎麽用?Java ErrorNode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ErrorNode類屬於org.antlr.v4.runtime.tree包,在下文中一共展示了ErrorNode類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: walk
import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的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);
}
示例2: visitFieldContains
import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
@Override
public TqlElement visitFieldContains(TqlParser.FieldContainsContext ctx) {
LOG.debug("Visit field contains: " + ctx.getText());
TerminalNode field = ctx.getChild(TerminalNode.class, 0);
TqlElement fieldName = field.accept(this);
TerminalNode valueNode = ctx.getChild(TerminalNode.class, 2);
if (valueNode instanceof ErrorNode)
throw new TqlException(valueNode.getText());
String quotedValue = valueNode.getSymbol().getText();
String value = quotedValue.substring(1, quotedValue.length() - 1);
FieldContainsExpression fieldContainsExpression = new FieldContainsExpression(fieldName, value);
LOG.debug("End visit field contains: " + ctx.getText());
return fieldContainsExpression;
}
示例3: visitFieldMatchesRegexp
import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
@Override
public TqlElement visitFieldMatchesRegexp(TqlParser.FieldMatchesRegexpContext ctx) {
LOG.debug("Visit field matches: " + ctx.getText());
TerminalNode field = ctx.getChild(TerminalNode.class, 0);
TqlElement fieldName = field.accept(this);
TerminalNode regexNode = ctx.getChild(TerminalNode.class, 2);
if (regexNode instanceof ErrorNode)
throw new TqlException(regexNode.getText());
String quotedRegex = regexNode.getSymbol().getText();
String regex = quotedRegex.substring(1, quotedRegex.length() - 1);
FieldMatchesRegex fieldMatchesRegex = new FieldMatchesRegex(fieldName, regex);
LOG.debug("End visit field matches: " + ctx.getText());
return fieldMatchesRegex;
}
示例4: visitErrorNode
import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
@Override
public CypherAstBase visitErrorNode(ErrorNode node) {
throw new MemgraphException(String.format(
"Could not parse: invalid value \"%s\" (line: %d, pos: %d)",
node.getText(),
node.getSymbol().getLine(),
node.getSymbol().getCharPositionInLine()
));
}
示例5: visitErrorNode
import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
// @Override public Result visitNumbers(@NotNull QueryParser.NumbersContext ctx) {
// return new Result( Result.Type.NUMBER, ctx.getText());
// }
@Override
public Result visitErrorNode(@NotNull ErrorNode errorNode) {
return null;
}
示例6: visitErrorNode
import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
@Override
public void visitErrorNode(ErrorNode node) {
super.visitErrorNode(node);
if (!isGenericError(node.getText()))
recognize(node.getSymbol(), getStop(node));
addErrorToken(node);
debugErrorNode(node);
}
示例7: visitErrorNode
import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
@Override
public void visitErrorNode(ErrorNode node) {
if(node.getSymbol().getCharPositionInLine() != -1) {
int line = node.getSymbol().getLine();
int rangeStart = node.getSymbol().getStartIndex();
int rangeEnd = node.getSymbol().getStopIndex();
log.logProblem("Error node: \"" + node.getText() + "\"", line, rangeStart, rangeEnd, Problem.Severity.CRITICAL);
} else {
log.logProblem("Error node with no position information: \"" + node.getText() + "\"", Problem.NO_LINE_NUM, Problem.Severity.CRITICAL);
}
}
示例8: checkNode
import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
private static <T> T checkNode(ParseTree node, Class<T> clazz) {
if (node instanceof ErrorNode) {
throw new IndexRQLParseError(node.getText());
} else if (node instanceof TerminalNode) {
return null;
} else if (clazz.isInstance(node)) {
return (T) node;
}
return null;
}
示例9: visitErrorNode
import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
@Override
public void visitErrorNode(ErrorNode node) {
// if (builder.length() > 0) {
// builder.append(' ');
// }
//
// builder.append(Utils.escapeWhitespace(Trees.getNodeText(node, ruleNames), false));
// builder.append(System.lineSeparator());
}
示例10: visitErrorNode
import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
@Override
public void visitErrorNode(ErrorNode node) {
if (builder.length() > 0) {
builder.append(' ');
}
builder.append(Utils.escapeWhitespace(Trees.getNodeText(node, ruleNames), false));
}
示例11: visitErrorNode
import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
@Override
public CypherAstBase visitErrorNode(ErrorNode node) {
throw new VertexiumException(String.format(
"Could not parse: invalid value \"%s\" (line: %d, pos: %d)",
node.getText(),
node.getSymbol().getLine(),
node.getSymbol().getCharPositionInLine()
));
}
示例12: visitErrorNode
import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
@Override
public void visitErrorNode(ErrorNode node) {
if (logger.isDebugEnabled()) {
logger.debug("visitErrorNode(ErrorNode) - start"); //$NON-NLS-1$
}
super.visitErrorNode(node);
if (logger.isDebugEnabled()) {
logger.debug("visitErrorNode(ErrorNode) - end"); //$NON-NLS-1$
}
}
示例13: getNodeText
import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
protected String getNodeText(Tree tree, List<String> ruleNames) {
if (ruleNames != null) {
if(tree instanceof RuleNode) {
int ruleIndex = ((RuleNode)tree).getRuleContext().getRuleIndex();
String ruleName = (String)ruleNames.get(ruleIndex);
return ruleName;
}
if(tree instanceof ErrorNode)
return tree.toString();
if(tree instanceof TerminalNode) {
Token symbol = ((TerminalNode)tree).getSymbol();
if(symbol != null) {
String s = symbol.getText();
return s;
}
}
}
Object payload = tree.getPayload();
if(payload instanceof Token)
return ((Token)payload).getText();
else
return tree.getPayload().toString();
}
示例14: visitFieldCompliesPattern
import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
@Override
public TqlElement visitFieldCompliesPattern(TqlParser.FieldCompliesPatternContext ctx) {
LOG.debug("Visit field complies: " + ctx.getText());
TqlElement fieldName = ctx.getChild(0).accept(this);
ParseTree patternNode = ctx.getChild(2);
if (patternNode instanceof ErrorNode)
throw new TqlException(patternNode.getText());
String quotedPattern = patternNode.getText();
String pattern = quotedPattern.substring(1, quotedPattern.length() - 1);
FieldCompliesPattern fieldCompliesPattern = new FieldCompliesPattern(fieldName, pattern);
LOG.debug("End visit field complies: " + ctx.getText());
return fieldCompliesPattern;
}
示例15: visitFieldIn
import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
@Override
public TqlElement visitFieldIn(TqlParser.FieldInContext ctx) {
LOG.debug("Visit field in: " + ctx.getText());
TerminalNode field = ctx.getChild(TerminalNode.class, 0);
TqlElement fieldName = field.accept(this);
// All children which are not terminal values are the needed literal values (see syntax)
LiteralValue[] literalValues = ctx.children.stream().filter(c -> c instanceof TqlParser.LiteralValueContext
|| c instanceof TqlParser.BooleanValueContext || c instanceof ErrorNode).map(c -> (LiteralValue) c.accept(this))
.toArray(LiteralValue[]::new);
FieldInExpression fieldIn = new FieldInExpression(fieldName, literalValues);
LOG.debug("End visit field in: " + ctx.getText());
return fieldIn;
}