@Test void testLineFeed() throws IOException { var stream = new BufferedCharStream(new ByteArrayInputStream("\r\n\r".getBytes())); assertEquals('\n', stream.take()); assertEquals(CharStream.NULL, stream.take()); }
@Override public char take() { if (pos >= buffer.length) { return NULL; } if (peek() == '\r') { if (++pos >= buffer.length) { return NULL; } } char ch = buffer[pos++]; if (ch == '\n') { line++; column = 1; } else if (ch == '\t') { column += tabSize - (column - 1) % tabSize; } else { column++; } return ch; }
BufferedCharStream implements CharStream { @Override public char take() { if (pos >= buffer.length) { return NULL; } if (peek() == '\r') { if (++pos >= buffer.length) { return NULL; } } char ch = buffer[pos++]; if (ch == '\n') { line++; column = 1; } else if (ch == '\t') { column += tabSize - (column - 1) % tabSize; } else { column++; } return ch; } }
BufferedCharStream implements CharStream { @Override public char take() { if (pos >= buffer.length) { return NULL; } if (peek() == '\r') { if (++pos >= buffer.length) { return NULL; } } char ch = buffer[pos++]; if (ch == '\n') { line++; column = 1; } else if (ch == '\t') { column += tabSize - (column - 1) % tabSize; } else { column++; } return ch; } BufferedCharStream(InputStream stream);  BufferedCharStream(InputStream stream, int line, int column); private  BufferedCharStream(InputStream stream, int tabSize); }
BufferedCharStream implements CharStream { @Override public char take() { if (pos >= buffer.length) { return NULL; } if (peek() == '\r') { if (++pos >= buffer.length) { return NULL; } } char ch = buffer[pos++]; if (ch == '\n') { line++; column = 1; } else if (ch == '\t') { column += tabSize - (column - 1) % tabSize; } else { column++; } return ch; } 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 take() { if (pos >= buffer.length) { return NULL; } if (peek() == '\r') { if (++pos >= buffer.length) { return NULL; } } char ch = buffer[pos++]; if (ch == '\n') { line++; column = 1; } else if (ch == '\t') { column += tabSize - (column - 1) % tabSize; } else { column++; } return ch; } 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();  }