X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=token.c;h=3d6987478cb30380442668956160ac2745206e18;hb=373937ba4ad87e9fa55dbf89644182050ed1b75a;hp=7d2104cef8f2cad94f0c69ac0a77b9d63fbba399;hpb=b22563a7907265c9ec238d37a5c68fe6491678ef;p=cparser diff --git a/token.c b/token.c index 7d2104c..3d69874 100644 --- a/token.c +++ b/token.c @@ -24,6 +24,7 @@ #include #include +#include #include "symbol.h" #include "lang_features.h" @@ -33,7 +34,7 @@ symbol_t *token_symbols[T_LAST_TOKEN]; -const source_position_t builtin_source_position = { "", 0, 0, true }; +const position_t builtin_position = { "", 0, 0, true }; static token_kind_t last_id; @@ -67,6 +68,11 @@ static void register_pp_token(pp_token_kind_t const id, char const *const string void init_tokens(void) { + static bool tokens_initialized = false; + if (tokens_initialized) + return; + tokens_initialized = true; + memset(token_symbols, 0, T_LAST_TOKEN * sizeof(token_symbols[0])); #define T(mode,x,str,val) register_token(mode, x, str); @@ -95,8 +101,11 @@ void print_token_kind(FILE *f, token_kind_t token_kind) char const *get_string_encoding_prefix(string_encoding_t const enc) { switch (enc) { - case STRING_ENCODING_CHAR: return ""; - case STRING_ENCODING_WIDE: return "L"; + case STRING_ENCODING_CHAR: return ""; + case STRING_ENCODING_CHAR16: return "u"; + case STRING_ENCODING_CHAR32: return "U"; + case STRING_ENCODING_UTF8: return "u8"; + case STRING_ENCODING_WIDE: return "L"; } panic("invalid string encoding"); }