forked from jasder/antlr
found 2 cases that called function on empty set.
This commit is contained in:
parent
6572b08095
commit
d9d21fe9b3
|
@ -548,7 +548,10 @@ public class DefaultErrorStrategy implements ANTLRErrorStrategy {
|
|||
protected Token getMissingSymbol(Parser recognizer) {
|
||||
Token currentSymbol = recognizer.getCurrentToken();
|
||||
IntervalSet expecting = getExpectedTokens(recognizer);
|
||||
int expectedTokenType = expecting.getMinElement(); // get any element
|
||||
int expectedTokenType = Token.INVALID_TYPE;
|
||||
if ( !expecting.isNil() ) {
|
||||
expectedTokenType = expecting.getMinElement(); // get any element
|
||||
}
|
||||
String tokenText;
|
||||
if ( expectedTokenType== Token.EOF ) tokenText = "<missing EOF>";
|
||||
else tokenText = "<missing "+recognizer.getVocabulary().getDisplayName(expectedTokenType)+">";
|
||||
|
|
|
@ -407,7 +407,10 @@ public class ParserInterpreter extends Parser {
|
|||
if ( e instanceof InputMismatchException ) {
|
||||
InputMismatchException ime = (InputMismatchException)e;
|
||||
Token tok = e.getOffendingToken();
|
||||
int expectedTokenType = ime.getExpectedTokens().getMinElement(); // get any element
|
||||
int expectedTokenType = Token.INVALID_TYPE;
|
||||
if ( !ime.getExpectedTokens().isNil() ) {
|
||||
expectedTokenType = ime.getExpectedTokens().getMinElement(); // get any element
|
||||
}
|
||||
Token errToken =
|
||||
getTokenFactory().create(new Pair<TokenSource, CharStream>(tok.getTokenSource(), tok.getTokenSource().getInputStream()),
|
||||
expectedTokenType, tok.getText(),
|
||||
|
|
Loading…
Reference in New Issue