]> git.xonotic.org Git - xonotic/gmqcc.git/blob - preprocess.c
55878a04d5bf544d1be487e92ba9f5061758419a
[xonotic/gmqcc.git] / preprocess.c
1 #include "gmqcc.h"
2 #include "lexer.h"
3
4 bool preprocess(const char *filename)
5 {
6     int tok;
7     lex_file *lex = lex_open(filename);
8     lex->flags.preprocessing = true;
9
10     do {
11         tok = lex_do(lex);
12 #if 0
13         if (tok == TOKEN_EOL)
14             printf("EOL");
15         else if (tok >= TOKEN_START && tok <= TOKEN_FATAL)
16             printf("%s: ", _tokennames[tok - TOKEN_START]);
17         else
18             printf("TOKEN: '%c'", tok);
19         if (tok == TOKEN_WHITE)
20             printf(">>%s<<\n", lex->tok.value);
21         else
22             printf("\n");
23 #else
24         if (tok == TOKEN_EOL)
25             printf("\n");
26         else if (tok >= TOKEN_START && tok < TOKEN_EOF)
27             printf("%s", lex->tok.value);
28         else if (tok < TOKEN_START)
29             printf("%c", tok); /* these are characters */
30 #endif
31     } while (tok < TOKEN_EOF);
32
33     lex_close(lex);
34     return true;
35 }