X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=token.c;h=c9b0de859dfae002c8b8d6a37f16139866cd362c;hb=d2bf8b03b1aec5141800a300c62595930023ad79;hp=5f395c70dcf8517b02209db6a6c33cfc00f257b3;hpb=42e9d19f816a47115767a727e8a0c25ba49262cc;p=cparser diff --git a/token.c b/token.c index 5f395c7..c9b0de8 100644 --- a/token.c +++ b/token.c @@ -134,7 +134,7 @@ void print_token(FILE *f, const token_t *token) { switch(token->kind) { case T_IDENTIFIER: - fprintf(f, "identifier '%s'", token->identifier.symbol->string); + fprintf(f, "identifier '%s'", token->base.symbol->string); break; case T_INTEGER: case T_FLOATINGPOINT: @@ -157,10 +157,15 @@ void print_token(FILE *f, const token_t *token) print_stringrep(&token->string.string, f); fputs("'", f); break; + default: - fputc('\'', f); - print_token_kind(f, (token_kind_t)token->kind); - fputc('\'', f); + if (token->base.symbol) { + fprintf(f, "'%s'", token->base.symbol->string); + } else { + fputc('\'', f); + print_token_kind(f, (token_kind_t)token->kind); + fputc('\'', f); + } break; } } @@ -194,7 +199,7 @@ void print_pp_token(FILE *f, const token_t *token) { switch((preprocessor_token_kind_t) token->kind) { case TP_IDENTIFIER: - fprintf(f, "identifier '%s'", token->identifier.symbol->string); + fprintf(f, "identifier '%s'", token->base.symbol->string); break; case TP_NUMBER: fprintf(f, "number '%s'", token->number.number.begin);