本文整理了Java中org.antlr.runtime.Parser.getErrorMessage()
方法的一些代码示例,展示了Parser.getErrorMessage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.getErrorMessage()
方法的具体详情如下:
包路径:org.antlr.runtime.Parser
类名称:Parser
方法名:getErrorMessage
暂无
代码示例来源:origin: JesusFreke/smali
public String getErrorMessage(RecognitionException e,
String[] tokenNames) {
if (verboseErrors) {
List stack = getRuleInvocationStack(e, this.getClass().getName());
String msg = null;
if (e instanceof NoViableAltException) {
NoViableAltException nvae = (NoViableAltException)e;
msg = " no viable alt; token="+getTokenErrorDisplay(e.token)+
" (decision="+nvae.decisionNumber+
" state "+nvae.stateNumber+")"+
" decision=<<"+nvae.grammarDecisionDescription+">>";
} else {
msg = super.getErrorMessage(e, tokenNames);
}
return stack + " " + msg;
} else {
return super.getErrorMessage(e, tokenNames);
}
}
代码示例来源:origin: apache/phoenix
@Override
public String getErrorMessage(RecognitionException e, String[] tokenNames) {
if (e instanceof MismatchedTokenException) {
MismatchedTokenException mte = (MismatchedTokenException)e;
String txt = mte.token.getText();
String p = mte.token.getType() == -1 ? "EOF" : PARAPHRASE[mte.token.getType()];
String expecting = (mte.expecting < PARAPHRASE.length && mte.expecting >= 0) ? PARAPHRASE[mte.expecting] : null;
if (expecting == null) {
return "unexpected token (" + line(mte.token) + "," + column(mte.token) + "): " + (txt != null ? txt : p);
} else {
return "expecting " + expecting +
", found '" + (txt != null ? txt : p) + "'";
}
} else if (e instanceof NoViableAltException) {
//NoViableAltException nvae = (NoViableAltException)e;
return "unexpected token: (" + line(e.token) + "," + column(e.token) + ")" + getTokenErrorDisplay(e.token);
}
return super.getErrorMessage(e, tokenNames);
}
代码示例来源:origin: forcedotcom/phoenix
@Override
public String getErrorMessage(RecognitionException e, String[] tokenNames) {
if (e instanceof MismatchedTokenException) {
MismatchedTokenException mte = (MismatchedTokenException)e;
String txt = mte.token.getText();
String p = mte.token.getType() == -1 ? "EOF" : PARAPHRASE[mte.token.getType()];
String expecting = (mte.expecting < PARAPHRASE.length && mte.expecting >= 0) ? PARAPHRASE[mte.expecting] : null;
if (expecting == null) {
return "unexpected token (" + line(mte.token) + "," + column(mte.token) + "): " + (txt != null ? txt : p);
} else {
return "expecting " + expecting +
", found '" + (txt != null ? txt : p) + "'";
}
} else if (e instanceof NoViableAltException) {
//NoViableAltException nvae = (NoViableAltException)e;
return "unexpected token: (" + line(e.token) + "," + column(e.token) + ")" + getTokenErrorDisplay(e.token);
}
return super.getErrorMessage(e, tokenNames);
}
代码示例来源:origin: org.eclipse/xtext
protected String superGetErrorMessage(RecognitionException e, String[] tokenNames) {
return super.getErrorMessage(e, tokenNames);
}
代码示例来源:origin: zinniasystems/Nectar
public String getErrorMessage(RecognitionException e,
String[] tokenNames)
{
String msg = super.getErrorMessage(e, tokenNames);
if ( paraphrases.size()>0 ) {
String paraphrase = (String)paraphrases.peek();
msg = msg+" "+paraphrase;
}
return msg;
}
代码示例来源:origin: org.ceylon-lang/com.redhat.ceylon.typechecker
@Override
public String getMessage() {
String message = parser.getErrorMessage(recognitionException, tokenNames)
.replace("'<EOF>'", "end of file")
.replace("input", "token")
.replace("missing null", "error");
String result = "incorrect syntax: " + message;
if (expecting!=-1 && !result.contains("expecting")) {
result += " expecting " + tokenNames[expecting];
}
return result;
}
代码示例来源:origin: org.kuali.student.common/ks-common-util
@Override
public String getErrorMessage(RecognitionException e, String[] tokenNames) {
List<?> stack = getRuleInvocationStack(e, this.getClass().getName());
String msg = null;
if ( e instanceof NoViableAltException ) {
NoViableAltException nvae = (NoViableAltException)e;
msg = " No viable alternatives; token=" + e.token
+ " (decision=" + nvae.decisionNumber
+ " state " + nvae.stateNumber+")"
+ " decision=<<" + nvae.grammarDecisionDescription + ">>";
}
else {
msg = super.getErrorMessage(e, tokenNames);
}
return stack + " " + msg;
}
代码示例来源:origin: net.rapture/Reflex
public String getErrorMessage(RecognitionException e, String[] tokenNames) {
List stack = getRuleInvocationStack(e, this.getClass().getName());
String msg = null;
if ( e instanceof NoViableAltException ) {
NoViableAltException nvae = (NoViableAltException)e;
msg = " no viable alt; token="+e.token+
" (decision="+nvae.decisionNumber+
" state "+nvae.stateNumber+")"+
" decision=<<"+nvae.grammarDecisionDescription+">>";
}
else {
msg = super.getErrorMessage(e, tokenNames);
}
return stack+" "+msg;
}
代码示例来源:origin: org.kuali.student.core/ks-common-util
@Override
public String getErrorMessage(RecognitionException e, String[] tokenNames) {
List<?> stack = getRuleInvocationStack(e, this.getClass().getName());
String msg = null;
if ( e instanceof NoViableAltException ) {
NoViableAltException nvae = (NoViableAltException)e;
msg = " No viable alternatives; token=" + e.token
+ " (decision=" + nvae.decisionNumber
+ " state " + nvae.stateNumber+")"
+ " decision=<<" + nvae.grammarDecisionDescription + ">>";
}
else {
msg = super.getErrorMessage(e, tokenNames);
}
return stack + " " + msg;
}
代码示例来源:origin: net.rapture/RaptureCore
public String getErrorMessage(RecognitionException e,
String[] tokenNames)
{
List stack = getRuleInvocationStack(e, this.getClass().getName());
String msg = null;
if ( e instanceof NoViableAltException ) {
NoViableAltException nvae = (NoViableAltException)e;
msg = " no viable alt; token="+e.token+
" (decision="+nvae.decisionNumber+
" state "+nvae.stateNumber+")"+
" decision=<<"+nvae.grammarDecisionDescription+">>";
}
else {
msg = super.getErrorMessage(e, tokenNames);
}
return stack+" "+msg;
}
public String getTokenErrorDisplay(Token t) { return t.toString();
代码示例来源:origin: org.aksw.sparqlify/obda-api-sml
public String getErrorMessage(RecognitionException e, String[] tokenNames)
{
List stack = getRuleInvocationStack(e, this.getClass().getName());
String msg = null;
if ( e instanceof NoViableAltException ) {
NoViableAltException nvae = (NoViableAltException)e;
msg = " no viable alt; token="+e.token+
" (decision="+nvae.decisionNumber+
" state "+nvae.stateNumber+")"+
" decision=<<"+nvae.grammarDecisionDescription+">>";
}
else if( e instanceof FailedPredicateException ) {
FailedPredicateException fpe = (FailedPredicateException)e;
msg = "failed predicate; token="+fpe.token+
" (rule="+fpe.ruleName+" predicate="+fpe.predicateText+")";
}
else {
msg = super.getErrorMessage(e, tokenNames);
}
return stack+" "+msg;
}
public String getTokenErrorDisplay(Token t) {
代码示例来源:origin: KB5201314/ZjDroid
public String getErrorMessage(RecognitionException e,
String[] tokenNames) {
if (verboseErrors) {
List stack = getRuleInvocationStack(e, this.getClass().getName());
String msg = null;
if (e instanceof NoViableAltException) {
NoViableAltException nvae = (NoViableAltException)e;
msg = " no viable alt; token="+getTokenErrorDisplay(e.token)+
" (decision="+nvae.decisionNumber+
" state "+nvae.stateNumber+")"+
" decision=<<"+nvae.grammarDecisionDescription+">>";
} else {
msg = super.getErrorMessage(e, tokenNames);
}
return stack + " " + msg;
} else {
return super.getErrorMessage(e, tokenNames);
}
}
代码示例来源:origin: org.antlr/antlr4
public String getParserErrorMessage(Parser parser, RecognitionException e) {
String msg;
if ( e instanceof NoViableAltException) {
String name = parser.getTokenErrorDisplay(e.token);
msg = name+" came as a complete surprise to me";
}
else if ( e instanceof v4ParserException) {
msg = ((v4ParserException)e).msg;
}
else {
msg = parser.getErrorMessage(e, parser.getTokenNames());
}
return msg;
}
代码示例来源:origin: uk.co.nichesolutions/antlr4
public String getParserErrorMessage(Parser parser, RecognitionException e) {
String msg;
if ( e instanceof NoViableAltException) {
String name = parser.getTokenErrorDisplay(e.token);
msg = name+" came as a complete surprise to me";
}
else if ( e instanceof v4ParserException) {
msg = ((v4ParserException)e).msg;
}
else {
msg = parser.getErrorMessage(e, parser.getTokenNames());
}
return msg;
}
代码示例来源:origin: com.tunnelvisionlabs/antlr4
public String getParserErrorMessage(Parser parser, RecognitionException e) {
String msg;
if ( e instanceof NoViableAltException) {
String name = parser.getTokenErrorDisplay(e.token);
msg = name+" came as a complete surprise to me";
}
else if ( e instanceof v4ParserException) {
msg = ((v4ParserException)e).msg;
}
else {
msg = parser.getErrorMessage(e, parser.getTokenNames());
}
return msg;
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
public String getParserErrorMessage(Parser parser, RecognitionException e) {
String msg;
if ( e instanceof NoViableAltException) {
String name = parser.getTokenErrorDisplay(e.token);
msg = name+" came as a complete surprise to me";
}
else if ( e instanceof v4ParserException) {
msg = ((v4ParserException)e).msg;
}
else {
msg = parser.getErrorMessage(e, parser.getTokenNames());
}
return msg;
}
代码示例来源:origin: io.virtdata/virtdata-lib-realer
public String getParserErrorMessage(Parser parser, RecognitionException e) {
String msg;
if ( e instanceof NoViableAltException) {
String name = parser.getTokenErrorDisplay(e.token);
msg = name+" came as a complete surprise to me";
}
else if ( e instanceof v4ParserException) {
msg = ((v4ParserException)e).msg;
}
else {
msg = parser.getErrorMessage(e, parser.getTokenNames());
}
return msg;
}
代码示例来源:origin: nativelibs4java/JNAerator
@Override
public String getErrorMessage(RecognitionException e, String[] tokenNames) {
if (e instanceof NoViableAltException) {
NoViableAltException ne = (NoViableAltException)e;
checkInterrupt();
return "Failed to match any alternative with token " + ne.token + "\n\t" +
" File: " + getFile() + ":" + (ne.line + sourceLineDelta) + "\n\t" +
"Input: " + getSurroundings(ne.token, 5).replace('\n', ' ') + "\n\t" +
" Rule: " + ne.grammarDecisionDescription + "\n\t" +
"Stack: " + getRuleInvocationStack(e, getClass().getName()) + "\n";
} else
return super.getErrorMessage(e, tokenNames);
}
@Override
代码示例来源:origin: com.github.sommeri/less4j
@Override
public String getErrorMessage(RecognitionException e, String[] tokenNames) {
String result = "" + super.getErrorMessage(e, tokenNames);
if (!paraphrases.isEmpty()) {
EnterRuleInfo info = paraphrases.peek();
String position = info.getStart().getLine() + ":" + (info.getStart().getCharPositionInLine() + 1);
result = result + " in " + info.getRulename() + " (which started at " + position + ")";
}
return result;
}
代码示例来源:origin: org.apache.phoenix/phoenix-core
@Override
public String getErrorMessage(RecognitionException e, String[] tokenNames) {
if (e instanceof MismatchedTokenException) {
MismatchedTokenException mte = (MismatchedTokenException)e;
String txt = mte.token.getText();
String p = mte.token.getType() == -1 ? "EOF" : PARAPHRASE[mte.token.getType()];
String expecting = (mte.expecting < PARAPHRASE.length && mte.expecting >= 0) ? PARAPHRASE[mte.expecting] : null;
if (expecting == null) {
return "unexpected token (" + line(mte.token) + "," + column(mte.token) + "): " + (txt != null ? txt : p);
} else {
return "expecting " + expecting +
", found '" + (txt != null ? txt : p) + "'";
}
} else if (e instanceof NoViableAltException) {
//NoViableAltException nvae = (NoViableAltException)e;
return "unexpected token: (" + line(e.token) + "," + column(e.token) + ")" + getTokenErrorDisplay(e.token);
}
return super.getErrorMessage(e, tokenNames);
}
内容来源于网络,如有侵权,请联系作者删除!