Create read module
This commit is contained in:
22
lib/read.c
Normal file
22
lib/read.c
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user