Improved handling of (potentially) null fields
This commit is contained in:
parent
4c4f767d17
commit
2f0029a040
|
@ -126,7 +126,8 @@ public class DefaultErrorStrategy implements ANTLRErrorStrategy {
|
||||||
// lastErrorIndex+
|
// lastErrorIndex+
|
||||||
// ", states="+lastErrorStates);
|
// ", states="+lastErrorStates);
|
||||||
if ( lastErrorIndex==recognizer.getInputStream().index() &&
|
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
|
// 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
|
// state in ATN; must be a case where LT(1) is in the recovery
|
||||||
// token set so nothing got consumed. Consume a single token
|
// token set so nothing got consumed. Consume a single token
|
||||||
|
|
|
@ -130,6 +130,10 @@ public abstract class Lexer extends Recognizer<Integer, LexerATNSimulator>
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Token nextToken() {
|
public Token nextToken() {
|
||||||
|
if (_input == null) {
|
||||||
|
throw new IllegalStateException("nextToken requires a non-null input stream.");
|
||||||
|
}
|
||||||
|
|
||||||
if (_hitEOF) {
|
if (_hitEOF) {
|
||||||
emitEOF();
|
emitEOF();
|
||||||
return _token;
|
return _token;
|
||||||
|
|
Loading…
Reference in New Issue