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, typ;

sym = searchst(tok->stringval);
tok->symentry = sym;
typ = sym->datatype;
tok->symtype = typ;
if ( typ->kind == BASICTYPE ||
     typ->kind == POINTERSYM)
    tok->datatype = typ->basicdt;