本文整理了Java中org.antlr.v4.runtime.Parser.getErrorListeners()
方法的一些代码示例,展示了Parser.getErrorListeners()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.getErrorListeners()
方法的具体详情如下:
包路径:org.antlr.v4.runtime.Parser
类名称: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);
}
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!