Contents    Page-10    Prev    Next    Page+10    Index   

Looking up ID in Symbol Table

An identifier that is encountered in executable code must be linked to its appropriate symbol table entries:


TOKEN findid(TOKEN tok) { /* the ID token */
SYMBOL sym = searchst(tok->stringval);
tok->symentry = sym;
SYMBOL typ = sym->datatype;
tok->symtype = typ;
if ( typ->kind == BASICTYPE ||
     typ->kind == POINTERSYM)
    tok->basicdt = typ->basicdt;
return tok; }