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

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

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

Parser.getErrorListeners介绍

暂无

代码示例

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

@Override
public ParserErrorListener getErrorListenerDispatch() {
  return new ProxyParserErrorListener(getErrorListeners());
}

代码示例来源:origin: antlr/intellij-plugin-v4

public AstBuilderListener(Language language, Parser parser, PsiBuilder builder) {
  this.language = language;
  this.builder = builder;
  this.tokenElementTypes = PSIElementTypeFactory.getTokenIElementTypes(language, Arrays.asList(parser.getTokenNames()));
  this.ruleElementTypes = PSIElementTypeFactory.getRuleIElementTypes(language, Arrays.asList(parser.getRuleNames()));
  for (ANTLRErrorListener listener : parser.getErrorListeners()) {
    if (listener instanceof SyntaxErrorListener) {
      syntaxErrors.addAll(((SyntaxErrorListener)listener).getSyntaxErrors());
    }
  }
  Collections.sort(syntaxErrors, new Comparator<SyntaxError>() {
    @Override
    public int compare(SyntaxError o1, SyntaxError o2) {
      return Integer.valueOf(getStart(o1)).compareTo(getStart(o2));
    }
  });
}

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

public ANTLRParseTreeToPSIConverter(Language language, Parser parser, PsiBuilder builder) {
  this.language = language;
  this.builder = builder;
  this.tokenElementTypes = PSIElementTypeFactory.getTokenIElementTypes(language);
  this.ruleElementTypes = PSIElementTypeFactory.getRuleIElementTypes(language);
  for (ANTLRErrorListener listener : parser.getErrorListeners()) {
    if (listener instanceof SyntaxErrorListener) {
      syntaxErrors = ((SyntaxErrorListener)listener).getSyntaxErrors();
      for (SyntaxError error : syntaxErrors) {
        // record first error per token
        int StartIndex = error.getOffendingSymbol().getStartIndex();
        if ( !tokenToErrorMap.containsKey(StartIndex) ) {
          tokenToErrorMap.put(StartIndex, error);
        }
      }
    }
  }
}

相关文章