let it consume EOF since we sometimes need to match that during prediction

This commit is contained in:
Terence Parr 2012-10-11 18:50:02 -07:00
parent 74754d04a2
commit 643edf0263
1 changed files with 2 additions and 2 deletions

View File

@ -75,7 +75,7 @@ public class UnbufferedCharStream implements CharStream {
/**
* This is the {@code LA(-1)} character for the current position.
*/
protected int lastChar = -1;
protected int lastChar = -2; // can't be -1 (EOF)
/**
* When {@code numMarkers > 0}, this is the {@code LA(-1)} character for the
@ -129,7 +129,7 @@ public class UnbufferedCharStream implements CharStream {
@Override
public void consume() {
if (LA(1) == CharStream.EOF) {
if ( lastChar == CharStream.EOF ) {
throw new IllegalStateException("cannot consume EOF");
}