diff options
Diffstat (limited to 'lib/aplwc_internal.h')
| -rw-r--r-- | lib/aplwc_internal.h | 63 |
1 files changed, 63 insertions, 0 deletions
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 <stdarg.h> +#include <stdbool.h> + +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 */ |