Fixed -tok, spacings in -st, and validation tests
This commit is contained in:
@ -7,80 +7,79 @@
|
||||
#define SIZE_INT 4
|
||||
#define SIZE_ADDR 8
|
||||
#define SIZE_CHAR 1
|
||||
#define SIZE_BOOL 4 //TODO: Ask Carl what this size should be
|
||||
|
||||
#define SIZE_BOOL 4 //TODO: Ask Carl what this size should be
|
||||
|
||||
struct TableNode;
|
||||
|
||||
typedef struct {
|
||||
int size;
|
||||
int size;
|
||||
} primitive_info;
|
||||
|
||||
typedef struct {
|
||||
int numofdimensions;
|
||||
struct TableNode *typeofarray;
|
||||
int numofdimensions;
|
||||
struct TableNode *typeofarray;
|
||||
} array_info;
|
||||
|
||||
typedef struct {
|
||||
int numofelements;
|
||||
struct SymbolTable *recordScope;
|
||||
int total_size;
|
||||
int* offsets;
|
||||
int numofelements;
|
||||
struct SymbolTable *recordScope;
|
||||
int total_size;
|
||||
int *offsets;
|
||||
} record_info;
|
||||
|
||||
typedef struct {
|
||||
int startlinenumber;
|
||||
bool regularoras;
|
||||
int startlinenumber;
|
||||
bool regularoras;
|
||||
} function_declaration_info;
|
||||
|
||||
typedef struct {
|
||||
struct TableNode *parameter;
|
||||
struct TableNode *returntype;
|
||||
struct TableNode *parameter;
|
||||
struct TableNode *returntype;
|
||||
} function_type_info;
|
||||
|
||||
typedef union {
|
||||
primitive_info *PrimAdInfo;
|
||||
array_info *ArrayAdInfo;
|
||||
record_info *RecAdInfo;
|
||||
function_declaration_info *FunDecAdInfo;
|
||||
function_type_info *FunTypeAdInfo;
|
||||
primitive_info *PrimAdInfo;
|
||||
array_info *ArrayAdInfo;
|
||||
record_info *RecAdInfo;
|
||||
function_declaration_info *FunDecAdInfo;
|
||||
function_type_info *FunTypeAdInfo;
|
||||
} AdInfo;
|
||||
|
||||
typedef struct ListOfTable {
|
||||
struct SymbolTable *table;
|
||||
struct ListOfTable *next;
|
||||
struct SymbolTable *table;
|
||||
struct ListOfTable *next;
|
||||
} ListOfTable;
|
||||
|
||||
//Table node to store
|
||||
typedef struct TableNode {
|
||||
struct TableNode *theType;
|
||||
int tag;
|
||||
char *theName;
|
||||
AdInfo *additionalinfo;
|
||||
struct TableNode *next;
|
||||
struct TableNode *theType;
|
||||
int tag;
|
||||
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;
|
||||
TableNode *entries;
|
||||
struct SymbolTable *Parent_Scope;
|
||||
struct ListOfTable *Children_Scope;
|
||||
int Line_Number;
|
||||
int Column_Number;
|
||||
} SymbolTable;
|
||||
|
||||
typedef enum {
|
||||
TYPE_STRING = 1,
|
||||
TYPE_ARRAY_TYPE = 2,
|
||||
TYPE_RECORD_TYPE = 3,
|
||||
TYPE_FUNCTION_DECLARATION = 4,
|
||||
TYPE_FUNCTION_TYPE = 5,
|
||||
TYPE_PRIMITIVE = 6,
|
||||
TYPE_ALL_ELSE = 7,
|
||||
TYPE_UNDEFINED = 8,
|
||||
TYPE_RECORD = 9,
|
||||
TYPE_ARRAY = 10,
|
||||
TYPE_SYSTEM_DEFINED = 11,
|
||||
TYPE_PRIMITIVE_TYPE = 12
|
||||
TYPE_STRING = 1,
|
||||
TYPE_ARRAY_TYPE = 2,
|
||||
TYPE_RECORD_TYPE = 3,
|
||||
TYPE_FUNCTION_DECLARATION = 4,
|
||||
TYPE_FUNCTION_TYPE = 5,
|
||||
TYPE_PRIMITIVE = 6,
|
||||
TYPE_ALL_ELSE = 7,
|
||||
TYPE_UNDEFINED = 8,
|
||||
TYPE_RECORD = 9,
|
||||
TYPE_ARRAY = 10,
|
||||
TYPE_SYSTEM_DEFINED = 11,
|
||||
TYPE_PRIMITIVE_TYPE = 12
|
||||
} types;
|
||||
|
||||
AdInfo *CreatePrimitiveInfo(int size);
|
||||
@ -128,10 +127,10 @@ ListOfTable *getRestOfChildren(ListOfTable *lt);
|
||||
TableNode *getFirstEntry(SymbolTable *st);
|
||||
TableNode *getNextEntry(TableNode *tn);
|
||||
|
||||
TableNode * printTableNode(TableNode * tn);
|
||||
TableNode *printTableNode(TableNode *tn);
|
||||
void printdebug_impl(char *file, int line, const char *format, ...);
|
||||
#define printdebug(format, ...) \
|
||||
printdebug_impl(__FILE__, __LINE__, format, ##__VA_ARGS__)
|
||||
#define printdebug(format, ...) \
|
||||
printdebug_impl(__FILE__, __LINE__, format, ##__VA_ARGS__)
|
||||
|
||||
extern int yylex(void);
|
||||
extern char *yytext;
|
||||
|
Reference in New Issue
Block a user