2012-11-02 17:28:54 +00:00
|
|
|
#include "gmqcc.h"
|
|
|
|
#include "lexer.h"
|
|
|
|
|
|
|
|
bool preprocess(const char *filename)
|
|
|
|
{
|
|
|
|
int tok;
|
|
|
|
lex_file *lex = lex_open(filename);
|
|
|
|
lex->flags.preprocessing = true;
|
|
|
|
|
|
|
|
do {
|
|
|
|
tok = lex_do(lex);
|
2012-11-02 17:48:32 +00:00
|
|
|
#if 0
|
2012-11-02 17:28:54 +00:00
|
|
|
if (tok == TOKEN_EOL)
|
|
|
|
printf("EOL");
|
|
|
|
else if (tok >= TOKEN_START && tok <= TOKEN_FATAL)
|
|
|
|
printf("%s: ", _tokennames[tok - TOKEN_START]);
|
|
|
|
else
|
|
|
|
printf("TOKEN: '%c'", tok);
|
|
|
|
if (tok == TOKEN_WHITE)
|
|
|
|
printf(">>%s<<\n", lex->tok.value);
|
|
|
|
else
|
|
|
|
printf("\n");
|
2012-11-02 17:48:32 +00:00
|
|
|
#else
|
2012-11-02 17:37:58 +00:00
|
|
|
if (tok == TOKEN_EOL)
|
|
|
|
printf("\n");
|
|
|
|
else if (tok >= TOKEN_START && tok < TOKEN_EOF)
|
|
|
|
printf("%s", lex->tok.value);
|
|
|
|
else
|
|
|
|
printf("%c", tok);
|
2012-11-02 17:48:32 +00:00
|
|
|
#endif
|
2012-11-02 17:28:54 +00:00
|
|
|
} while (tok < TOKEN_EOF);
|
|
|
|
|
|
|
|
lex_close(lex);
|
|
|
|
return true;
|
|
|
|
}
|