Remove the unnecessary distinction between T_INTEGER, T_INTEGER_HEXADECIMAL and T_INT...
authorChristoph Mallon <christoph.mallon@gmx.de>
Sun, 6 May 2012 17:25:33 +0000 (19:25 +0200)
committerChristoph Mallon <christoph.mallon@gmx.de>
Sun, 6 May 2012 18:07:07 +0000 (20:07 +0200)
Just keep T_INTEGER.

lexer.c
parser.c
token.c
tokens.inc

diff --git a/lexer.c b/lexer.c
index 1ad3b89..0aa07ab 100644 (file)
--- a/lexer.c
+++ b/lexer.c
@@ -388,7 +388,7 @@ static void parse_number_hex(void)
        lexer_token.number.number = identify_string(string, size);
 
        lexer_token.kind    =
-               is_float ? T_FLOATINGPOINT_HEXADECIMAL : T_INTEGER_HEXADECIMAL;
+               is_float ? T_FLOATINGPOINT_HEXADECIMAL : T_INTEGER;
 
        if (!has_digits) {
                errorf(&lexer_token.base.source_position, "invalid number literal '%S'", &lexer_token.number.number);
@@ -460,21 +460,19 @@ static void parse_number(void)
        char   *string = obstack_finish(&symbol_obstack);
        lexer_token.number.number = identify_string(string, size);
 
-       /* is it an octal number? */
        if (is_float) {
                lexer_token.kind = T_FLOATINGPOINT;
-       } else if (string[0] == '0') {
-               lexer_token.kind = T_INTEGER_OCTAL;
-
-               /* check for invalid octal digits */
-               for (size_t i= 0; i < size; ++i) {
-                       char t = string[i];
-                       if (t >= '8')
-                               errorf(&lexer_token.base.source_position,
-                                      "invalid digit '%c' in octal number", t);
-               }
        } else {
                lexer_token.kind = T_INTEGER;
+
+               if (string[0] == '0') {
+                       /* check for invalid octal digits */
+                       for (size_t i= 0; i < size; ++i) {
+                               char t = string[i];
+                               if (t >= '8')
+                                       errorf(&lexer_token.base.source_position, "invalid digit '%c' in octal number", t);
+                       }
+               }
        }
 
        if (!has_digits) {
index 6556b09..be86418 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -250,8 +250,6 @@ static void semantic_comparison(binary_expression_t *expression);
        case T_FLOATINGPOINT:             \
        case T_FLOATINGPOINT_HEXADECIMAL: \
        case T_INTEGER:                   \
-       case T_INTEGER_HEXADECIMAL:       \
-       case T_INTEGER_OCTAL:             \
        case T_MINUSMINUS:                \
        case T_PLUSPLUS:                  \
        case T_STRING_LITERAL:            \
@@ -1144,8 +1142,6 @@ static symbol_t *get_symbol_from_token(void)
        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:
@@ -5855,8 +5851,6 @@ static expression_t *parse_number_literal(void)
 
        switch (token.kind) {
        case T_INTEGER:
-       case T_INTEGER_OCTAL:
-       case T_INTEGER_HEXADECIMAL:
                kind = EXPR_LITERAL_INTEGER;
                check_integer_suffix();
                type = type_int;
@@ -6765,8 +6759,6 @@ static expression_t *parse_primary_expression(void)
        case T_false:                        return parse_boolean_literal(false);
        case T_true:                         return parse_boolean_literal(true);
        case T_INTEGER:
-       case T_INTEGER_OCTAL:
-       case T_INTEGER_HEXADECIMAL:
        case T_FLOATINGPOINT:
        case T_FLOATINGPOINT_HEXADECIMAL:    return parse_number_literal();
        case T_CHARACTER_CONSTANT:           return parse_character_constant();
diff --git a/token.c b/token.c
index a0a7d7e..6e53a6c 100644 (file)
--- a/token.c
+++ b/token.c
@@ -137,8 +137,6 @@ void print_token(FILE *f, const token_t *token)
                fprintf(f, "identifier '%s'", token->identifier.symbol->string);
                break;
        case T_INTEGER:
-       case T_INTEGER_OCTAL:
-       case T_INTEGER_HEXADECIMAL:
        case T_FLOATINGPOINT:
        case T_FLOATINGPOINT_HEXADECIMAL:
                print_token_kind(f, (token_kind_t)token->kind);
index cbe19ec..f8d35e0 100644 (file)
@@ -11,8 +11,6 @@
 
 TS(IDENTIFIER,                "identifier",)
 TS(INTEGER,                   "integer number",)
-TS(INTEGER_OCTAL,             "octal integer number",)
-TS(INTEGER_HEXADECIMAL,       "hexadecimal integer number",)
 TS(FLOATINGPOINT,             "floatingpoint number",)
 TS(FLOATINGPOINT_HEXADECIMAL, "hexadecimal floatingpoint number",)
 TS(CHARACTER_CONSTANT,        "character constant",)