def expect_lit(char, buf, pos):
    """Expect a literal character at the current buffer position."""
    if pos >= len(buf) or buf[pos] != char:
        return None, len(buf)
    return char, pos + 1
