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 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();
}

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
@ -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();

View File

@ -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

View File

View File

View File