#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, COMM_MULTI, COMM_SINGLE, 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; }; struct whitespace { int spaces; int bspaces; int tabs; int vtabs; int lines; }; struct comment { enum comment_type type; char *text; cursor start_pos; cursor end_pos; whitespace wsp; }; 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 keyword *find_keyword(const char *key, keyword **keywords, int dbg);*/ extern char *skip_whitespace(source *src, whitespace *wspace, int count_lines, int count_columns, int dbg); extern char *skip_comment(source *src, whitespace *wspace, comment_type *type, 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