Java Code Examples for org.antlr.v4.runtime.misc.IntervalSet#toString()
The following examples show how to use
org.antlr.v4.runtime.misc.IntervalSet#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BeetlAntlrErrorStrategy.java From beetl2.0 with BSD 3-Clause "New" or "Revised" License | 6 votes |
protected void reportUnwantedToken(@NotNull Parser recognizer) { if (inErrorRecoveryMode(recognizer)) { return; } beginErrorCondition(recognizer); Token t = recognizer.getCurrentToken(); String tokenName = getTokenErrorDisplay(t); IntervalSet expecting = getExpectedTokens(recognizer); String msg = "多余输入 " + tokenName + " 期望 " + expecting.toString(recognizer.getTokenNames()); BeetlException exception = new BeetlParserException(BeetlException.PARSER_MISS_ERROR, msg); // exception.token = this.getGrammarToken(t); exception.pushToken(this.getGrammarToken(t)); throw exception; }
Example 2
Source File: KsqlParserErrorStrategy.java From ksql-fork-with-deep-learning-function with Apache License 2.0 | 5 votes |
protected void reportUnwantedToken(Parser recognizer) { if (!this.inErrorRecoveryMode(recognizer)) { this.beginErrorCondition(recognizer); Token t = recognizer.getCurrentToken(); String tokenName = this.getTokenErrorDisplay(t); IntervalSet expecting = this.getExpectedTokens(recognizer); String msg = "extraneous input " + tokenName + " expecting " + expecting.toString(recognizer.getVocabulary()); recognizer.notifyErrorListeners(t, msg, (RecognitionException) null); } }
Example 3
Source File: KsqlParserErrorStrategy.java From ksql-fork-with-deep-learning-function with Apache License 2.0 | 5 votes |
protected void reportMissingToken(Parser recognizer) { if (!this.inErrorRecoveryMode(recognizer)) { this.beginErrorCondition(recognizer); Token t = recognizer.getCurrentToken(); IntervalSet expecting = this.getExpectedTokens(recognizer); String msg = "missing " + expecting.toString(recognizer.getVocabulary()) + " at " + this .getTokenErrorDisplay(t); recognizer.notifyErrorListeners(t, msg, (RecognitionException) null); } }
Example 4
Source File: ExpressionInterpreter.java From arma-dialog-creator with MIT License | 5 votes |
@Override public void reportMissingToken(Parser recognizer) { beginErrorCondition(recognizer); Token t = recognizer.getCurrentToken(); IntervalSet expecting = getExpectedTokens(recognizer); String msg = "missing " + expecting.toString(recognizer.getTokenNames()) + " at " + getTokenErrorDisplay(t); throw new RecognitionException(msg, recognizer, recognizer.getInputStream(), recognizer.getContext()); }
Example 5
Source File: BeetlAntlrErrorStrategy.java From beetl2.0 with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected void reportMissingToken(@NotNull Parser recognizer) { if (inErrorRecoveryMode(recognizer)) { return; } beginErrorCondition(recognizer); // Token t = recognizer.getCurrentToken(); Token t = recognizer.getTokenStream().LT(-1); IntervalSet expecting = getExpectedTokens(recognizer); String expect = expecting.toString(recognizer.getTokenNames()); if(expects.containsKey(expect)){ expect = expects.get(expect); } if(expect.equals("'>>'")){ expect = "'模板的占位结束符号'"; } String tokenStr = getTokenErrorDisplay(t); String msg = null; if(expect.equals("'}'")&&tokenStr.equals("'>>'")) { msg = "试图在第"+t.getLine()+"行未找到 '{' 匹配的结束符号 '}'"; }else { //常规情况 msg = "缺少输入 " + expect + " 在 " + tokenStr+" 后面"; } BeetlException exception = new BeetlParserException(BeetlException.PARSER_MISS_ERROR, msg); exception.pushToken(this.getGrammarToken(t)); throw exception; }