Header files updated

This commit is contained in:
Scarlett
2025-04-03 18:29:43 -04:00
parent 3d06352510
commit 4e862d54a4
6 changed files with 132 additions and 311 deletions

View File

@ -1,3 +1,4 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@ -9,26 +10,12 @@ 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;
@ -47,19 +34,16 @@ 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;
@ -74,30 +58,100 @@ typedef struct SymbolTable {
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
} types;
AdInfo *CreatePrimitiveInfo(int size);
int getPrimSize(TableNode *definition);
AdInfo *CreateArrayInfo(int dim, TableNode *type);
int getNumArrDim(TableNode *definition);
TableNode *getArrType(TableNode *definition);
AdInfo *CreateRecordInfo(int length, SymbolTable *recordScope);
int getRecLength(TableNode *definition);
SymbolTable *getRecList(TableNode *definition);
TableNode *setRecSize(TableNode *tn, int n);
int getRecSize(SymbolTable *tn);
AdInfo *CreateFunctionDeclarationInfo(int line, bool asorregular);
int getStartLine(TableNode *definition);
TableNode *setStartLine(TableNode *tn, int start);
bool getAsKeyword(TableNode *definition);
TableNode *setAsKeyword(TableNode *tn, bool as);
AdInfo *CreateFunctionTypeInfo(TableNode *parameter, TableNode *returntype);
TableNode *getParameter(TableNode *definition);
TableNode *getReturn(TableNode *definition);
SymbolTable *CreateScope(SymbolTable *ParentScope, int Line, int Column);
SymbolTable *init(SymbolTable *start);
TableNode *populateTypeAndInfo(TableNode *tn, TableNode *type, AdInfo *info);
int getAdInfoType(TableNode *tn);
TableNode *CreateEntry(SymbolTable *table, TableNode *typeOf, char *id,
AdInfo *ad);
char *getType(TableNode *tn);
char *getName(TableNode *tn);
int getLine(SymbolTable *st);
int getColumn(SymbolTable *st);
TableNode *addName(TableNode *tn, char *str);
SymbolTable *setLineNumber(SymbolTable *st, int line);
SymbolTable *setColumnNumber(SymbolTable *st, 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 *removeEntry(SymbolTable *scope, char *search);
bool typeCheck(char *firstID, char *secondID);
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);
void printdebug_impl(char *file, int line, const char *format, ...);
#define printdebug(format, ...) \
printdebug_impl(__FILE__, __LINE__, format, ##__VA_ARGS__)
extern int yylex(void);
extern char *yytext;
extern int yyleng;
extern int yychar;
extern SymbolTable *cur;
extern int line_number;
extern int column_number;
extern FILE *yyin;
extern bool DEBUG;
extern TableNode *funprime;
extern TableNode *arrayprim;
extern TableNode *integ;
extern TableNode *addr;
extern TableNode *chara;
extern TableNode *stri;
extern TableNode *boo;
extern TableNode *recprime;
extern TableNode *funtypeprime;
extern TableNode *undefined;
extern char *COLOR_RED;
extern char *COLOR_GREEN;
extern char *COLOR_ORANGE;
extern char *COLOR_BLUE;
extern char *COLOR_PURPLE;
extern char *COLOR_CYAN;
extern char *COLOR_LIGHTGRAY;
extern char *COLOR_DARKGRAY;
extern char *COLOR_LIGHTRED;
extern char *COLOR_LIGHTGREEN;
extern char *COLOR_YELLOW;
extern char *COLOR_LIGHTBLUE;
extern char *COLOR_LIGHTPURPLE;
extern char *COLOR_LIGHTCYAN;
extern char *COLOR_WHITE;