found 2 cases that called function on empty set.

This commit is contained in:
parrt 2017-03-02 14:18:00 -08:00
parent 6572b08095
commit d9d21fe9b3
2 changed files with 8 additions and 2 deletions

View File

@ -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)+">";

View File

@ -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(),