本文整理了Java中org.antlr.v4.runtime.Parser.getSourceName()
方法的一些代码示例,展示了Parser.getSourceName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.getSourceName()
方法的具体详情如下:
包路径:org.antlr.v4.runtime.Parser
类名称:Parser
方法名:getSourceName
暂无
代码示例来源:origin: co.cask.re/dre-core
@Override
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine,
String msg, RecognitionException e) {
Parser parser = (Parser) recognizer;
String name = parser.getSourceName();
TokenStream tokens = parser.getInputStream();
Token offSymbol = (Token) offendingSymbol;
int thisError = offSymbol.getTokenIndex();
String source = "<unknown>";
if (offSymbol != null) {
String charstream = offSymbol.getTokenSource().getInputStream().toString();
String[] lines = charstream.split("\n");
source = lines[line - 1];
}
if (offSymbol.getType() == -1 && thisError == tokens.size() - 1) {
if (e != null) {
if (e instanceof NoViableAltException) {
msg = "unexpected token found '" + ((NoViableAltException) e).getStartToken().getText() + "'";
}
}
String message = "At line " + line + ":" + charPositionInLine + ": " + msg;
errors.add(new SyntaxError(line, charPositionInLine, message, source));
return;
}
String offSymName = RulebookLexer.VOCABULARY.getDisplayName(offSymbol.getType());
String message = "At line " + line + ":" + charPositionInLine + " at " + offSymName.toLowerCase() + ": " + msg;
lastError = thisError;
errors.add(new SyntaxError(line, charPositionInLine, message, source));
}
代码示例来源:origin: co.cask.wrangler/wrangler-core
String name = parser.getSourceName();
TokenStream tokens = parser.getInputStream();
内容来源于网络,如有侵权,请联系作者删除!