]> de.git.xonotic.org Git - xonotic/gmqcc.git/blob - preprocess.c
Finishing the preprocessing flag for the lexer, added preprocess.c to test it
[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 (tok == TOKEN_EOL)
13             printf("EOL");
14         else if (tok >= TOKEN_START && tok <= TOKEN_FATAL)
15             printf("%s: ", _tokennames[tok - TOKEN_START]);
16         else
17             printf("TOKEN: '%c'", tok);
18         if (tok == TOKEN_WHITE)
19             printf(">>%s<<\n", lex->tok.value);
20         else
21             printf("\n");
22     } while (tok < TOKEN_EOF);
23
24     lex_close(lex);
25     return true;
26 }