Function to require from pipe but skip (don't output)

This commit is contained in:
Wilson Lin 2018-08-03 22:57:56 +12:00
parent 88017538f5
commit 8127690e89
1 changed files with 10 additions and 0 deletions

View File

@ -365,6 +365,16 @@ void hbu_pipe_require(hbu_pipe_t pipe, hb_char_t c) {
}
}
void hbu_pipe_require_skip(hbu_pipe_t pipe, hb_char_t c) {
hb_char_t n = hbu_pipe_peek(pipe);
if (c != n) {
hbe_fatal(HBE_PARSE_EXPECTED_NOT_FOUND, "Expected `%c` (0x%x), got `%c` (0x%x) at %s", c, c, n, n, hbu_pipe_generate_pos_msg(pipe));
}
hbu_pipe_skip(pipe);
}
hb_char_t hbu_pipe_require_predicate(hbu_pipe_t pipe, hbu_pipe_predicate_t pred, const char *name) {
hb_char_t n = hbu_pipe_accept(pipe);