diff options
author | c+1 | 2023-10-10 11:26:44 -0400 |
---|---|---|
committer | c+1 | 2023-10-10 11:26:44 -0400 |
commit | 58c7a71a50318940e747c365cc3f207dba432977 (patch) | |
tree | 7d173f5433fba1b01c531610a0bf70684b8ca1de /src/include/pp.h | |
parent | 78befa147eccfb169bf994da3d9bfba9be3631a6 (diff) |
fixed source.c, fixed preprocessor mem leaks, implemented new lexer
Diffstat (limited to 'src/include/pp.h')
-rw-r--r-- | src/include/pp.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/include/pp.h b/src/include/pp.h new file mode 100644 index 0000000..d82907c --- /dev/null +++ b/src/include/pp.h @@ -0,0 +1,55 @@ +#ifndef PP_H +#define PP_H + +#include <stdlib.h> +#include <string.h> + +#include "util.h" +#include "syntax.h" + +/* TODO */ +typedef struct MACRO_STRUC { + char* id; + char* val; +} macro_t; + +/* + preprocessor struct + + TODO: keep track of macros +*/ +typedef struct PP_STRUC { + /* original source */ + char* src; + + /* pre-processed source */ + char* psrc; + + /* what the preprocessor is looking at right now */ + enum PP_STATE { + PP_STATE_REG, /* regular */ + PP_STATE_STR, /* string */ + PP_STATE_COM, /* comment */ + PP_STATE_ESC, /* escaped character in string */ + /* PP_STATE_MCO, */ /* macro */ + } state; +} pp_t; + +/* creates a new preprocessor from some source code */ +pp_t* pp_init(char*); + +/* destroys the preprocessor **but not the pre-processed source** */ +void pp_destroy(pp_t*); + +/* copy over the current character from src to psrc */ +void pp_cpy_char(pp_t*); + +void pp_do_reg(pp_t*); +void pp_do_str(pp_t*); +void pp_do_com(pp_t*); + +/* run the preprocessor */ +void pp_run(pp_t*); + +#endif + |