From 046ccf194b8e75a7e306a68f12f5e59c062a9b14 Mon Sep 17 00:00:00 2001 From: Partho Bhattacharya Date: Wed, 26 Feb 2025 12:52:29 -0500 Subject: [PATCH] edited symbol table functions --- grammar.y | 22 +++++++++++++++------- lex.yy.c | 11 +++++------ symbol_table.c | 6 +++--- test_keywords.st | 0 test_operators.st | 0 test_real_alpha_2.st | 0 6 files changed, 23 insertions(+), 16 deletions(-) delete mode 100644 test_keywords.st delete mode 100644 test_operators.st delete mode 100644 test_real_alpha_2.st diff --git a/grammar.y b/grammar.y index d930f2a..172058c 100644 --- a/grammar.y +++ b/grammar.y @@ -54,12 +54,20 @@ %token RELEASE 614 %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 -E : Maybe_D U; //An expression can start with an optional D followed by an undeclared segment -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 + +start: /*empty for now*/ + ; +// 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 +// E : Maybe_D U; //An expression can start with an optional D followed by an undeclared segment +// 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(); +} + diff --git a/lex.yy.c b/lex.yy.c index c4dad48..49b4eed 100644 --- a/lex.yy.c +++ b/lex.yy.c @@ -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 @@ -557,11 +556,11 @@ char *yytext; #ifndef DEBUG #define DEBUG 0 #endif -#line 561 "lex.yy.c" +#line 560 "lex.yy.c" #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 */ /* 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 @@ -781,7 +780,7 @@ YY_DECL #line 26 "lexicalStructure.lex" -#line 785 "lex.yy.c" +#line 784 "lex.yy.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -1090,7 +1089,7 @@ YY_RULE_SETUP #line 89 "lexicalStructure.lex" ECHO; YY_BREAK -#line 1094 "lex.yy.c" +#line 1093 "lex.yy.c" case YY_STATE_EOF(INITIAL): yyterminate(); diff --git a/symbol_table.c b/symbol_table.c index 2a7729f..11ba544 100644 --- a/symbol_table.c +++ b/symbol_table.c @@ -102,7 +102,7 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr){ } SymbolTable * getParent(SymbolTable* st){ - return st->ParentScope; + return st->Parent_Scope; } ListOfTable * getChildren(SymbolTable* st){ @@ -127,10 +127,10 @@ char * getName(TableNode * tn){ return tn->theName; } int getLine(SymbolTable * st){ - return st->line; + return st->Line_Number; } 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 diff --git a/test_keywords.st b/test_keywords.st deleted file mode 100644 index e69de29..0000000 diff --git a/test_operators.st b/test_operators.st deleted file mode 100644 index e69de29..0000000 diff --git a/test_real_alpha_2.st b/test_real_alpha_2.st deleted file mode 100644 index e69de29..0000000