From 524cfc23b15e1067076e45b056cb1d84e87e66cb Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Thu, 17 Feb 2022 16:42:31 -0400 Subject: igen: Did some more work on it. --- igen/preprocessor.h | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'igen/preprocessor.h') 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 -- cgit v1.2.3-13-gbd6f