How to generate a symbol table for a Pascal-subset compiler in C? -
i'm writing compiler in c, interpret pseudo-pascal instructions (their syntax irrelevant) asm
output. know now, need:
- a syntax scanner scan user input , identify tokens parser process
- a parser check if tokens fit defined grammar productions
- a symbol table
i'm little bit stuck on important phase - symbol table. i'm unsure should included in table. variables (identifiers), address. should include keywords such if
, for
etc? guidelines on appreciated.
for now, think logical way define structure:
struct entry{ char* name; vartype vartype; int address; }
where vartype
enum available variable types (integer
, real
). ofc make array of structures , expand when necessary. how , when should modify it?
here awsome free book: compiler design in c
Comments
Post a Comment