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:
451 case '\\': ftepp_out(ftepp, "\\\\", false); break;
452 case '"': ftepp_out(ftepp, "\\\"", false); break;
455 ftepp_out(ftepp, chs, false);
462 ftepp_out(ftepp, " ", false);
465 ftepp_out(ftepp, "\\n", false);
468 ftepp_out(ftepp, token->value, false);
473 static void ftepp_stringify(ftepp_t *ftepp, macroparam *param)
476 ftepp_out(ftepp, "\"", false);
477 for (i = 0; i < vec_size(param->tokens); ++i)
478 ftepp_stringify_token(ftepp, param->tokens[i]);
479 ftepp_out(ftepp, "\"", false);
482 static bool ftepp_preprocess(ftepp_t *ftepp);
483 static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *params)
485 char *old_string = ftepp->output_string;
486 lex_file *old_lexer = ftepp->lex;
495 if (!vec_size(macro->output))
498 ftepp->output_string = NULL;
499 for (o = 0; o < vec_size(macro->output); ++o) {
500 pptoken *out = macro->output[o];
501 switch (out->token) {
505 if (!macro_params_find(macro, out->value, &pi)) {
506 ftepp_out(ftepp, out->value, false);
509 for (pv = 0; pv < vec_size(params[pi].tokens); ++pv) {
510 out = params[pi].tokens[pv];
511 if (out->token == TOKEN_EOL)
512 ftepp_out(ftepp, "\n", false);
514 ftepp_out(ftepp, out->value, false);
519 if (o + 1 < vec_size(macro->output)) {
520 nextok = macro->output[o+1]->token;
522 /* raw concatenation */
526 if ( (nextok == TOKEN_IDENT ||
527 nextok == TOKEN_KEYWORD ||
528 nextok == TOKEN_TYPENAME) &&
529 macro_params_find(macro, macro->output[o+1]->value, &pi))
532 ftepp_stringify(ftepp, ¶ms[pi]);
536 ftepp_out(ftepp, "#", false);
539 ftepp_out(ftepp, "\n", false);
542 ftepp_out(ftepp, out->value, false);
546 vec_push(ftepp->output_string, 0);
547 /* Now run the preprocessor recursively on this string buffer */
549 printf("__________\n%s\n=========\n", ftepp->output_string);
551 inlex = lex_open_string(ftepp->output_string, vec_size(ftepp->output_string)-1, ftepp->lex->name);
553 ftepp_error(ftepp, "internal error: failed to instantiate lexer");
557 ftepp->output_string = old_string;
559 if (!ftepp_preprocess(ftepp)) {
560 lex_close(ftepp->lex);
566 ftepp->lex = old_lexer;
567 ftepp->output_string = old_string;
571 static bool ftepp_macro_call(ftepp_t *ftepp, ppmacro *macro)
574 macroparam *params = NULL;
577 if (!macro->has_params) {
578 if (!ftepp_macro_expand(ftepp, macro, NULL))
585 if (!ftepp_skipallwhite(ftepp))
588 if (ftepp->token != '(') {
589 ftepp_error(ftepp, "expected macro parameters in parenthesis");
594 if (!ftepp_macro_call_params(ftepp, ¶ms))
597 if (vec_size(params) != vec_size(macro->params)) {
598 ftepp_error(ftepp, "macro %s expects %u paramteters, %u provided", macro->name,
599 (unsigned int)vec_size(macro->params),
600 (unsigned int)vec_size(params));
605 if (!ftepp_macro_expand(ftepp, macro, params))
610 for (o = 0; o < vec_size(params); ++o)
611 macroparam_clean(¶ms[o]);
617 * #if - the FTEQCC way:
618 * defined(FOO) => true if FOO was #defined regardless of parameters or contents
619 * <numbers> => True if the number is not 0
620 * !<factor> => True if the factor yields false
621 * !!<factor> => ERROR on 2 or more unary nots
622 * <macro> => becomes the macro's FIRST token regardless of parameters
623 * <e> && <e> => True if both expressions are true
624 * <e> || <e> => True if either expression is true
626 * <ident> => False (remember for macros the <macro> rule applies instead)
627 * Unary + and - are weird and wrong in fteqcc so we don't allow them
628 * parenthesis in expressions are allowed
629 * parameter lists on macros are errors
630 * No mathematical calculations are executed
632 static bool ftepp_if_expr(ftepp_t *ftepp, bool *out)
637 if (!ftepp_skipspace(ftepp))
640 while (ftepp->token == '!') {
643 if (!ftepp_skipspace(ftepp))
647 switch (ftepp->token) {
651 if (!strcmp(ftepp_tokval(ftepp), "defined")) {
653 if (!ftepp_skipspace(ftepp))
655 if (ftepp->token != '(') {
656 ftepp_error(ftepp, "`defined` keyword in #if requires a macro name in parenthesis");
660 if (!ftepp_skipspace(ftepp))
662 if (ftepp->token != TOKEN_IDENT &&
663 ftepp->token != TOKEN_TYPENAME &&
664 ftepp->token != TOKEN_KEYWORD)
666 ftepp_error(ftepp, "defined() used on an unexpected token type");
669 macro = ftepp_macro_find(ftepp, ftepp_tokval(ftepp));
672 if (!ftepp_skipspace(ftepp))
674 if (ftepp->token != ')') {
675 ftepp_error(ftepp, "expected closing paren");
681 macro = ftepp_macro_find(ftepp, ftepp_tokval(ftepp));
682 if (!macro || !vec_size(macro->output)) {
685 /* This does not expand recursively! */
686 switch (macro->output[0]->token) {
688 *out = !!(macro->output[0]->constval.f);
690 case TOKEN_FLOATCONST:
691 *out = !!(macro->output[0]->constval.f);
699 case TOKEN_STRINGCONST:
703 *out = !!(ftepp->lex->tok.constval.i);
705 case TOKEN_FLOATCONST:
706 *out = !!(ftepp->lex->tok.constval.f);
711 if (!ftepp_if_expr(ftepp, out))
713 if (ftepp->token != ')') {
714 ftepp_error(ftepp, "expected closing paren in #if expression");
720 ftepp_error(ftepp, "junk in #if");
726 ftepp->lex->flags.noops = false;
728 if (!ftepp_skipspace(ftepp))
730 ftepp->lex->flags.noops = true;
732 if (ftepp->token == ')')
735 if (ftepp->token != TOKEN_OPERATOR)
738 if (!strcmp(ftepp_tokval(ftepp), "&&") ||
739 !strcmp(ftepp_tokval(ftepp), "||"))
742 char opc = ftepp_tokval(ftepp)[0];
745 if (!ftepp_if_expr(ftepp, &next))
755 ftepp_error(ftepp, "junk after #if");
760 static bool ftepp_if(ftepp_t *ftepp, ppcondition *cond)
764 memset(cond, 0, sizeof(*cond));
765 (void)ftepp_next(ftepp);
767 if (!ftepp_skipspace(ftepp))
769 if (ftepp->token == TOKEN_EOL) {
770 ftepp_error(ftepp, "expected expression for #if-directive");
774 if (!ftepp_if_expr(ftepp, &result))
782 * ifdef is rather simple
784 static bool ftepp_ifdef(ftepp_t *ftepp, ppcondition *cond)
787 memset(cond, 0, sizeof(*cond));
788 (void)ftepp_next(ftepp);
789 if (!ftepp_skipspace(ftepp))
792 switch (ftepp->token) {
796 macro = ftepp_macro_find(ftepp, ftepp_tokval(ftepp));
799 ftepp_error(ftepp, "expected macro name");
803 (void)ftepp_next(ftepp);
804 if (!ftepp_skipspace(ftepp))
806 /* relaxing this condition
807 if (ftepp->token != TOKEN_EOL && ftepp->token != TOKEN_EOF) {
808 ftepp_error(ftepp, "stray tokens after #ifdef");
817 * undef is also simple
819 static bool ftepp_undef(ftepp_t *ftepp)
821 (void)ftepp_next(ftepp);
822 if (!ftepp_skipspace(ftepp))
825 if (ftepp->output_on) {
826 switch (ftepp->token) {
830 ftepp_macro_delete(ftepp, ftepp_tokval(ftepp));
833 ftepp_error(ftepp, "expected macro name");
838 (void)ftepp_next(ftepp);
839 if (!ftepp_skipspace(ftepp))
841 /* relaxing this condition
842 if (ftepp->token != TOKEN_EOL && ftepp->token != TOKEN_EOF) {
843 ftepp_error(ftepp, "stray tokens after #ifdef");
850 /* Basic structure handlers */
851 static bool ftepp_else_allowed(ftepp_t *ftepp)
853 if (!vec_size(ftepp->conditions)) {
854 ftepp_error(ftepp, "#else without #if");
857 if (vec_last(ftepp->conditions).had_else) {
858 ftepp_error(ftepp, "multiple #else for a single #if");
864 static bool ftepp_hash(ftepp_t *ftepp)
869 lex_ctx ctx = ftepp_ctx(ftepp);
871 if (!ftepp_skipspace(ftepp))
874 switch (ftepp->token) {
878 if (!strcmp(ftepp_tokval(ftepp), "define")) {
879 return ftepp_define(ftepp);
881 else if (!strcmp(ftepp_tokval(ftepp), "undef")) {
882 return ftepp_undef(ftepp);
884 else if (!strcmp(ftepp_tokval(ftepp), "ifdef")) {
885 if (!ftepp_ifdef(ftepp, &cond))
887 cond.was_on = cond.on;
888 vec_push(ftepp->conditions, cond);
889 ftepp->output_on = ftepp->output_on && cond.on;
892 else if (!strcmp(ftepp_tokval(ftepp), "ifndef")) {
893 if (!ftepp_ifdef(ftepp, &cond))
896 cond.was_on = cond.on;
897 vec_push(ftepp->conditions, cond);
898 ftepp->output_on = ftepp->output_on && cond.on;
901 else if (!strcmp(ftepp_tokval(ftepp), "elifdef")) {
902 if (!ftepp_else_allowed(ftepp))
904 if (!ftepp_ifdef(ftepp, &cond))
906 pc = &vec_last(ftepp->conditions);
907 pc->on = !pc->was_on && cond.on;
908 pc->was_on = pc->was_on || pc->on;
909 ftepp_update_output_condition(ftepp);
912 else if (!strcmp(ftepp_tokval(ftepp), "elifndef")) {
913 if (!ftepp_else_allowed(ftepp))
915 if (!ftepp_ifdef(ftepp, &cond))
918 pc = &vec_last(ftepp->conditions);
919 pc->on = !pc->was_on && cond.on;
920 pc->was_on = pc->was_on || pc->on;
921 ftepp_update_output_condition(ftepp);
924 else if (!strcmp(ftepp_tokval(ftepp), "elif")) {
925 if (!ftepp_else_allowed(ftepp))
927 if (!ftepp_if(ftepp, &cond))
929 pc = &vec_last(ftepp->conditions);
930 pc->on = !pc->was_on && cond.on;
931 pc->was_on = pc->was_on || pc->on;
932 ftepp_update_output_condition(ftepp);
935 else if (!strcmp(ftepp_tokval(ftepp), "if")) {
936 if (!ftepp_if(ftepp, &cond))
938 cond.was_on = cond.on;
939 vec_push(ftepp->conditions, cond);
940 ftepp->output_on = ftepp->output_on && cond.on;
943 else if (!strcmp(ftepp_tokval(ftepp), "else")) {
944 if (!ftepp_else_allowed(ftepp))
946 pc = &vec_last(ftepp->conditions);
947 pc->on = !pc->was_on;
950 ftepp_update_output_condition(ftepp);
953 else if (!strcmp(ftepp_tokval(ftepp), "endif")) {
954 if (!vec_size(ftepp->conditions)) {
955 ftepp_error(ftepp, "#endif without #if");
958 vec_pop(ftepp->conditions);
960 ftepp_update_output_condition(ftepp);
964 ftepp_error(ftepp, "unrecognized preprocessor directive: `%s`", ftepp_tokval(ftepp));
969 ftepp_error(ftepp, "unexpected preprocessor token: `%s`", ftepp_tokval(ftepp));
972 ftepp_errorat(ftepp, ctx, "empty preprocessor directive");
975 ftepp_error(ftepp, "missing newline at end of file", ftepp_tokval(ftepp));
978 /* Builtins! Don't forget the builtins! */
980 case TOKEN_FLOATCONST:
981 ftepp_out(ftepp, "#", false);
984 if (!ftepp_skipspace(ftepp))
989 static bool ftepp_preprocess(ftepp_t *ftepp)
994 ftepp->lex->flags.preprocessing = true;
995 ftepp->lex->flags.mergelines = false;
996 ftepp->lex->flags.noops = true;
1001 if (ftepp->token >= TOKEN_EOF)
1004 ftepp->newline = newline;
1007 /* For the sake of FTE compatibility... FU, really */
1008 ftepp->newline = newline = true;
1011 switch (ftepp->token) {
1014 case TOKEN_TYPENAME:
1015 macro = ftepp_macro_find(ftepp, ftepp_tokval(ftepp));
1017 ftepp_out(ftepp, ftepp_tokval(ftepp), false);
1021 if (!ftepp_macro_call(ftepp, macro))
1022 ftepp->token = TOKEN_ERROR;
1025 if (!ftepp->newline) {
1026 ftepp_out(ftepp, ftepp_tokval(ftepp), false);
1030 ftepp->lex->flags.mergelines = true;
1031 if (ftepp_next(ftepp) >= TOKEN_EOF) {
1032 ftepp_error(ftepp, "error in preprocessor directive");
1033 ftepp->token = TOKEN_ERROR;
1036 if (!ftepp_hash(ftepp))
1037 ftepp->token = TOKEN_ERROR;
1038 ftepp->lex->flags.mergelines = false;
1042 ftepp_out(ftepp, "\n", true);
1046 ftepp_out(ftepp, ftepp_tokval(ftepp), false);
1050 } while (!ftepp->errors && ftepp->token < TOKEN_EOF);
1052 newline = ftepp->token == TOKEN_EOF;
1056 /* Like in parser.c - files keep the previous state so we have one global
1057 * preprocessor. Except here we will want to warn about dangling #ifs.
1059 static ftepp_t *ftepp;
1061 static bool ftepp_preprocess_done()
1064 lex_close(ftepp->lex);
1066 if (vec_size(ftepp->conditions)) {
1067 if (ftepp_warn(ftepp, WARN_MULTIFILE_IF, "#if spanning multiple files, is this intended?"))
1073 bool ftepp_preprocess_file(const char *filename)
1075 ftepp->lex = lex_open(filename);
1077 con_out("failed to open file \"%s\"\n", filename);
1080 if (!ftepp_preprocess(ftepp)) {
1081 ftepp_delete(ftepp);
1084 return ftepp_preprocess_done();
1087 bool ftepp_preprocess_string(const char *name, const char *str)
1089 ftepp_t *ftepp = ftepp_new();
1090 ftepp->lex = lex_open_string(str, strlen(str), name);
1092 con_out("failed to create lexer for string \"%s\"\n", name);
1095 if (!ftepp_preprocess(ftepp)) {
1096 ftepp_delete(ftepp);
1099 return ftepp_preprocess_done();
1104 ftepp = ftepp_new();
1108 const char *ftepp_get()
1110 return ftepp->output_string;
1115 vec_free(ftepp->output_string);
1122 ftepp_delete(ftepp);