org.antlr.v4.runtime.tree.ErrorNode Java Examples

The following examples show how to use org.antlr.v4.runtime.tree.ErrorNode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PaloAltoConfigurationBuilder.java    From batfish with Apache License 2.0 6 votes vote down vote up
@Override
public void visitErrorNode(ErrorNode errorNode) {
  Token token = errorNode.getSymbol();
  String lineText = getText(errorNode).replace("\n", "").replace("\r", "").trim();
  int line = getLine(token);
  _mainConfiguration.setUnrecognized(true);

  if (token instanceof UnrecognizedLineToken) {
    UnrecognizedLineToken unrecToken = (UnrecognizedLineToken) token;
    _w.getParseWarnings()
        .add(
            new ParseWarning(
                line, lineText, unrecToken.getParserContext(), "This syntax is unrecognized"));
  } else {
    String msg = String.format("Unrecognized Line: %d: %s", line, lineText);
    _w.redFlag(msg + " SUBSEQUENT LINES MAY NOT BE PROCESSED CORRECTLY");
  }
}
 
Example #2
Source File: CumulusInterfacesConfigurationBuilder.java    From batfish with Apache License 2.0 6 votes vote down vote up
@Override
public void visitErrorNode(ErrorNode errorNode) {
  Token token = errorNode.getSymbol();
  int line = token.getLine();
  String lineText = errorNode.getText().replace("\n", "").replace("\r", "").trim();
  _config.setUnrecognized(true);

  if (token instanceof UnrecognizedLineToken) {
    UnrecognizedLineToken unrecToken = (UnrecognizedLineToken) token;
    _w.getParseWarnings()
        .add(
            new ParseWarning(
                line, lineText, unrecToken.getParserContext(), "This syntax is unrecognized"));
  } else {
    String msg = String.format("Unrecognized Line: %d: %s", line, lineText);
    _w.redFlag(msg + " SUBSEQUENT LINES MAY NOT BE PROCESSED CORRECTLY");
  }
}
 
Example #3
Source File: CumulusFrrConfigurationBuilder.java    From batfish with Apache License 2.0 6 votes vote down vote up
@Override
public void visitErrorNode(ErrorNode errorNode) {
  Token token = errorNode.getSymbol();
  int line = token.getLine();
  String lineText = errorNode.getText().replace("\n", "").replace("\r", "").trim();
  _c.setUnrecognized(true);

  if (token instanceof UnrecognizedLineToken) {
    UnrecognizedLineToken unrecToken = (UnrecognizedLineToken) token;
    _w.getParseWarnings()
        .add(
            new ParseWarning(
                line, lineText, unrecToken.getParserContext(), "This syntax is unrecognized"));
  } else {
    String msg = String.format("Unrecognized Line: %d: %s", line, lineText);
    _w.redFlag(msg + " SUBSEQUENT LINES MAY NOT BE PROCESSED CORRECTLY");
  }
}
 
Example #4
Source File: CumulusPortsConfigurationBuilder.java    From batfish with Apache License 2.0 6 votes vote down vote up
@Override
public void visitErrorNode(ErrorNode errorNode) {
  Token token = errorNode.getSymbol();
  int line = token.getLine();
  String lineText = errorNode.getText().replace("\n", "").replace("\r", "").trim();
  _config.setUnrecognized(true);

  if (token instanceof UnrecognizedLineToken) {
    UnrecognizedLineToken unrecToken = (UnrecognizedLineToken) token;
    _w.getParseWarnings()
        .add(
            new ParseWarning(
                line, lineText, unrecToken.getParserContext(), "This syntax is unrecognized"));
  } else {
    String msg = String.format("Unrecognized Line: %d: %s", line, lineText);
    _w.redFlag(msg + " SUBSEQUENT LINES MAY NOT BE PROCESSED CORRECTLY");
  }
}
 
Example #5
Source File: CumulusNcluConfigurationBuilder.java    From batfish with Apache License 2.0 6 votes vote down vote up
@Override
public void visitErrorNode(ErrorNode errorNode) {
  Token token = errorNode.getSymbol();
  int line = token.getLine();
  String lineText = errorNode.getText().replace("\n", "").replace("\r", "").trim();

  if (token instanceof UnrecognizedLineToken) {
    UnrecognizedLineToken unrecToken = (UnrecognizedLineToken) token;
    ParseWarning warning =
        new ParseWarning(
            line, lineText, unrecToken.getParserContext(), "This syntax is unrecognized");
    unrecognized(warning, null);
  } else {
    String msg = String.format("Unrecognized Line: %d: %s", line, lineText);
    _w.redFlag(msg + " Subsequent lines may not be processed correctly");
  }
}
 
Example #6
Source File: F5BigipImishConfigurationBuilder.java    From batfish with Apache License 2.0 6 votes vote down vote up
@Override
public void visitErrorNode(ErrorNode errorNode) {
  Token token = errorNode.getSymbol();
  int line = token.getLine();
  String lineText = errorNode.getText().replace("\n", "").replace("\r", "").trim();
  _c.setUnrecognized(true);

  if (token instanceof UnrecognizedLineToken) {
    UnrecognizedLineToken unrecToken = (UnrecognizedLineToken) token;
    _w.getParseWarnings()
        .add(
            new ParseWarning(
                line, lineText, unrecToken.getParserContext(), "This syntax is unrecognized"));
  } else {
    String msg = String.format("Unrecognized Line: %d: %s", line, lineText);
    _w.redFlag(msg + " SUBSEQUENT LINES MAY NOT BE PROCESSED CORRECTLY");
  }
}
 
Example #7
Source File: BatfishANTLRErrorStrategy.java    From batfish with Apache License 2.0 6 votes vote down vote up
/**
 * Create an error node with the text of the current line and insert it into parse tree
 *
 * @param recognizer The recognizer with which to create the error node
 * @param separator The token that ends the unrecognized link. This is also used to determine the
 *     index of the line to return in error messages.
 * @return The token contained in the error node
 */
private Token createErrorNode(Parser recognizer, ParserRuleContext ctx, Token separator) {
  if (_recoveredAtEof) {
    _recoveredAtEof = false;
    throw new BatfishRecognitionException(recognizer, recognizer.getInputStream(), ctx);
  }
  if (separator.getType() == Lexer.EOF) {
    _recoveredAtEof = true;
  }
  String lineText = _lines[separator.getLine() - 1] + separator.getText();
  Token lineToken =
      new UnrecognizedLineToken(lineText, separator.getLine(), _parserStateAtRecovery);
  ErrorNode errorNode = recognizer.createErrorNode(ctx, lineToken);
  ctx.addErrorNode(errorNode);
  return lineToken;
}
 
Example #8
Source File: CypherCstToAstVisitor.java    From vertexium with Apache License 2.0 5 votes vote down vote up
@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()
    ));
}
 
Example #9
Source File: IndexRQL.java    From indexr with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #10
Source File: SQLParserExecutor.java    From shardingsphere with Apache License 2.0 5 votes vote down vote up
/**
 * Execute to parse SQL.
 *
 * @return AST node
 */
public ParseASTNode execute() {
    ParseASTNode result = twoPhaseParse();
    if (result.getRootNode() instanceof ErrorNode) {
        throw new SQLParsingException(String.format("Unsupported SQL of `%s`", sql));
    }
    return result;
}
 
Example #11
Source File: ExpressionTagQueryParser.java    From hawkular-alerts with Apache License 2.0 5 votes vote down vote up
@Override
public void visitErrorNode(ErrorNode node) {
    if (error) {
        errorMsg = "Error " + errorMsg + " on node " + node.getText();
    } else {
        errorMsg = "Error on node " + node.getText();
        error = true;
    }
}
 
Example #12
Source File: RecoveryExtractor.java    From batfish with Apache License 2.0 5 votes vote down vote up
@Override
public void visitErrorNode(ErrorNode node) {
  if (_firstErrorLine == 0) {
    _firstErrorLine = node.getSymbol().getLine();
  }
  _numErrorNodes++;
}
 
Example #13
Source File: TypeScriptAssert.java    From doov with Apache License 2.0 4 votes vote down vote up
public ListAssert<ErrorNode> errors() {
    return new ListAssert<>(this.actual.getErrors());
}
 
Example #14
Source File: FlatJuniperRecoveryExtractor.java    From batfish with Apache License 2.0 4 votes vote down vote up
@Override
public void visitErrorNode(ErrorNode node) {
  _numErrorNodes++;
}
 
Example #15
Source File: ElasticSearchVisitor.java    From elasticsearch-jdbc with MIT License 4 votes vote down vote up
@Override
public ParserResult visitErrorNode(ErrorNode node) {
    throw new UnsupportedOperationException("Error would be thrown by ThrowingExceptionErrorStrategy");
}
 
Example #16
Source File: YangStatementStreamSource.java    From yangtools with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void visitErrorNode(final ErrorNode node) {
    // No-op
}
 
Example #17
Source File: CollectTokenPairs.java    From codebuff with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void visitErrorNode(ErrorNode node) { }
 
Example #18
Source File: CollectSiblingLists.java    From codebuff with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void visitErrorNode(ErrorNode node) {
}
 
Example #19
Source File: VisitSiblingLists.java    From codebuff with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void visitErrorNode(ErrorNode node) {
}
 
Example #20
Source File: LocalDateVisitor.java    From incubator-tuweni with Apache License 2.0 4 votes vote down vote up
@Override
public LocalDate visitErrorNode(ErrorNode node) {
  return null;
}
 
Example #21
Source File: AstListener.java    From indexr with Apache License 2.0 4 votes vote down vote up
@Override
public void visitErrorNode(@NotNull ErrorNode node) {
    super.visitErrorNode(node);
}
 
Example #22
Source File: LocalDateVisitor.java    From cava with Apache License 2.0 4 votes vote down vote up
@Override
public LocalDate visitErrorNode(ErrorNode node) {
  return null;
}
 
Example #23
Source File: EagleQueryFilterListenerImpl.java    From eagle with Apache License 2.0 4 votes vote down vote up
public void visitErrorNode(ErrorNode node) {
}
 
Example #24
Source File: ExpressionCompiler.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
@Override
public void visitErrorNode(ErrorNode node) {
   logger.debug("Error parsing expression {}", node);
   errors.append("\n\t").append(node);
}
 
Example #25
Source File: JplagPython3Listener.java    From jplag with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void visitErrorNode(@NotNull ErrorNode node) {
}
 
Example #26
Source File: DebugPassListener.java    From trygve with GNU General Public License v2.0 4 votes vote down vote up
@Override public void visitErrorNode(final ErrorNode n){
    tab();
    System.err.print("E ");
    System.err.println(n.getText());
}
 
Example #27
Source File: ASTBuilder.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
@Override
public void visitErrorNode(ErrorNode node) {
}
 
Example #28
Source File: LocalTimeVisitor.java    From incubator-tuweni with Apache License 2.0 4 votes vote down vote up
@Override
public LocalTime visitErrorNode(ErrorNode node) {
  return null;
}
 
Example #29
Source File: ZoneOffsetVisitor.java    From incubator-tuweni with Apache License 2.0 4 votes vote down vote up
@Override
public ZoneOffset visitErrorNode(ErrorNode node) {
  return null;
}
 
Example #30
Source File: LocalTimeVisitor.java    From cava with Apache License 2.0 4 votes vote down vote up
@Override
public LocalTime visitErrorNode(ErrorNode node) {
  return null;
}