scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit 87fe94c89193c60d778a364c67f8885b58df3dec
parent f18d5404c710db34fcd2a945ba0fddb9e70d80c5
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun,  9 Mar 2014 16:24:11 +0100

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.

Diffstat:
decl.c | 5++---
lex.c | 10+++++-----
tokens.h | 2+-
3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/decl.c b/decl.c @@ -181,9 +181,8 @@ specifier(register struct ctype *tp, 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); diff --git a/lex.c b/lex.c @@ -123,7 +123,7 @@ void 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 @@ init_keywords(void) {"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 @@ init_keywords(void) {"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}, diff --git a/tokens.h b/tokens.h @@ -13,7 +13,7 @@ enum tokens { 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 */