From 54871d52ff7e838f3891272980cc86798221c722 Mon Sep 17 00:00:00 2001 From: Terence Parr Date: Sun, 14 Oct 2012 18:46:43 -0700 Subject: [PATCH 1/2] Revert "let it consume EOF since we sometimes need to match that during prediction" This reverts commit 643edf0263f39a82cd7d67db8433fc3f2be7eca2. --- .../Java/src/org/antlr/v4/runtime/UnbufferedCharStream.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/Java/src/org/antlr/v4/runtime/UnbufferedCharStream.java b/runtime/Java/src/org/antlr/v4/runtime/UnbufferedCharStream.java index 1e98389b2..5f6193b1a 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/UnbufferedCharStream.java +++ b/runtime/Java/src/org/antlr/v4/runtime/UnbufferedCharStream.java @@ -75,7 +75,7 @@ public class UnbufferedCharStream implements CharStream { /** * This is the {@code LA(-1)} character for the current position. */ - protected int lastChar = -2; // can't be -1 (EOF) + protected int lastChar = -1; /** * 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 ( lastChar == CharStream.EOF ) { + if (LA(1) == CharStream.EOF) { throw new IllegalStateException("cannot consume EOF"); } From 327a3a01008af0efdbf31caa3eb5eff0bccadb33 Mon Sep 17 00:00:00 2001 From: Terence Parr Date: Sun, 14 Oct 2012 18:46:54 -0700 Subject: [PATCH 2/2] Revert "update comment on consume()" This reverts commit 27a8e5e521f284535d6e363b2d402f6ea7f0801a. --- runtime/Java/src/org/antlr/v4/runtime/IntStream.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/Java/src/org/antlr/v4/runtime/IntStream.java b/runtime/Java/src/org/antlr/v4/runtime/IntStream.java index 53166ee2b..0b0ca6ff8 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/IntStream.java +++ b/runtime/Java/src/org/antlr/v4/runtime/IntStream.java @@ -79,9 +79,9 @@ public interface IntStream { * filtering streams (e.g. {@link CommonTokenStream} which distinguishes * between "on-channel" and "off-channel" tokens). * - * @throws IllegalStateException if an attempt is made to consume past - * end of the stream (i.e. if last char == {@link #EOF EOF} before calling - * {@code consume}). Sometimes need to match EOF during prediction. + * @throws IllegalStateException if an attempt is made to consume the the + * end of the stream (i.e. if {@code LA(1)==}{@link #EOF EOF} before calling + * {@code consume}). */ void consume();