#include #include #include #include struct TableNode; typedef struct { int size; } primitive_info; /*This structure can be subsumed into the structure below (1-d array of chars) typedef struct{ //shouldn't need to store any values since would be compiled at runtime //int length; //char* location; }string_info; */ typedef struct { int numofdimensions; // the above value tells you how long the below array is. For example if // num of dimensions is 5, I can store 1,3,2,5,9 to define > int* // arr; shouldn't need to store any values (like sizes of dimenions or // the location int* sizesofdimensions; do have to store type of array struct TableNode *typeofarray; } array_info; typedef struct { // similar to above we define a record to hold the number of elements // and an array of tablenodes (types) that it contains in the > int numofelements; struct SymbolTable *recordScope; } record_info; typedef struct { int startlinenumber; bool regularoras; } function_declaration_info; typedef struct { struct TableNode *parameter; struct TableNode *returntype; } function_type_info; typedef union { primitive_info *PrimAdInfo; array_info *ArrayAdInfo; record_info *RecAdInfo; // string_info* StringAdInfo; function_declaration_info *FunDecAdInfo; function_type_info *FunTypeAdInfo; } AdInfo; typedef struct ListOfTable { struct SymbolTable *table; // struct ListOfTable* prev; struct ListOfTable *next; } ListOfTable; typedef struct TableNode { // reference to the type entry that this is struct TableNode *theType; char *theName; AdInfo *additionalinfo; struct TableNode *next; } TableNode; typedef struct SymbolTable { TableNode *entries; struct SymbolTable *Parent_Scope; struct ListOfTable *Children_Scope; int Line_Number; int Column_Number; } SymbolTable; SymbolTable *CreateScope(SymbolTable *ParentScope, int Line, int Column); TableNode *table_lookup(SymbolTable *table, char *x); TableNode *look_up(SymbolTable *table, char *x); void print_symbol_table(SymbolTable *table, FILE *file_ptr); SymbolTable *getAncestor(SymbolTable *table); SymbolTable *getParent(SymbolTable *st); ListOfTable *getChildren(SymbolTable *st); SymbolTable *getFirstChild(ListOfTable *lt); ListOfTable *getRestOfChildren(ListOfTable *lt); TableNode *getFirstEntry(SymbolTable *st); TableNode *getNextEntry(TableNode *tn); SymbolTable *init(SymbolTable *scope); int getPrimSize(TableNode *definition); int getNumArrDim(TableNode *definition); TableNode *getArrType(TableNode *definition); int getRecLength(TableNode *definition); SymbolTable *getRecList(TableNode *definition); int getStartLine(TableNode *definition); bool getAsKeyword(TableNode *definition); TableNode *getParameter(TableNode *definition); TableNode *getReturn(TableNode *definition); char *getType(TableNode *tn); char *getName(TableNode *tn); int getLine(SymbolTable *st); int getColumn(SymbolTable *st);