Create read module

This commit is contained in:
2025-08-10 16:39:13 +01:00
parent d90f91cda0
commit e25975e29d
5 changed files with 131 additions and 0 deletions

22
lib/read.c Normal file
View File

@@ -0,0 +1,22 @@
#include "read.h"
#include "parse.h"
#include "token.h"
#include <assert.h>
void read(am_t *am, stream_t *stream)
{
parse_ctx_t ctx;
token_t token;
parse_init(am, &ctx);
while (ctx.state != PARSE_STATE_DONE) {
const token_status_t token_status = token_read(stream, &token);
assert(token_status == TOKEN_OK);
parse_proc(&ctx, &token);
assert(ctx.state != PARSE_STATE_ERROR);
}
}