#ifndef __SCC_LEXER_UTILS_H__ #define __SCC_LEXER_UTILS_H__ #include "scc_lexer.h" static inline cbool scc_lexer_peek_non_blank(scc_lexer_tok_ring_t *stream, scc_lexer_tok_t *out) { cbool ok; while (1) { scc_ring_peek(*stream, *out, ok); if (!ok || out->type != SCC_TOK_BLANK) break; scc_ring_next_consume(*stream, *out, ok); scc_lexer_tok_drop(out); } return ok; } static inline cbool scc_lexer_next_non_blank(scc_lexer_tok_ring_t *stream, scc_lexer_tok_t *out) { cbool ok; if (!scc_lexer_peek_non_blank(stream, out)) return false; scc_ring_next_consume(*stream, *out, ok); return true; } static inline void scc_lexer_skip_until_newline(scc_lexer_tok_ring_t *stream) { scc_lexer_tok_t tok; cbool ok; while (1) { scc_ring_next_consume(*stream, tok, ok); if (!ok) break; scc_tok_type_t type = tok.type; scc_lexer_tok_drop(&tok); if (type == SCC_TOK_ENDLINE) break; } } #endif /* __SCC_LEXER_UTILS_H__ */