forked from jasder/antlr
Fix comparison with IntStream.EOF
This commit is contained in:
parent
645f80971f
commit
03f8d3772f
|
@ -169,7 +169,7 @@ public class UnbufferedCharStream implements CharStream {
|
||||||
*/
|
*/
|
||||||
protected int fill(int n) {
|
protected int fill(int n) {
|
||||||
for (int i=0; i<n; i++) {
|
for (int i=0; i<n; i++) {
|
||||||
if (this.n > 0 && data[this.n - 1] == IntStream.EOF) {
|
if (this.n > 0 && data[this.n - 1] == (char)IntStream.EOF) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ public class UnbufferedCharStream implements CharStream {
|
||||||
sync(i);
|
sync(i);
|
||||||
int index = p + i - 1;
|
int index = p + i - 1;
|
||||||
if ( index < 0 ) throw new IndexOutOfBoundsException();
|
if ( index < 0 ) throw new IndexOutOfBoundsException();
|
||||||
if ( index > n ) return IntStream.EOF;
|
if ( index >= n ) return IntStream.EOF;
|
||||||
char c = data[index];
|
char c = data[index];
|
||||||
if ( c==(char)IntStream.EOF ) return IntStream.EOF;
|
if ( c==(char)IntStream.EOF ) return IntStream.EOF;
|
||||||
return c;
|
return c;
|
||||||
|
@ -315,7 +315,7 @@ public class UnbufferedCharStream implements CharStream {
|
||||||
|
|
||||||
if (interval.a < bufferStartIndex || interval.b >= bufferStartIndex + n) {
|
if (interval.a < bufferStartIndex || interval.b >= bufferStartIndex + n) {
|
||||||
throw new UnsupportedOperationException("interval "+interval+" outside buffer: "+
|
throw new UnsupportedOperationException("interval "+interval+" outside buffer: "+
|
||||||
bufferStartIndex+".."+(bufferStartIndex+n));
|
bufferStartIndex+".."+(bufferStartIndex+n-1));
|
||||||
}
|
}
|
||||||
// convert from absolute to local index
|
// convert from absolute to local index
|
||||||
int i = interval.a - bufferStartIndex;
|
int i = interval.a - bufferStartIndex;
|
||||||
|
|
Loading…
Reference in New Issue