Throw IllegalStateException if the user tries to consume EOF

This commit is contained in:
Sam Harwell 2012-11-03 15:38:32 -05:00
parent cf5bf7c384
commit c9890e8305
1 changed files with 5 additions and 0 deletions

View File

@ -144,6 +144,11 @@ public class ANTLRInputStream implements CharStream {
@Override
public void consume() {
if (p >= n) {
assert LA(1) == CharStream.EOF;
throw new IllegalStateException("cannot consume EOF");
}
//System.out.println("prev p="+p+", c="+(char)data[p]);
if ( p < n ) {
p++;