Mercurial > hg > index.cgi
comparison lwcc/cpp-main.c @ 304:d85d173ba120 ccdev
Checkpoint lwcc development - preprocessor is runnable but nonfunctional
The preprocessor is currently runnable but doesn't actually do anything
useful. This is just a checkpoint.
author | William Astle <lost@l-w.ca> |
---|---|
date | Tue, 17 Sep 2013 19:33:41 -0600 |
parents | 4b17780f2777 |
children | 54f213c8fb81 |
comparison
equal
deleted
inserted
replaced
303:659e0e4ce50c | 304:d85d173ba120 |
---|---|
118 | 118 |
119 if (lw_stringlist_nstrings(input_files) == 0) | 119 if (lw_stringlist_nstrings(input_files) == 0) |
120 { | 120 { |
121 /* if no input files, work on stdin */ | 121 /* if no input files, work on stdin */ |
122 retval = process_file("-"); | 122 retval = process_file("-"); |
123 retval = 1; | |
124 } | 123 } |
125 else | 124 else |
126 { | 125 { |
127 char *s; | 126 char *s; |
128 lw_stringlist_reset(input_files); | 127 lw_stringlist_reset(input_files); |
140 } | 139 } |
141 | 140 |
142 int process_file(const char *fn) | 141 int process_file(const char *fn) |
143 { | 142 { |
144 struct preproc_info *pp; | 143 struct preproc_info *pp; |
145 struct token *tok; | 144 struct token *tok = NULL; |
146 | 145 |
147 pp = preproc_init(fn); | 146 pp = preproc_init(fn); |
148 if (!pp) | 147 if (!pp) |
149 return -1; | 148 return -1; |
150 | 149 |
151 for (;;) | 150 for (;;) |
152 { | 151 { |
153 tok = preproc_next_token(pp); | 152 tok = preproc_next(pp); |
154 if (tok -> ttype == TOK_EOF) | 153 if (tok -> ttype == TOK_EOF) |
155 break; | 154 break; |
156 token_print(tok, output_fp); | 155 token_print(tok, output_fp); |
156 token_free(tok); | |
157 } | 157 } |
158 token_free(tok); | |
158 preproc_finish(pp); | 159 preproc_finish(pp); |
159 return 0; | 160 return 0; |
160 } | 161 } |
161 | 162 |
162 static void do_error(const char *f, ...) | 163 static void do_error(const char *f, ...) |