Mercurial > hg > index.cgi
comparison lwcc/cpp.h @ 296:83fcc1ed6ad6 ccdev
Checkpoint lwcc development
Initial untested version of the preprocessor with macro expansion but
without file inclusion.
author | William Astle <lost@l-w.ca> |
---|---|
date | Sat, 14 Sep 2013 20:04:38 -0600 |
parents | 4b17780f2777 |
children | 6112c67728ba |
comparison
equal
deleted
inserted
replaced
295:4b17780f2777 | 296:83fcc1ed6ad6 |
---|---|
22 #ifndef cpp_h_seen___ | 22 #ifndef cpp_h_seen___ |
23 #define cpp_h_seen___ | 23 #define cpp_h_seen___ |
24 | 24 |
25 #include <stdio.h> | 25 #include <stdio.h> |
26 | 26 |
27 //#include "symbol.h" | |
27 #include "token.h" | 28 #include "token.h" |
28 | 29 |
29 #define TOKBUFSIZE 32 | 30 #define TOKBUFSIZE 32 |
31 | |
32 struct expand_e | |
33 { | |
34 struct expand_e *next; | |
35 struct symtab_e *s; // symbol table entry of the expanding symbol | |
36 }; | |
30 | 37 |
31 struct preproc_info | 38 struct preproc_info |
32 { | 39 { |
33 const char *fn; | 40 const char *fn; |
34 FILE *fp; | 41 FILE *fp; |
35 struct token *tokbuf[TOKBUFSIZE]; | |
36 struct token *tokqueue; | 42 struct token *tokqueue; |
37 int tokbuf_ptr; | 43 struct token *curtok; |
38 void (*errorcb)(const char *); | 44 void (*errorcb)(const char *); |
39 void (*warningcb)(const char *); | 45 void (*warningcb)(const char *); |
40 int eolstate; | 46 int eolstate; // internal for use in handling newlines |
41 int lineno; | 47 int lineno; // the current input line number |
42 int column; | 48 int column; // the current input column |
43 int trigraphs; | 49 int trigraphs; // nonzero if we're going to handle trigraphs |
44 int ra; | 50 int ra; |
45 int qseen; | 51 int qseen; |
46 int ungetbufl; | 52 int ungetbufl; |
47 int ungetbufs; | 53 int ungetbufs; |
48 int *ungetbuf; | 54 int *ungetbuf; |
49 int unget; | 55 int unget; |
50 int eolseen; | 56 int eolseen; |
51 int nlseen; | 57 int nlseen; |
58 int ppeolseen; // nonzero if we've seen only whitespace (or nothing) since a newline | |
59 int skip_level; // nonzero if we're in a false conditional | |
60 int found_level; // nonzero if we're in a true conditional | |
61 int else_level; // for counting #else directives | |
62 int else_skip_level; // ditto | |
63 struct symtab_e *sh; // the preprocessor's symbol table | |
64 struct token *sourcelist; // for expanding a list of tokens | |
65 struct expand_e *expand_list; // record of which macros are currently being expanded | |
66 | |
52 }; | 67 }; |
53 | 68 |
54 extern struct preproc_info *preproc_init(const char *); | 69 extern struct preproc_info *preproc_init(const char *); |
55 extern struct token *preproc_next_token(struct preproc_info *); | 70 extern struct token *preproc_next_token(struct preproc_info *); |
71 extern struct token *preproc_next_processed_token(struct preproc_info *); | |
56 extern void preproc_finish(struct preproc_info *); | 72 extern void preproc_finish(struct preproc_info *); |
57 extern void preproc_register_error_callback(struct preproc_info *, void (*)(const char *)); | 73 extern void preproc_register_error_callback(struct preproc_info *, void (*)(const char *)); |
58 extern void preproc_register_warning_callback(struct preproc_info *, void (*)(const char *)); | 74 extern void preproc_register_warning_callback(struct preproc_info *, void (*)(const char *)); |
59 extern void preproc_throw_error(struct preproc_info *, const char *, ...); | 75 extern void preproc_throw_error(struct preproc_info *, const char *, ...); |
60 extern void preproc_throw_warning(struct preproc_info *, const char *, ...); | 76 extern void preproc_throw_warning(struct preproc_info *, const char *, ...); |
77 extern void preproc_unget_token(struct preproc_info *, struct token *); | |
78 | |
61 #endif // cpp_h_seen___ | 79 #endif // cpp_h_seen___ |