New grammar formatting rules applied.

This commit is contained in:
Scarlett
2025-04-03 16:37:53 -04:00
parent 3186d363ed
commit 3d06352510
4 changed files with 535 additions and 297 deletions

View File

@ -66,7 +66,8 @@ typedef enum {
// TYPE_ADDRESS,
// Type String is an array of char enclosed in double quotes per lexer
TYPE_STRING = 1,
// Array can be multidimensional. Information should be stored here. This is the type of the array
// Array can be multidimensional. Information should be stored here.
// This is the type of the array
TYPE_ARRAY_TYPE = 2,
// Record is user defined types
TYPE_RECORD_TYPE = 3,
@ -84,7 +85,7 @@ typedef enum {
TYPE_ALL_ELSE = 7,
TYPE_UNDEFINED = 8,
TYPE_RECORD = 9,
TYPE_ARRAY = 10
TYPE_ARRAY = 10
} types;
@ -513,8 +514,9 @@ SymbolTable *CreateScope(SymbolTable *ParentScope, int Line, int Column) {
// types
SymbolTable *init(SymbolTable *start) {
if (start->Parent_Scope != NULL) {
printdebug(
"%s[FATAL] Cannot initialize a scope that is not the parent scope", COLOR_RED);
printdebug("%s[FATAL] Cannot initialize a scope that is not "
"the parent scope",
COLOR_RED);
return NULL;
}
integ = (TableNode *)calloc(1, sizeof(TableNode));
@ -707,15 +709,15 @@ int getAdInfoType(TableNode *tn) {
if (strcmp(getName(tn), getName(undefined)) == 0) {
return TYPE_UNDEFINED;
} else {
if(strcmp(getType(tn), getName(funtypeprime))==0){
if (strcmp(getType(tn), getName(funtypeprime)) == 0) {
printdebug("passed in a function to getAdInfoType");
return TYPE_FUNCTION_DECLARATION;
}
if(strcmp(getType(tn), getName(arrayprim))==0){
if (strcmp(getType(tn), getName(arrayprim)) == 0) {
printdebug("passed in an array to getAdInfoType");
return TYPE_ARRAY_TYPE;
return TYPE_ARRAY_TYPE;
}
if(strcmp(getType(tn), getName(recprime))==0){
if (strcmp(getType(tn), getName(recprime)) == 0) {
printdebug("passed in a record to getAdInfoType");
return TYPE_RECORD;
}
@ -1139,13 +1141,14 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr) {
if (getChildren(table) != NULL) {
ListOfTable *node = getChildren(table);
for (; node != NULL; node = node->next) {
if((node->table) == NULL){
print_symbol_table(node->table, file_ptr);
}else{
if ((node->table)->Line_Number == -1){
continue;
}else{
print_symbol_table(node->table, file_ptr);
if ((node->table) == NULL) {
print_symbol_table(node->table, file_ptr);
} else {
if ((node->table)->Line_Number == -1) {
continue;
} else {
print_symbol_table(node->table,
file_ptr);
}
}
}