diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2022-02-17 16:42:31 -0400 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2022-02-18 10:05:01 -0400 |
commit | 524cfc23b15e1067076e45b056cb1d84e87e66cb (patch) | |
tree | 03a1b91d23da653ec3e5b9703b0b1544238400d9 /igen/preprocessor.h | |
parent | 5f753ddee7d935e0ba4750a6a8c26fe056c77612 (diff) |
igen: Did some more work on it.
Diffstat (limited to 'igen/preprocessor.h')
-rw-r--r-- | igen/preprocessor.h | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/igen/preprocessor.h b/igen/preprocessor.h index 7a85e45..200f5b2 100644 --- a/igen/preprocessor.h +++ b/igen/preprocessor.h @@ -1,11 +1,25 @@ #ifndef PREPROCESSOR_H #define PREPROCESSOR_H +#include "lexer.h" + + typedef enum comment_type comment_type; +typedef enum directive_type directive_type; +typedef struct stmt stmt; +typedef struct linked_list linked_list; +typedef struct keyword keyword; typedef struct cursor cursor; typedef struct whitespace whitespace; typedef struct comment comment; typedef struct source source; +typedef void *(keyword_cb)(void *ctx, int dbg); + +enum directive_type { + DIR_NONE, + DIR_INCLUDE, + NUM_DIRS +}; enum comment_type { COMM_NONE, @@ -14,6 +28,17 @@ enum comment_type { NUM_COMMS }; +struct linked_list { + void *data; + linked_list *next; +}; + +struct keyword { + char *name; + int id; + keyword_cb *found_keyword; +}; + struct cursor { int line; int column; @@ -36,12 +61,19 @@ struct comment { }; struct source { + source *parent; source **include_list; + comment **comments; char *filename; char *text; + int included : 1; int tab_width; cursor cur; + stmt *root; + stmt *last; }; -extern source *preprocess(const char *str, int dbg); +/*extern keyword *find_keyword(const char *key, keyword **keywords, int dbg);*/ +extern int find_keyword(const char *key, keyword **keywords, void *ctx, void **callback_ret, int dbg); +extern source *preprocess(source *parent, const char *filename, int dbg); #endif |