SimpleParser { public void br() { sp(); if (eof()) { return; } char c = peek(); if (c == '\n' || c == '\r') { skip(); } else { throw syntax("Expected a line break, but found '" + c + "'"); } } SimpleParser(String expression);  SimpleParser(String expression, int maxNestingLevel); final String expression(); final int position(); final int line(); final int column(); final boolean eof(); final char peek(); final char peek(int offset); final char expect(char token); final String peekSingleCharForMessage(); final char expect(char... tokens); RuntimeException syntax(String message); void ws(); void sp(); void br(); void skip(); void consumeRemainingCharactersOnLine(); final String sliceFrom(int start); final int consumeUntilNoLongerMatches(Predicate<Character> predicate); final void increaseNestingLevel(); final void decreaseNestingLevel(); int nestingLevel();  }
@Test public void eofIsAcceptableNewline() { SimpleParser p = new SimpleParser(""); p.br(); }
@Test public void throwsWhenNotNewline() { RuntimeException e = Assertions.assertThrows(RuntimeException.class, () -> { SimpleParser p = new SimpleParser("H"); p.br(); }); assertThat(e.getMessage(), containsString("Expected a line break, but found 'H'")); }