TOKEN parameter_declaration(void) { SYMBOL s = symalloc(); TOKEN dec = NULL; declaration_specifiers(s); dec = declarator(s); set_token_symbol_type(dec,s); return dec; }
TOKEN external_declaration(void) { TOKEN ext_declaration = NULL; SYMBOL sym = symalloc(); //symbol for the declaration we are dealing with //used as a temporary place to aggregate data about the declaration until //we can install the symbol //NOTE: we check for a global declaration first because we can easily use //the information we aggregate in the SYMBOL sym and pass it on rather than //having to backtrack like we would if we looked for a function definition first setStorageClass(sym, STATIC_STORAGE_CLASS); ext_declaration = declaration(sym); if( NULL == ext_declaration ) { //we have a function definition instead of a global variable declaration //and functions default to external storage setStorageClass(sym, EXTERNAL_STORAGE_CLASS); ext_declaration = function_definition(sym); } else { ext_declaration = NULL; //we don't want the variable declaration to make its way into the parse tree, so return NULL } return ext_declaration; }
/* Allocate a new entry for name and install it. */ struct symbol * install(char *name, ScopeType scope) { int h; struct symbol *p; p = symalloc(name); h = hash(name); p->next = htab[h]; p->scope = scope; p->type = MincVoidType; htab[h] = p; p->v.number = 0.0; DPRINT2("install ('%s') => %p\n", name, p); return p; }