ref: 87fe94c89193c60d778a364c67f8885b58df3dec
parent: f18d5404c710db34fcd2a945ba0fddb9e70d80c5
author: Roberto E. Vargas Caballero <[email protected]>
date: Sun Mar 9 12:24:11 EDT 2014
Use a STORAGE token This token help us in order to know that the next token is the name of a storage specifier, so it is easier to detect a declaration.
--- a/decl.c
+++ b/decl.c
@@ -181,9 +181,8 @@
case CONST: case VOLATILE:
qlf = qualifier(qlf, yytoken);
break;
- case TYPEDEF: case EXTERN: case STATIC:
- case AUTO: case REGISTER:
- store = storage(store, yytoken);
+ case STORAGE:
+ store = storage(store, yyval->c);
break;
case TYPE:
tp = ctype(tp, yyval->c);
--- a/lex.c
+++ b/lex.c
@@ -123,7 +123,7 @@
init_keywords(void)
{
static struct keyword buff[] = {
- {"auto", AUTO, AUTO},
+ {"auto", STORAGE, AUTO},
{"break", BREAK, BREAK},
{"_Bool", TYPE, BOOL},
{"_Complex", TYPE, COMPLEX},
@@ -136,7 +136,7 @@
{"double", TYPE, DOUBLE},
{"else", ELSE, ELSE},
{"enum", ENUM, ENUM},
- {"extern", EXTERN, EXTERN},
+ {"extern", STORAGE, EXTERN},
{"float", TYPE, FLOAT},
{"for", FOR, FOR},
{"goto", GOTO, GOTO},
@@ -144,16 +144,16 @@
{"int", TYPE, INT},
{"_Imaginary", TYPE, IMAGINARY},
{"long", TYPE, LONG},
- {"register", REGISTER, REGISTER},
+ {"register", STORAGE, REGISTER},
{"restricted", RESTRICT, RESTRICT},
{"return", RETURN, RETURN},
{"short", TYPE, SHORT},
{"signed", TYPE, SIGNED},
{"sizeof", SIZEOF, SIZEOF},
- {"static", STATIC, STATIC},
+ {"static", STORAGE, STATIC},
{"struct", STRUCT, STRUCT},
{"switch", SWITCH, SWITCH},
- {"typedef", TYPEDEF, TYPEDEF},
+ {"typedef", STORAGE, TYPEDEF},
{"union", UNION, UNION},
{"unsigned", TYPE, UNSIGNED},
{"void", TYPE, VOID},
--- a/tokens.h
+++ b/tokens.h
@@ -13,7 +13,7 @@
LDOUBLE, STRUCT, UNION, ENUM, BOOL, ARY, PTR, FTN,
COMPLEX, IMAGINARY, BITFLD, TYPE,
/* storage specifier */
- TYPEDEF, EXTERN, STATIC, AUTO, REGISTER,
+ TYPEDEF, EXTERN, STATIC, AUTO, REGISTER, STORAGE,
/* type qualifier */
VOLATILE, CONST, RESTRICT,
/* sign specifier */