5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 * this software and associated documentation files (the "Software"), to deal in
7 * the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is furnished to do
10 * so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35 /* a copy from the lexer */
49 /* yes we need an extra flag since `#define FOO x` is not the same as `#define FOO() x` */
62 ppcondition *conditions;
68 #define ftepp_tokval(f) ((f)->lex->tok.value)
69 #define ftepp_ctx(f) ((f)->lex->tok.ctx)
71 static void ftepp_errorat(ftepp_t *ftepp, lex_ctx ctx, const char *fmt, ...)
78 con_vprintmsg(LVL_ERROR, ctx.file, ctx.line, "error", fmt, ap);
82 static void ftepp_error(ftepp_t *ftepp, const char *fmt, ...)
89 con_vprintmsg(LVL_ERROR, ftepp->lex->tok.ctx.file, ftepp->lex->tok.ctx.line, "error", fmt, ap);
93 static bool GMQCC_WARN ftepp_warn(ftepp_t *ftepp, int warntype, const char *fmt, ...)
96 int lvl = LVL_WARNING;
98 if (!OPTS_WARN(warntype))
107 con_vprintmsg(lvl, ftepp->lex->tok.ctx.file, ftepp->lex->tok.ctx.line, "error", fmt, ap);
112 static pptoken *pptoken_make(ftepp_t *ftepp)
114 pptoken *token = (pptoken*)mem_a(sizeof(pptoken));
115 token->token = ftepp->token;
117 if (token->token == TOKEN_WHITE)
118 token->value = util_strdup(" ");
121 token->value = util_strdup(ftepp_tokval(ftepp));
123 memcpy(&token->constval, &ftepp->lex->tok.constval, sizeof(token->constval));
127 static void pptoken_delete(pptoken *self)
133 static ppmacro *ppmacro_new(lex_ctx ctx, const char *name)
135 ppmacro *macro = (ppmacro*)mem_a(sizeof(ppmacro));
136 memset(macro, 0, sizeof(*macro));
137 macro->name = util_strdup(name);
141 static void ppmacro_delete(ppmacro *self)
144 for (i = 0; i < vec_size(self->params); ++i)
145 mem_d(self->params[i]);
146 vec_free(self->params);
147 for (i = 0; i < vec_size(self->output); ++i)
148 pptoken_delete(self->output[i]);
149 vec_free(self->output);
154 static ftepp_t* ftepp_new()
158 ftepp = (ftepp_t*)mem_a(sizeof(*ftepp));
159 memset(ftepp, 0, sizeof(*ftepp));
161 ftepp->output_on = true;
166 static void ftepp_delete(ftepp_t *self)
169 for (i = 0; i < vec_size(self->macros); ++i)
170 ppmacro_delete(self->macros[i]);
171 vec_free(self->macros);
172 vec_free(self->conditions);
174 lex_close(self->lex);
178 static void ftepp_out(ftepp_t *ftepp, const char *str, bool ignore_cond)
180 if (ignore_cond || ftepp->output_on)
185 data = vec_add(ftepp->output_string, len);
186 memcpy(data, str, len);
190 static void ftepp_update_output_condition(ftepp_t *ftepp)
193 ftepp->output_on = true;
194 for (i = 0; i < vec_size(ftepp->conditions); ++i)
195 ftepp->output_on = ftepp->output_on && ftepp->conditions[i].on;
198 static ppmacro* ftepp_macro_find(ftepp_t *ftepp, const char *name)
201 for (i = 0; i < vec_size(ftepp->macros); ++i) {
202 if (!strcmp(name, ftepp->macros[i]->name))
203 return ftepp->macros[i];
208 static void ftepp_macro_delete(ftepp_t *ftepp, const char *name)
211 for (i = 0; i < vec_size(ftepp->macros); ++i) {
212 if (!strcmp(name, ftepp->macros[i]->name)) {
213 vec_remove(ftepp->macros, i, 1);
219 static inline int ftepp_next(ftepp_t *ftepp)
221 return (ftepp->token = lex_do(ftepp->lex));
224 /* Important: this does not skip newlines! */
225 static bool ftepp_skipspace(ftepp_t *ftepp)
227 if (ftepp->token != TOKEN_WHITE)
229 while (ftepp_next(ftepp) == TOKEN_WHITE) {}
230 if (ftepp->token >= TOKEN_EOF) {
231 ftepp_error(ftepp, "unexpected end of preprocessor directive");
237 /* this one skips EOLs as well */
238 static bool ftepp_skipallwhite(ftepp_t *ftepp)
240 if (ftepp->token != TOKEN_WHITE && ftepp->token != TOKEN_EOL)
244 } while (ftepp->token == TOKEN_WHITE || ftepp->token == TOKEN_EOL);
245 if (ftepp->token >= TOKEN_EOF) {
246 ftepp_error(ftepp, "unexpected end of preprocessor directive");
253 * The huge macro parsing code...
255 static bool ftepp_define_params(ftepp_t *ftepp, ppmacro *macro)
259 if (!ftepp_skipspace(ftepp))
261 if (ftepp->token == ')')
263 switch (ftepp->token) {
269 ftepp_error(ftepp, "unexpected token in parameter list");
272 vec_push(macro->params, util_strdup(ftepp_tokval(ftepp)));
274 if (!ftepp_skipspace(ftepp))
276 } while (ftepp->token == ',');
277 if (ftepp->token != ')') {
278 ftepp_error(ftepp, "expected closing paren after macro parameter list");
282 /* skipspace happens in ftepp_define */
286 static bool ftepp_define_body(ftepp_t *ftepp, ppmacro *macro)
289 while (ftepp->token != TOKEN_EOL && ftepp->token < TOKEN_EOF) {
290 ptok = pptoken_make(ftepp);
291 vec_push(macro->output, ptok);
294 /* recursive expansion can cause EOFs here */
295 if (ftepp->token != TOKEN_EOL && ftepp->token != TOKEN_EOF) {
296 ftepp_error(ftepp, "unexpected junk after macro or unexpected end of file");
302 static bool ftepp_define(ftepp_t *ftepp)
305 (void)ftepp_next(ftepp);
306 if (!ftepp_skipspace(ftepp))
309 switch (ftepp->token) {
313 macro = ftepp_macro_find(ftepp, ftepp_tokval(ftepp));
314 if (macro && ftepp->output_on) {
315 if (ftepp_warn(ftepp, WARN_PREPROCESSOR, "redefining `%s`", ftepp_tokval(ftepp)))
317 ftepp_macro_delete(ftepp, ftepp_tokval(ftepp));
319 macro = ppmacro_new(ftepp_ctx(ftepp), ftepp_tokval(ftepp));
322 ftepp_error(ftepp, "expected macro name");
326 (void)ftepp_next(ftepp);
328 if (ftepp->token == '(') {
329 macro->has_params = true;
330 if (!ftepp_define_params(ftepp, macro))
334 if (!ftepp_skipspace(ftepp))
337 if (!ftepp_define_body(ftepp, macro))
340 if (ftepp->output_on)
341 vec_push(ftepp->macros, macro);
343 ppmacro_delete(macro);
349 * When a macro is used we have to handle parameters as well
350 * as special-concatenation via ## or stringification via #
352 * Note: parenthesis can nest, so FOO((a),b) is valid, but only
353 * this kind of parens. Curly braces or [] don't count towards the
360 static void macroparam_clean(macroparam *self)
363 for (i = 0; i < vec_size(self->tokens); ++i)
364 pptoken_delete(self->tokens[i]);
365 vec_free(self->tokens);
368 /* need to leave the last token up */
369 static bool ftepp_macro_call_params(ftepp_t *ftepp, macroparam **out_params)
371 macroparam *params = NULL;
377 if (!ftepp_skipallwhite(ftepp))
379 while (ftepp->token != ')') {
381 if (!ftepp_skipallwhite(ftepp))
383 while (parens || ftepp->token != ',') {
384 if (ftepp->token == '(')
386 else if (ftepp->token == ')') {
391 ptok = pptoken_make(ftepp);
392 vec_push(mp.tokens, ptok);
393 if (ftepp_next(ftepp) >= TOKEN_EOF) {
394 ftepp_error(ftepp, "unexpected EOF in macro call");
398 vec_push(params, mp);
400 if (ftepp->token == ')')
402 if (ftepp->token != ',') {
403 ftepp_error(ftepp, "expected closing paren or comma in macro call");
406 if (ftepp_next(ftepp) >= TOKEN_EOF) {
407 ftepp_error(ftepp, "unexpected EOF in macro call");
411 /* need to leave that up
412 if (ftepp_next(ftepp) >= TOKEN_EOF) {
413 ftepp_error(ftepp, "unexpected EOF in macro call");
417 *out_params = params;
422 macroparam_clean(&mp);
423 for (i = 0; i < vec_size(params); ++i)
424 macroparam_clean(¶ms[i]);
429 static bool macro_params_find(ppmacro *macro, const char *name, size_t *idx)
432 for (i = 0; i < vec_size(macro->params); ++i) {
433 if (!strcmp(macro->params[i], name)) {
441 static void ftepp_stringify_token(ftepp_t *ftepp, pptoken *token)
446 switch (token->token) {
447 case TOKEN_STRINGCONST:
450 /* in preprocessor mode strings already are string,
451 * so we don't get actual newline bytes here.
452 * Still need to escape backslashes and quotes.
455 case '\\': ftepp_out(ftepp, "\\\\", false); break;
456 case '"': ftepp_out(ftepp, "\\\"", false); break;
459 ftepp_out(ftepp, chs, false);
466 ftepp_out(ftepp, " ", false);
469 ftepp_out(ftepp, "\\n", false);
472 ftepp_out(ftepp, token->value, false);
477 static void ftepp_stringify(ftepp_t *ftepp, macroparam *param)
480 ftepp_out(ftepp, "\"", false);
481 for (i = 0; i < vec_size(param->tokens); ++i)
482 ftepp_stringify_token(ftepp, param->tokens[i]);
483 ftepp_out(ftepp, "\"", false);
486 static bool ftepp_preprocess(ftepp_t *ftepp);
487 static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *params)
489 char *old_string = ftepp->output_string;
490 lex_file *old_lexer = ftepp->lex;
499 if (!vec_size(macro->output))
502 ftepp->output_string = NULL;
503 for (o = 0; o < vec_size(macro->output); ++o) {
504 pptoken *out = macro->output[o];
505 switch (out->token) {
509 if (!macro_params_find(macro, out->value, &pi)) {
510 ftepp_out(ftepp, out->value, false);
513 for (pv = 0; pv < vec_size(params[pi].tokens); ++pv) {
514 out = params[pi].tokens[pv];
515 if (out->token == TOKEN_EOL)
516 ftepp_out(ftepp, "\n", false);
518 ftepp_out(ftepp, out->value, false);
523 if (o + 1 < vec_size(macro->output)) {
524 nextok = macro->output[o+1]->token;
526 /* raw concatenation */
530 if ( (nextok == TOKEN_IDENT ||
531 nextok == TOKEN_KEYWORD ||
532 nextok == TOKEN_TYPENAME) &&
533 macro_params_find(macro, macro->output[o+1]->value, &pi))
536 ftepp_stringify(ftepp, ¶ms[pi]);
540 ftepp_out(ftepp, "#", false);
543 ftepp_out(ftepp, "\n", false);
546 ftepp_out(ftepp, out->value, false);
550 vec_push(ftepp->output_string, 0);
551 /* Now run the preprocessor recursively on this string buffer */
553 printf("__________\n%s\n=========\n", ftepp->output_string);
555 inlex = lex_open_string(ftepp->output_string, vec_size(ftepp->output_string)-1, ftepp->lex->name);
557 ftepp_error(ftepp, "internal error: failed to instantiate lexer");
561 ftepp->output_string = old_string;
563 if (!ftepp_preprocess(ftepp)) {
564 lex_close(ftepp->lex);
570 ftepp->lex = old_lexer;
571 ftepp->output_string = old_string;
575 static bool ftepp_macro_call(ftepp_t *ftepp, ppmacro *macro)
578 macroparam *params = NULL;
581 if (!macro->has_params) {
582 if (!ftepp_macro_expand(ftepp, macro, NULL))
589 if (!ftepp_skipallwhite(ftepp))
592 if (ftepp->token != '(') {
593 ftepp_error(ftepp, "expected macro parameters in parenthesis");
598 if (!ftepp_macro_call_params(ftepp, ¶ms))
601 if (vec_size(params) != vec_size(macro->params)) {
602 ftepp_error(ftepp, "macro %s expects %u paramteters, %u provided", macro->name,
603 (unsigned int)vec_size(macro->params),
604 (unsigned int)vec_size(params));
609 if (!ftepp_macro_expand(ftepp, macro, params))
614 for (o = 0; o < vec_size(params); ++o)
615 macroparam_clean(¶ms[o]);
621 * #if - the FTEQCC way:
622 * defined(FOO) => true if FOO was #defined regardless of parameters or contents
623 * <numbers> => True if the number is not 0
624 * !<factor> => True if the factor yields false
625 * !!<factor> => ERROR on 2 or more unary nots
626 * <macro> => becomes the macro's FIRST token regardless of parameters
627 * <e> && <e> => True if both expressions are true
628 * <e> || <e> => True if either expression is true
630 * <ident> => False (remember for macros the <macro> rule applies instead)
631 * Unary + and - are weird and wrong in fteqcc so we don't allow them
632 * parenthesis in expressions are allowed
633 * parameter lists on macros are errors
634 * No mathematical calculations are executed
636 static bool ftepp_if_expr(ftepp_t *ftepp, bool *out)
641 if (!ftepp_skipspace(ftepp))
644 while (ftepp->token == '!') {
647 if (!ftepp_skipspace(ftepp))
651 switch (ftepp->token) {
655 if (!strcmp(ftepp_tokval(ftepp), "defined")) {
657 if (!ftepp_skipspace(ftepp))
659 if (ftepp->token != '(') {
660 ftepp_error(ftepp, "`defined` keyword in #if requires a macro name in parenthesis");
664 if (!ftepp_skipspace(ftepp))
666 if (ftepp->token != TOKEN_IDENT &&
667 ftepp->token != TOKEN_TYPENAME &&
668 ftepp->token != TOKEN_KEYWORD)
670 ftepp_error(ftepp, "defined() used on an unexpected token type");
673 macro = ftepp_macro_find(ftepp, ftepp_tokval(ftepp));
676 if (!ftepp_skipspace(ftepp))
678 if (ftepp->token != ')') {
679 ftepp_error(ftepp, "expected closing paren");
685 macro = ftepp_macro_find(ftepp, ftepp_tokval(ftepp));
686 if (!macro || !vec_size(macro->output)) {
689 /* This does not expand recursively! */
690 switch (macro->output[0]->token) {
692 *out = !!(macro->output[0]->constval.f);
694 case TOKEN_FLOATCONST:
695 *out = !!(macro->output[0]->constval.f);
703 case TOKEN_STRINGCONST:
707 *out = !!(ftepp->lex->tok.constval.i);
709 case TOKEN_FLOATCONST:
710 *out = !!(ftepp->lex->tok.constval.f);
715 if (!ftepp_if_expr(ftepp, out))
717 if (ftepp->token != ')') {
718 ftepp_error(ftepp, "expected closing paren in #if expression");
724 ftepp_error(ftepp, "junk in #if");
730 ftepp->lex->flags.noops = false;
732 if (!ftepp_skipspace(ftepp))
734 ftepp->lex->flags.noops = true;
736 if (ftepp->token == ')')
739 if (ftepp->token != TOKEN_OPERATOR)
742 if (!strcmp(ftepp_tokval(ftepp), "&&") ||
743 !strcmp(ftepp_tokval(ftepp), "||"))
746 char opc = ftepp_tokval(ftepp)[0];
749 if (!ftepp_if_expr(ftepp, &next))
759 ftepp_error(ftepp, "junk after #if");
764 static bool ftepp_if(ftepp_t *ftepp, ppcondition *cond)
768 memset(cond, 0, sizeof(*cond));
769 (void)ftepp_next(ftepp);
771 if (!ftepp_skipspace(ftepp))
773 if (ftepp->token == TOKEN_EOL) {
774 ftepp_error(ftepp, "expected expression for #if-directive");
778 if (!ftepp_if_expr(ftepp, &result))
786 * ifdef is rather simple
788 static bool ftepp_ifdef(ftepp_t *ftepp, ppcondition *cond)
791 memset(cond, 0, sizeof(*cond));
792 (void)ftepp_next(ftepp);
793 if (!ftepp_skipspace(ftepp))
796 switch (ftepp->token) {
800 macro = ftepp_macro_find(ftepp, ftepp_tokval(ftepp));
803 ftepp_error(ftepp, "expected macro name");
807 (void)ftepp_next(ftepp);
808 if (!ftepp_skipspace(ftepp))
810 /* relaxing this condition
811 if (ftepp->token != TOKEN_EOL && ftepp->token != TOKEN_EOF) {
812 ftepp_error(ftepp, "stray tokens after #ifdef");
821 * undef is also simple
823 static bool ftepp_undef(ftepp_t *ftepp)
825 (void)ftepp_next(ftepp);
826 if (!ftepp_skipspace(ftepp))
829 if (ftepp->output_on) {
830 switch (ftepp->token) {
834 ftepp_macro_delete(ftepp, ftepp_tokval(ftepp));
837 ftepp_error(ftepp, "expected macro name");
842 (void)ftepp_next(ftepp);
843 if (!ftepp_skipspace(ftepp))
845 /* relaxing this condition
846 if (ftepp->token != TOKEN_EOL && ftepp->token != TOKEN_EOF) {
847 ftepp_error(ftepp, "stray tokens after #ifdef");
854 /* Basic structure handlers */
855 static bool ftepp_else_allowed(ftepp_t *ftepp)
857 if (!vec_size(ftepp->conditions)) {
858 ftepp_error(ftepp, "#else without #if");
861 if (vec_last(ftepp->conditions).had_else) {
862 ftepp_error(ftepp, "multiple #else for a single #if");
868 static bool ftepp_hash(ftepp_t *ftepp)
873 lex_ctx ctx = ftepp_ctx(ftepp);
875 if (!ftepp_skipspace(ftepp))
878 switch (ftepp->token) {
882 if (!strcmp(ftepp_tokval(ftepp), "define")) {
883 return ftepp_define(ftepp);
885 else if (!strcmp(ftepp_tokval(ftepp), "undef")) {
886 return ftepp_undef(ftepp);
888 else if (!strcmp(ftepp_tokval(ftepp), "ifdef")) {
889 if (!ftepp_ifdef(ftepp, &cond))
891 cond.was_on = cond.on;
892 vec_push(ftepp->conditions, cond);
893 ftepp->output_on = ftepp->output_on && cond.on;
896 else if (!strcmp(ftepp_tokval(ftepp), "ifndef")) {
897 if (!ftepp_ifdef(ftepp, &cond))
900 cond.was_on = cond.on;
901 vec_push(ftepp->conditions, cond);
902 ftepp->output_on = ftepp->output_on && cond.on;
905 else if (!strcmp(ftepp_tokval(ftepp), "elifdef")) {
906 if (!ftepp_else_allowed(ftepp))
908 if (!ftepp_ifdef(ftepp, &cond))
910 pc = &vec_last(ftepp->conditions);
911 pc->on = !pc->was_on && cond.on;
912 pc->was_on = pc->was_on || pc->on;
913 ftepp_update_output_condition(ftepp);
916 else if (!strcmp(ftepp_tokval(ftepp), "elifndef")) {
917 if (!ftepp_else_allowed(ftepp))
919 if (!ftepp_ifdef(ftepp, &cond))
922 pc = &vec_last(ftepp->conditions);
923 pc->on = !pc->was_on && cond.on;
924 pc->was_on = pc->was_on || pc->on;
925 ftepp_update_output_condition(ftepp);
928 else if (!strcmp(ftepp_tokval(ftepp), "elif")) {
929 if (!ftepp_else_allowed(ftepp))
931 if (!ftepp_if(ftepp, &cond))
933 pc = &vec_last(ftepp->conditions);
934 pc->on = !pc->was_on && cond.on;
935 pc->was_on = pc->was_on || pc->on;
936 ftepp_update_output_condition(ftepp);
939 else if (!strcmp(ftepp_tokval(ftepp), "if")) {
940 if (!ftepp_if(ftepp, &cond))
942 cond.was_on = cond.on;
943 vec_push(ftepp->conditions, cond);
944 ftepp->output_on = ftepp->output_on && cond.on;
947 else if (!strcmp(ftepp_tokval(ftepp), "else")) {
948 if (!ftepp_else_allowed(ftepp))
950 pc = &vec_last(ftepp->conditions);
951 pc->on = !pc->was_on;
954 ftepp_update_output_condition(ftepp);
957 else if (!strcmp(ftepp_tokval(ftepp), "endif")) {
958 if (!vec_size(ftepp->conditions)) {
959 ftepp_error(ftepp, "#endif without #if");
962 vec_pop(ftepp->conditions);
964 ftepp_update_output_condition(ftepp);
968 ftepp_error(ftepp, "unrecognized preprocessor directive: `%s`", ftepp_tokval(ftepp));
973 ftepp_error(ftepp, "unexpected preprocessor token: `%s`", ftepp_tokval(ftepp));
976 ftepp_errorat(ftepp, ctx, "empty preprocessor directive");
979 ftepp_error(ftepp, "missing newline at end of file", ftepp_tokval(ftepp));
982 /* Builtins! Don't forget the builtins! */
984 case TOKEN_FLOATCONST:
985 ftepp_out(ftepp, "#", false);
988 if (!ftepp_skipspace(ftepp))
993 static bool ftepp_preprocess(ftepp_t *ftepp)
998 ftepp->lex->flags.preprocessing = true;
999 ftepp->lex->flags.mergelines = false;
1000 ftepp->lex->flags.noops = true;
1005 if (ftepp->token >= TOKEN_EOF)
1008 ftepp->newline = newline;
1011 /* For the sake of FTE compatibility... FU, really */
1012 ftepp->newline = newline = true;
1015 switch (ftepp->token) {
1018 case TOKEN_TYPENAME:
1019 macro = ftepp_macro_find(ftepp, ftepp_tokval(ftepp));
1021 ftepp_out(ftepp, ftepp_tokval(ftepp), false);
1025 if (!ftepp_macro_call(ftepp, macro))
1026 ftepp->token = TOKEN_ERROR;
1029 if (!ftepp->newline) {
1030 ftepp_out(ftepp, ftepp_tokval(ftepp), false);
1034 ftepp->lex->flags.mergelines = true;
1035 if (ftepp_next(ftepp) >= TOKEN_EOF) {
1036 ftepp_error(ftepp, "error in preprocessor directive");
1037 ftepp->token = TOKEN_ERROR;
1040 if (!ftepp_hash(ftepp))
1041 ftepp->token = TOKEN_ERROR;
1042 ftepp->lex->flags.mergelines = false;
1046 ftepp_out(ftepp, "\n", true);
1050 ftepp_out(ftepp, ftepp_tokval(ftepp), false);
1054 } while (!ftepp->errors && ftepp->token < TOKEN_EOF);
1056 newline = ftepp->token == TOKEN_EOF;
1060 /* Like in parser.c - files keep the previous state so we have one global
1061 * preprocessor. Except here we will want to warn about dangling #ifs.
1063 static ftepp_t *ftepp;
1065 static bool ftepp_preprocess_done()
1068 lex_close(ftepp->lex);
1070 if (vec_size(ftepp->conditions)) {
1071 if (ftepp_warn(ftepp, WARN_MULTIFILE_IF, "#if spanning multiple files, is this intended?"))
1077 bool ftepp_preprocess_file(const char *filename)
1079 ftepp->lex = lex_open(filename);
1081 con_out("failed to open file \"%s\"\n", filename);
1084 if (!ftepp_preprocess(ftepp)) {
1085 ftepp_delete(ftepp);
1088 return ftepp_preprocess_done();
1091 bool ftepp_preprocess_string(const char *name, const char *str)
1093 ftepp_t *ftepp = ftepp_new();
1094 ftepp->lex = lex_open_string(str, strlen(str), name);
1096 con_out("failed to create lexer for string \"%s\"\n", name);
1099 if (!ftepp_preprocess(ftepp)) {
1100 ftepp_delete(ftepp);
1103 return ftepp_preprocess_done();
1108 ftepp = ftepp_new();
1112 const char *ftepp_get()
1114 return ftepp->output_string;
1119 vec_free(ftepp->output_string);
1126 ftepp_delete(ftepp);