Improved handling of (potentially) null fields

This commit is contained in:
Sam Harwell 2012-07-18 15:04:05 -05:00
parent 4c4f767d17
commit 2f0029a040
2 changed files with 6 additions and 1 deletions

View File

@ -126,7 +126,8 @@ public class DefaultErrorStrategy implements ANTLRErrorStrategy {
// lastErrorIndex+
// ", states="+lastErrorStates);
if ( lastErrorIndex==recognizer.getInputStream().index() &&
lastErrorStates.contains(recognizer._ctx.s) ) {
lastErrorStates != null &&
lastErrorStates.contains(recognizer._ctx.s) ) {
// uh oh, another error at same token index and previously-visited
// state in ATN; must be a case where LT(1) is in the recovery
// token set so nothing got consumed. Consume a single token

View File

@ -130,6 +130,10 @@ public abstract class Lexer extends Recognizer<Integer, LexerATNSimulator>
*/
@Override
public Token nextToken() {
if (_input == null) {
throw new IllegalStateException("nextToken requires a non-null input stream.");
}
if (_hitEOF) {
emitEOF();
return _token;