Simplify get_symbol_from_token(): All keywords have symbols.
authorChristoph Mallon <christoph.mallon@gmx.de>
Fri, 4 May 2012 17:48:43 +0000 (19:48 +0200)
committerChristoph Mallon <christoph.mallon@gmx.de>
Sat, 5 May 2012 21:09:53 +0000 (23:09 +0200)
parser.c
token.c
token_t.h

index a9ebe44..94982af 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -1136,40 +1136,20 @@ static attribute_t *parse_attribute_asm(void)
 static symbol_t *get_symbol_from_token(void)
 {
        switch(token.kind) {
-       case T_IDENTIFIER:
-               return token.identifier.symbol;
-       case T_auto:
-       case T_char:
-       case T_double:
-       case T_enum:
-       case T_extern:
-       case T_float:
-       case T_int:
-       case T_long:
-       case T_register:
-       case T_short:
-       case T_static:
-       case T_struct:
-       case T_union:
-       case T_unsigned:
-       case T_void:
-       case T_bool:
-       case T__Bool:
-       case T_class:
-       case T_explicit:
-       case T_export:
-       case T_wchar_t:
-       case T_const:
-       case T_signed:
-       case T___real__:
-       case T___imag__:
-       case T_restrict:
-       case T_volatile:
-       case T_inline:
-               /* maybe we need more tokens ... add them on demand */
-               return get_token_kind_symbol(token.kind);
-       default:
+       case T_CHARACTER_CONSTANT:
+       case T_EOF:
+       case T_FLOATINGPOINT:
+       case T_FLOATINGPOINT_HEXADECIMAL:
+       case T_INTEGER:
+       case T_INTEGER_HEXADECIMAL:
+       case T_INTEGER_OCTAL:
+       case T_STRING_LITERAL:
+       case T_WIDE_CHARACTER_CONSTANT:
+       case T_WIDE_STRING_LITERAL:
                return NULL;
+
+       default:
+               return token.identifier.symbol;
        }
 }
 
diff --git a/token.c b/token.c
index 51f9dc5..a0a7d7e 100644 (file)
--- a/token.c
+++ b/token.c
@@ -123,11 +123,6 @@ void print_token_kind(FILE *f, token_kind_t token_kind)
        }
 }
 
-symbol_t *get_token_kind_symbol(int kind)
-{
-       return token_symbols[kind];
-}
-
 static void print_stringrep(const string_t *string, FILE *f)
 {
        for (size_t i = 0; i < string->size; ++i) {
index 858f3bb..831afd7 100644 (file)
--- a/token_t.h
+++ b/token_t.h
@@ -99,8 +99,6 @@ void exit_tokens(void);
 void print_token_kind(FILE *out, token_kind_t token_kind);
 void print_token(FILE *out, const token_t *token);
 
-symbol_t *get_token_kind_symbol(int token_kind);
-
 void print_pp_token_kind(FILE *out, int kind);
 void print_pp_token(FILE *out, const token_t *token);