added more symbol table functions
This commit is contained in:
@ -4,6 +4,7 @@
|
|||||||
// Prologue
|
// Prologue
|
||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "symbol_table.c"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%token ID 101
|
%token ID 101
|
||||||
@ -53,7 +54,7 @@
|
|||||||
%token RELEASE 614
|
%token RELEASE 614
|
||||||
%token COMMENT 700
|
%token COMMENT 700
|
||||||
%%
|
%%
|
||||||
B : '{' E '}'; //Braced Expressions can have braces removed to get regular expressions
|
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
|
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
|
E : Maybe_D U; //An expression can start with an optional D followed by an undeclared segment
|
||||||
Maybe_D : D
|
Maybe_D : D
|
||||||
|
3
runner.c
3
runner.c
@ -81,7 +81,8 @@ int run(FILE *alpha) {
|
|||||||
}
|
}
|
||||||
if(token == 1999){
|
if(token == 1999){
|
||||||
printf("On line number %d and column number %d we have an invalid character:%s\n",line_number,column_number,yytext);
|
printf("On line number %d and column number %d we have an invalid character:%s\n",line_number,column_number,yytext);
|
||||||
return -1;}
|
//return -1;
|
||||||
|
}
|
||||||
column_number += yyleng;
|
column_number += yyleng;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,6 +101,37 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SymbolTable * getParent(SymbolTable* st){
|
||||||
|
return st->ParentScope;
|
||||||
|
}
|
||||||
|
|
||||||
|
ListOfTable * getChildren(SymbolTable* st){
|
||||||
|
return st->Children_Scope;
|
||||||
|
}
|
||||||
|
SymbolTable * getFirstChild(ListOfTable * lt){
|
||||||
|
return lt->table;
|
||||||
|
}
|
||||||
|
ListOfTable * getRestOfChildren(ListOfTable * lt){
|
||||||
|
return lt->next;
|
||||||
|
}
|
||||||
|
TableNode * getFirstEntry(SymbolTable * st){
|
||||||
|
return st->entries;
|
||||||
|
}
|
||||||
|
TableNode * getNextEntry(TableNode * tn){
|
||||||
|
return tn->next;
|
||||||
|
}
|
||||||
|
char * getType(TableNode * tn){
|
||||||
|
return tn->theType;
|
||||||
|
}
|
||||||
|
char * getName(TableNode * tn){
|
||||||
|
return tn->theName;
|
||||||
|
}
|
||||||
|
int getLine(SymbolTable * st){
|
||||||
|
return st->line;
|
||||||
|
}
|
||||||
|
int getColumn(SymbolTable *st){
|
||||||
|
return st->column;
|
||||||
|
}
|
||||||
//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
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
0
test_keywords.st
Normal file
0
test_keywords.st
Normal file
0
test_operators.st
Normal file
0
test_operators.st
Normal file
0
test_real_alpha_2.st
Normal file
0
test_real_alpha_2.st
Normal file
Reference in New Issue
Block a user