edited symbol table functions

This commit is contained in:
Partho Bhattacharya
2025-02-26 12:52:29 -05:00
parent 38b73bd551
commit 046ccf194b
6 changed files with 23 additions and 16 deletions

View File

@ -54,12 +54,20 @@
%token RELEASE 614 %token RELEASE 614
%token COMMENT 700 %token COMMENT 700
%% %%
B : '{'{CreateScope(cur,line,column)} E '}'; //Braced Expressions can have braces removed to get regular expressions
D : '[' l ']'; //Declaration Lists Brackets can be taken out to get a list of Declarations start: /*empty for now*/
E : Maybe_D U; //An expression can start with an optional D followed by an undeclared segment ;
Maybe_D : D // B : '{'{CreateScope(cur,line,column)} E '}'; //Braced Expressions can have braces removed to get regular expressions
| ; //Either D or not // D : '[' l ']'; //Declaration Lists Brackets can be taken out to get a list of Declarations
l : A ';' l; // E : Maybe_D U; //An expression can start with an optional D followed by an undeclared segment
| ; //a declaration list can either be empty or be an assignment followed by a semi-colon and another list // Maybe_D : D
// | ; //Either D or not
//l : A ';' l;
// | ; //a declaration list can either be empty or be an assignment followed by a semi-colon and another list
%% %%
int main() {
return yyparse();
}

View File

@ -1,6 +1,5 @@
#line 2 "lex.yy.c"
#line 4 "lex.yy.c" #line 3 "lex.yy.c"
#define YY_INT_ALIGNED short int #define YY_INT_ALIGNED short int
@ -557,11 +556,11 @@ char *yytext;
#ifndef DEBUG #ifndef DEBUG
#define DEBUG 0 #define DEBUG 0
#endif #endif
#line 561 "lex.yy.c" #line 560 "lex.yy.c"
#line 22 "lexicalStructure.lex" #line 22 "lexicalStructure.lex"
/* char can be a newline, tab, an escaped quote, or anything but a single quote, an actual line break, an actual tab, or a backslash by itself (to prevent confusion from escaped quote */ /* char can be a newline, tab, an escaped quote, or anything but a single quote, an actual line break, an actual tab, or a backslash by itself (to prevent confusion from escaped quote */
/* similar to above, a string Char (SCHAR) is the same as a CHAR except we cannot have double quotes instead of single quotes. Double quotes need to be escaped in Flex unlike single quotes based on documentation */ /* similar to above, a string Char (SCHAR) is the same as a CHAR except we cannot have double quotes instead of single quotes. Double quotes need to be escaped in Flex unlike single quotes based on documentation */
#line 565 "lex.yy.c" #line 564 "lex.yy.c"
#define INITIAL 0 #define INITIAL 0
@ -781,7 +780,7 @@ YY_DECL
#line 26 "lexicalStructure.lex" #line 26 "lexicalStructure.lex"
#line 785 "lex.yy.c" #line 784 "lex.yy.c"
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{ {
@ -1090,7 +1089,7 @@ YY_RULE_SETUP
#line 89 "lexicalStructure.lex" #line 89 "lexicalStructure.lex"
ECHO; ECHO;
YY_BREAK YY_BREAK
#line 1094 "lex.yy.c" #line 1093 "lex.yy.c"
case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INITIAL):
yyterminate(); yyterminate();

View File

@ -102,7 +102,7 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr){
} }
SymbolTable * getParent(SymbolTable* st){ SymbolTable * getParent(SymbolTable* st){
return st->ParentScope; return st->Parent_Scope;
} }
ListOfTable * getChildren(SymbolTable* st){ ListOfTable * getChildren(SymbolTable* st){
@ -127,10 +127,10 @@ char * getName(TableNode * tn){
return tn->theName; return tn->theName;
} }
int getLine(SymbolTable * st){ int getLine(SymbolTable * st){
return st->line; return st->Line_Number;
} }
int getColumn(SymbolTable *st){ int getColumn(SymbolTable *st){
return st->column; return st->Column_Number;
} }
//uncomment the below main function along with the headers above for a simple standalone test of table and entry creation //uncomment the below main function along with the headers above for a simple standalone test of table and entry creation

View File

View File

View File