Partially implement -Wdeprecated-declarations.
[cparser] / token.c
diff --git a/token.c b/token.c
index 5c5df4c..946f510 100644 (file)
--- a/token.c
+++ b/token.c
@@ -32,7 +32,7 @@
 static symbol_t *token_symbols[T_LAST_TOKEN];
 static symbol_t *pp_token_symbols[TP_LAST_TOKEN];
 
-source_position_t builtin_source_position = { "<built-in>", 0 };
+const source_position_t builtin_source_position = { "<built-in>", 0 };
 
 void init_tokens(void)
 {
@@ -51,13 +51,15 @@ void init_tokens(void)
                assert(T_##x >= 0 && T_##x < T_LAST_TOKEN);                \
                symbol               = symbol_table_insert(str);           \
                symbol->ID           = T_##x;                              \
-               token_symbols[T_##x] = symbol;                             \
+               if (token_symbols[T_##x] == NULL)                          \
+                       token_symbols[T_##x] = symbol;                         \
        }
 
 #define TS(x,str,val)                                              \
        assert(T_##x >= 0 && T_##x < T_LAST_TOKEN);                    \
        symbol               = symbol_table_insert(str);               \
-       token_symbols[T_##x] = symbol;
+       if (token_symbols[T_##x] == NULL)                              \
+               token_symbols[T_##x] = symbol;                             \
 
 #include "tokens.inc"
 
@@ -68,12 +70,14 @@ void init_tokens(void)
        assert(TP_##x >= 0 && TP_##x < TP_LAST_TOKEN);                 \
        symbol                   = symbol_table_insert(str);           \
        symbol->pp_ID            = TP_##x;                             \
-       pp_token_symbols[TP_##x] = symbol;
+       if (pp_token_symbols[TP_##x] == NULL)                          \
+               pp_token_symbols[TP_##x] = symbol;
 
 #define TS(x,str,val)                                              \
        assert(TP_##x >= 0 && TP_##x < T_LAST_TOKEN);                  \
        symbol                   = symbol_table_insert(str);           \
-       pp_token_symbols[TP_##x] = symbol;
+       if (pp_token_symbols[TP_##x] == NULL)                          \
+               pp_token_symbols[TP_##x] = symbol;
 
 #include "tokens_preprocessor.inc"
 
@@ -170,7 +174,7 @@ void print_pp_token(FILE *f, const token_t *token)
                fprintf(f, "symbol '%s'", token->v.symbol->string);
                break;
        case TP_NUMBER:
-               fprintf(f, "number %lld", token->v.intvalue);
+               fprintf(f, "number %s", token->v.string.begin);
                break;
        case TP_STRING_LITERAL:
                fprintf(f, "string '%s'", token->v.string.begin);