preproc: Add dump_token helper

While being debugging some nifty problem I found
that it might be useful to produce a full dump of
tokens, in particular text of tokens.

For this reason dump_token is here just to not loose
it. It doesn't affect normal build procedure since it
requires a special -DNASM_TRACE to be passed to the
compiler. Which of course we don't in a regular
compilations.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
Cyrill Gorcunov 2010-11-11 15:06:12 +03:00
parent 574fbf1972
commit 49e8f698fc

View File

@ -483,6 +483,24 @@ static ExpInv *new_ExpInv(int exp_type, ExpDef *ed);
#define tok_is_(x,v) (tok_type_((x), TOK_OTHER) && !strcmp((x)->text,(v)))
#define tok_isnt_(x,v) ((x) && ((x)->type!=TOK_OTHER || strcmp((x)->text,(v))))
#ifdef NASM_TRACE
#define dump_token(t) raw_dump_token(t, __FILE__, __LINE__, __func__);
static void raw_dump_token(Token *token, const char *file, int line, const char *func)
{
printf("---[%s (%s:%d): %p]---\n", func, file, line, (void *)token);
if (token) {
Token *t;
list_for_each(t, token) {
if (t->text)
printf("'%s' ", t->text);
}
printf("\n");
}
}
#endif
/*
* nasm_unquote with error if the string contains NUL characters.
* If the string contains NUL characters, issue an error and return