@Test void testPeek() throws IOException { var buffer = "abcdef"; var stream = new BufferedCharStream(new ByteArrayInputStream(buffer.getBytes())); for (var ch : buffer.toCharArray()) { assertEquals(ch, stream.peek()); stream.take(); } assertEquals(CharStream.NULL, stream.peek()); }
@Override public char peek() { if (pos >= buffer.length) { return NULL; } return buffer[pos]; }
BufferedCharStream implements CharStream { @Override public char peek() { if (pos >= buffer.length) { return NULL; } return buffer[pos]; } }
BufferedCharStream implements CharStream { @Override public char peek() { if (pos >= buffer.length) { return NULL; } return buffer[pos]; } BufferedCharStream(InputStream stream);  BufferedCharStream(InputStream stream, int line, int column); private  BufferedCharStream(InputStream stream, int tabSize); }
BufferedCharStream implements CharStream { @Override public char peek() { if (pos >= buffer.length) { return NULL; } return buffer[pos]; } BufferedCharStream(InputStream stream);  BufferedCharStream(InputStream stream, int line, int column); private  BufferedCharStream(InputStream stream, int tabSize); @Override char take(); @Override char peek(); @Override void mark(); @Override void reset(); @Override void rollback(int count); @Override boolean hasRemaining(); @Override LineColumn position(); }
BufferedCharStream implements CharStream { @Override public char peek() { if (pos >= buffer.length) { return NULL; } return buffer[pos]; } BufferedCharStream(InputStream stream);  BufferedCharStream(InputStream stream, int line, int column); private  BufferedCharStream(InputStream stream, int tabSize); @Override char take(); @Override char peek(); @Override void mark(); @Override void reset(); @Override void rollback(int count); @Override boolean hasRemaining(); @Override LineColumn position();  }