Implement parsing

This commit is contained in:
2025-08-09 19:43:17 +01:00
parent f97cea9290
commit a03ef58eca
5 changed files with 377 additions and 0 deletions

27
lib/include/parse.h Normal file
View File

@@ -0,0 +1,27 @@
#ifndef PARSE_H
#define PARSE_H
#include "am.h"
#include "store.h"
#include "token.h"
#define PARSE_MAX_DEPTH 128U
typedef enum {
PARSE_STATE_INIT,
PARSE_STATE_LIST,
PARSE_STATE_DONE,
PARSE_STATE_ERROR,
} parse_state_t;
typedef struct {
am_t *am;
store_t *store;
parse_state_t state;
parse_state_t *sp, stack[PARSE_MAX_DEPTH];
} parse_ctx_t;
void parse_init(am_t *am, store_t *store, parse_ctx_t *out);
parse_state_t parse_proc(parse_ctx_t *ctx, const token_t *token);
#endif