restructured table, still have to update print table properly as well as grammar rules
This commit is contained in:
@ -3,6 +3,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct TableNode;
|
||||
|
||||
typedef struct{
|
||||
int size;
|
||||
}primitive_info;
|
||||
@ -21,12 +23,13 @@ typedef struct{
|
||||
//shouldn't need to store any values (like sizes of dimenions or the location
|
||||
//int* sizesofdimensions;
|
||||
//do have to store type of array
|
||||
TableNode* typeofarray;
|
||||
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;
|
||||
TableNode* listoftypes;
|
||||
//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 TableNode* listoftypes;
|
||||
}record_info;
|
||||
|
||||
typedef struct{
|
||||
@ -35,8 +38,8 @@ typedef struct{
|
||||
}function_declaration_info;
|
||||
|
||||
typedef struct{
|
||||
TableNode* parameter;
|
||||
TableNode* returntype;
|
||||
struct TableNode* parameter;
|
||||
struct TableNode* returntype;
|
||||
}function_type_info;
|
||||
|
||||
typedef union {
|
||||
@ -44,8 +47,8 @@ typedef union {
|
||||
array_info* ArrayAdInfo;
|
||||
record_info* RecAdInfo;
|
||||
//string_info* StringAdInfo;
|
||||
func_dec_info* FunDecAdInfo;
|
||||
func_type_info* FunTypeAdInfo;
|
||||
function_declaration_info* FunDecAdInfo;
|
||||
function_type_info* FunTypeAdInfo;
|
||||
}AdInfo;
|
||||
|
||||
typedef struct ListOfTable {
|
||||
@ -56,11 +59,11 @@ typedef struct ListOfTable {
|
||||
|
||||
typedef struct TableNode {
|
||||
//reference to the type entry that this is
|
||||
TableNode* theType;
|
||||
struct TableNode* theType;
|
||||
char* theName;
|
||||
AdInfo* additionalinfo;
|
||||
struct TableNode* next;
|
||||
} TableNode;
|
||||
}TableNode;
|
||||
|
||||
typedef struct SymbolTable {
|
||||
TableNode* entries;
|
||||
@ -71,7 +74,6 @@ typedef struct SymbolTable {
|
||||
} SymbolTable;
|
||||
|
||||
SymbolTable* CreateScope(SymbolTable* ParentScope, int Line, int Column);
|
||||
TableNode* CreateEntry(SymbolTable* table, char* typeOf, char* id);
|
||||
TableNode* table_lookup(SymbolTable* table, char* x);
|
||||
TableNode* look_up(SymbolTable* table, char* x);
|
||||
void print_symbol_table(SymbolTable* table, FILE* file_ptr);
|
||||
@ -83,6 +85,7 @@ SymbolTable* getFirstChild(ListOfTable* lt);
|
||||
ListOfTable* getRestOfChildren(ListOfTable* lt);
|
||||
TableNode* getFirstEntry(SymbolTable* st);
|
||||
TableNode* getNextEntry(TableNode* tn);
|
||||
SymbolTable* init(SymbolTable* scope);
|
||||
char* getType(TableNode* tn);
|
||||
char* getName(TableNode* tn);
|
||||
int getLine(SymbolTable* st);
|
||||
|
Reference in New Issue
Block a user