org.antlr.v4.runtime.Parser.addErrorListener()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(236)

本文整理了Java中org.antlr.v4.runtime.Parser.addErrorListener()方法的一些代码示例,展示了Parser.addErrorListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.addErrorListener()方法的具体详情如下:
包路径:org.antlr.v4.runtime.Parser
类名称:Parser
方法名:addErrorListener

Parser.addErrorListener介绍

暂无

代码示例

代码示例来源:origin: debezium/debezium

@Override
public void parse(String ddlContent, Tables databaseTables) {
  this.databaseTables = databaseTables;
  CodePointCharStream ddlContentCharStream = CharStreams.fromString(ddlContent);
  L lexer = createNewLexerInstance(new CaseChangingCharStream(ddlContentCharStream, isGrammarInUpperCase()));
  P parser = createNewParserInstance(new CommonTokenStream(lexer));
  dataTypeResolver = initializeDataTypeResolver();
  // remove default console output printing error listener
  parser.removeErrorListener(ConsoleErrorListener.INSTANCE);
  ParsingErrorListener parsingErrorListener = new ParsingErrorListener(AbstractDdlParser::accumulateParsingFailure);
  parser.addErrorListener(parsingErrorListener);
  ParseTree parseTree = parseTree(parser);
  if (parsingErrorListener.getErrors().isEmpty()) {
    antlrDdlParserListener = createParseTreeWalkerListener();
    if (antlrDdlParserListener != null) {
      ParseTreeWalker.DEFAULT.walk(antlrDdlParserListener, parseTree);
      if (throwErrorsFromTreeWalk && !antlrDdlParserListener.getErrors().isEmpty()) {
        throwParsingException(antlrDdlParserListener.getErrors());
      }
    }
  }
  else {
    throwParsingException(parsingErrorListener.getErrors());
  }
}

代码示例来源:origin: theonedev/onedev

parser.addErrorListener(new BaseErrorListener() {

代码示例来源:origin: org.opendaylight.yangtools/yang-parser-rfc7950

/**
   * Use a Lexer/Parser pair extracting the parser's root item.
   *
   * @param lexer lexer to use
   * @param parser parser to use
   * @param parseMethod Root item extractor method
   * @param ref Source reference
   * @return Parsed item
   * @throws NullPointerException if any argument is null
   * @throws SourceException if a parser error occurs
   */
  public static <T> T parse(final Lexer lexer, final Parser parser, final Supplier<T> parseMethod,
      final StatementSourceReference ref) {
    final Listener listener = new Listener(ref);
    lexer.removeErrorListeners();
    lexer.addErrorListener(listener);
    parser.removeErrorListeners();
    parser.addErrorListener(listener);

    final T ret = parseMethod.get();
    listener.validate();
    return ret;
  }
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

parser.addErrorListener(new DiagnosticErrorListener());
parser.getInterpreter().setPredictionMode(PredictionMode.LL_EXACT_AMBIG_DETECTION);

代码示例来源:origin: com.github.julianthome/inmemantlr-api

parser.addErrorListener(el);
parser.getInterpreter().setPredictionMode(PredictionMode.LL_EXACT_AMBIG_DETECTION);
parser.setBuildParseTree(true);

代码示例来源:origin: uk.co.nichesolutions/antlr4

parser.addErrorListener(new DiagnosticErrorListener());
parser.getInterpreter().setPredictionMode(PredictionMode.LL_EXACT_AMBIG_DETECTION);

代码示例来源:origin: org.antlr/antlr4

parser.addErrorListener(new DiagnosticErrorListener());
parser.getInterpreter().setPredictionMode(PredictionMode.LL_EXACT_AMBIG_DETECTION);

代码示例来源:origin: com.tunnelvisionlabs/antlr4

parser.addErrorListener(new DiagnosticErrorListener());
parser.getInterpreter().setPredictionMode(PredictionMode.LL_EXACT_AMBIG_DETECTION);

代码示例来源:origin: io.virtdata/virtdata-lib-realer

parser.addErrorListener(new DiagnosticErrorListener());
parser.getInterpreter().setPredictionMode(PredictionMode.LL_EXACT_AMBIG_DETECTION);

代码示例来源:origin: io.debezium/debezium-ddl-parser

@Override
public void parse(String ddlContent, Tables databaseTables) {
  this.databaseTables = databaseTables;
  CodePointCharStream ddlContentCharStream = CharStreams.fromString(ddlContent);
  L lexer = createNewLexerInstance(new CaseChangingCharStream(ddlContentCharStream, isGrammarInUpperCase()));
  P parser = createNewParserInstance(new CommonTokenStream(lexer));
  dataTypeResolver = initializeDataTypeResolver();
  // remove default console output printing error listener
  parser.removeErrorListener(ConsoleErrorListener.INSTANCE);
  ParsingErrorListener parsingErrorListener = new ParsingErrorListener(AbstractDdlParser::accumulateParsingFailure);
  parser.addErrorListener(parsingErrorListener);
  ParseTree parseTree = parseTree(parser);
  if (parsingErrorListener.getErrors().isEmpty()) {
    antlrDdlParserListener = createParseTreeWalkerListener();
    if (antlrDdlParserListener != null) {
      ParseTreeWalker.DEFAULT.walk(antlrDdlParserListener, parseTree);
      if (throwErrorsFromTreeWalk && !antlrDdlParserListener.getErrors().isEmpty()) {
        throwParsingException(antlrDdlParserListener.getErrors());
      }
    }
  }
  else {
    throwParsingException(parsingErrorListener.getErrors());
  }
}

代码示例来源:origin: antlr/codebuff

doc.parser.addErrorListener(
  new ANTLRErrorListener() {
    @Override

代码示例来源:origin: antlr/antlr4-intellij-adaptor

parser.setErrorHandler(new ErrorStrategyAdaptor()); // tweaks missing tokens
parser.removeErrorListeners();
parser.addErrorListener(new SyntaxErrorListener()); // trap errors
ParseTree parseTree = null;
PsiBuilder.Marker rollbackMarker = builder.mark();

代码示例来源:origin: org.bitbucket.goalhub.grammar/languageTools

parser.addErrorListener(this);

代码示例来源:origin: com.bitplan.antlr/com.bitplan.antlr

lexer.addErrorListener(errorListener);
parser.removeErrorListeners();
parser.addErrorListener(errorListener);
switch (parserMode) {
case LL_ONLY:

相关文章