diff options
| author | Chloe M. <chloe@mirocom.org> | 2026-05-23 14:36:55 +0000 |
|---|---|---|
| committer | Chloe M. <chloe@mirocom.org> | 2026-05-23 14:36:55 +0000 |
| commit | a0b204fadd0ff2dae410e7b9e089de55cf1a4c47 (patch) | |
| tree | 39d4913347185559c854c25ebfed04a418ee22b8 | |
| parent | 19c7587f28a8b3de2ad161020d4673c674af343b (diff) | |
core: parser: Add parser-side nom function
Signed-off-by: Chloe M. <chloe@mirocom.org>
| -rw-r--r-- | core/parser.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/core/parser.c b/core/parser.c index 58a1bc5..4779803 100644 --- a/core/parser.c +++ b/core/parser.c @@ -58,6 +58,28 @@ static const char *toktab[] = { [TT_U64] = qtok("u64") }; +static int +parser_nom(struct cescal_state *state, struct token *res) +{ + struct token tok; + + if (state == NULL || res == NULL) { + errno = EINVAL; + return -1; + } + + if (lexer_nom(state, &tok) < 0) { + return -1; + } + + if (tokbuf_push(&state->tokbuf, &tok) < 0) { + return -1; + } + + *res = tok; + return 0; +} + int parser_parse(struct cescal_state *state) { @@ -68,7 +90,7 @@ parser_parse(struct cescal_state *state) return -1; } - while (lexer_nom(state, &tok) == 0) { + while (parser_nom(state, &tok) == 0) { cc_trace("got token %s\n", tokstr(&tok)); } |
