Mercurial > hg > index.cgi
comparison lwcc/cpp.c @ 306:b08787e5b9f3 ccdev
Add include search paths and command line macro definitions
Added command line macro definitions. Also implemented include paths. There
is no default include path; that will be supplied by the driver program.
author | William Astle <lost@l-w.ca> |
---|---|
date | Wed, 18 Sep 2013 20:41:41 -0600 |
parents | 54f213c8fb81 |
children | 670ea8f90212 |
comparison
equal
deleted
inserted
replaced
305:54f213c8fb81 | 306:b08787e5b9f3 |
---|---|
24 #include <stdlib.h> | 24 #include <stdlib.h> |
25 #include <string.h> | 25 #include <string.h> |
26 | 26 |
27 #include <lw_alloc.h> | 27 #include <lw_alloc.h> |
28 #include <lw_string.h> | 28 #include <lw_string.h> |
29 #include <lw_stringlist.h> | |
29 | 30 |
30 #include "cpp.h" | 31 #include "cpp.h" |
31 #include "strpool.h" | 32 #include "strpool.h" |
32 | 33 |
33 struct token *preproc_lex_next_token(struct preproc_info *); | 34 struct token *preproc_lex_next_token(struct preproc_info *); |
56 pp -> ra = CPP_NOUNG; | 57 pp -> ra = CPP_NOUNG; |
57 pp -> unget = CPP_NOUNG; | 58 pp -> unget = CPP_NOUNG; |
58 pp -> ppeolseen = 1; | 59 pp -> ppeolseen = 1; |
59 pp -> lineno = 1; | 60 pp -> lineno = 1; |
60 pp -> n = NULL; | 61 pp -> n = NULL; |
62 pp -> quotelist = lw_stringlist_create(); | |
63 pp -> inclist = lw_stringlist_create(); | |
61 return pp; | 64 return pp; |
65 } | |
66 | |
67 void preproc_add_include(struct preproc_info *pp, char *dir, int sys) | |
68 { | |
69 if (sys) | |
70 lw_stringlist_addstring(pp -> inclist, dir); | |
71 else | |
72 lw_stringlist_addstring(pp -> quotelist, dir); | |
62 } | 73 } |
63 | 74 |
64 struct token *preproc_next_token(struct preproc_info *pp) | 75 struct token *preproc_next_token(struct preproc_info *pp) |
65 { | 76 { |
66 struct token *t; | 77 struct token *t; |
116 } | 127 } |
117 | 128 |
118 void preproc_finish(struct preproc_info *pp) | 129 void preproc_finish(struct preproc_info *pp) |
119 { | 130 { |
120 fclose(pp -> fp); | 131 fclose(pp -> fp); |
132 lw_stringlist_destroy(pp -> inclist); | |
133 lw_stringlist_destroy(pp -> quotelist); | |
121 if (pp -> curtok) | 134 if (pp -> curtok) |
122 token_free(pp -> curtok); | 135 token_free(pp -> curtok); |
123 while (pp -> tokqueue) | 136 while (pp -> tokqueue) |
124 { | 137 { |
125 preproc_next_token(pp); | 138 preproc_next_token(pp); |