Open ahpalmerUNR opened 5 years ago
We are going to need to add functionality to our symbol table to distinguish between variables and functions. I am working on that right now.
We should also have some sort of ability to determine enum, typeDef, and struct, since these are treated slightly differently than normal variables.
I will be making the lexer make a node, which the parser inserts into the symbol table since it will be a lot easier to fix this way
Mostly finished the symbol table :smiley:
Still a couple of bugs with insertion (mostly with popping), but it is working a bit better now. Added
// Vector containing the types of the node
vector<nodeDataType> types;
// Contains the params of node (if it is a function)
vector<vector<nodeDataType>> params;
to keep check of parameters. Need to add some semantic checking if the parameters don't line up
Not touching the symbol table now to work more on AST nodes. It's mostly working (though there's still some stuff to work through with variables that are pretty important to fix)
Edit: Jk I forgot \0
wasn't in yytext. Should be working now.
Per discussion: add a function to insert into symbol table at level 0. If global variable seen, add to global scope. (Optional) Static variables need to be global lifetime but function scope. Dot operators are something to consider later as we look forward.
I am going to move everything out of declaration
and external_declaration
into direct_declarator
Alright I have everything moved into direct declarator
. Going to fix parameters tomorrow and then work on the different namespaces for the symbol table with ntype. Need to make it so we look up functions instead of blindly inserting as well.
dumping the symbol table doesn't work. Can you look at this. I am trying to figure out why a segfault is happening when we pop.
Andrew
On Mon, Nov 26, 2018 at 10:08 PM Nathan Yocum notifications@github.com wrote:
Alright I have everything moved into direct declarator. Going to fix parameters tomorrow and then work on the different namespaces for the symbol table with ntype. Need to make it so we look up functions instead of blindly inserting as well.
— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/ahpalmerUNR/c_compiler/issues/3#issuecomment-441937009, or mute the thread https://github.com/notifications/unsubscribe-auth/AfkgwVy7OptitKVLuVKs8-4E5Ly7OLiKks5uzNbIgaJpZM4X9xSf .
fixed seg fault. Caused because the $3 and $4 weren't updated in last compound statement production.
Work needed:
c_compiler.ypp
to only use one symbol table again
==
node operator overload
AST Symbol Table:
Issues I notice so far in the table relate to inserting/looking up immediately when we see an identifier in the lexer.
Some code I am going to work on fixing (in order of priority):