From c9f1161ecb323c7872559dd40c56d691dbd5959f Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Sun, 19 Apr 2026 17:09:06 +0200 Subject: Start working on parsing/scanning. Too many changes to list them all individually. --- lib/aplwc_internal.h | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'lib/aplwc_internal.h') diff --git a/lib/aplwc_internal.h b/lib/aplwc_internal.h index 99c16ee..dd676fb 100644 --- a/lib/aplwc_internal.h +++ b/lib/aplwc_internal.h @@ -21,11 +21,74 @@ #ifndef APLWC_INTERNAL_H #define APLWC_INTERNAL_H +#include +#include + +enum aplwc_token_tag { + APLWC_TOKEN_SYSCMD, + APLWC_TOKEN_SYSCMD_ARGS, + + APLWC_TOKEN_ERROR, +}; + +enum aplwc_ast_tag { + APLWC_AST_SYSCMD, + + APLWC_AST_ERROR, +}; + struct aplwc { + void *(*alloc)(size_t); + void (*free)(void *); + void *(*realloc)(void *, size_t); + struct aplwc_syscmd **syscmds; int n_syscmds; + bool running; +}; + +struct aplwc_eval_context { + struct aplwc *aplwc; + char *text; + size_t offset; + size_t length; + + size_t n_tokens; + struct aplwc_token **tokens; + + size_t token_offset; + struct aplwc_ast *ast; +}; + +struct aplwc_token { + enum aplwc_token_tag tag; + size_t offset_start; + size_t offset_end; + + union { + } data; +}; + +struct aplwc_ast { + enum aplwc_ast_tag tag; + + union { + struct { + struct aplwc_syscmd *syscmd; + char *args; + } syscmd; + } data; }; struct aplwc_syscmd *aplwc_lookup_syscmd(struct aplwc *, const char *); +struct aplwc_eval_context *aplwc_new_eval_context(struct aplwc *); +void aplwc_scan_line(struct aplwc_eval_context *, const char *); +void aplwc_parse(struct aplwc_eval_context *); +void aplwc_eval(struct aplwc_eval_context *); +void aplwc_free_eval_context(struct aplwc_eval_context *); +void aplwc_free_ast(struct aplwc *, struct aplwc_ast *); +char *aplwc_strdup(struct aplwc *, const char *); +void aplwc_output(struct aplwc *, const char *, ...); +void aplwc_voutput(struct aplwc *, const char *, va_list); #endif /* APLWC_INTERNAL_H */ -- cgit v1.2.3