scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 91886b417645874398263b84f186d8bffe40e805
parent 203eee14a2e6b32e23d94c0dfff68b32346609d3
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri,  8 Aug 2014 16:35:33 +0200

Add type field in Symbols

This field is necessary if we want to know what we have.

Diffstat:
Mcc2/cc2.h | 2++
Mcc2/parser.c | 3+++
2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/cc2/cc2.h b/cc2/cc2.h @@ -1,6 +1,7 @@ typedef struct symbol { char public; + char type; struct symbol *next; union { struct { @@ -46,6 +47,7 @@ enum nerrors { }; #define FUNCTION 0 +#define VARIABLE 1 #define AUTO 'A' #define REGISTER 'R' #define STATIC 'T' diff --git a/cc2/parser.c b/cc2/parser.c @@ -208,6 +208,7 @@ declaration(char *token) case 'G': case 'R': case 'T': break; } + sym->type = VARIABLE; sym->u.v.storage = class; sym->u.v.type = gettype(strtok(NULL, "\t")); } @@ -218,6 +219,7 @@ deflabel(char *token) Symbol *sym; sym = local(token); + sym->type = LABEL; sym->u.l.addr = listp - listexp; } @@ -228,6 +230,7 @@ function(char *token) curfun = global(token); if ((token = strtok(NULL, "\t")) == NULL) error(ESYNTAX); + curfun->type = FUNCTION; curfun->u.f.name = xstrdup(token); listp = listexp; newp = nodepool;