have to finish idlist rules

This commit is contained in:
Partho
2025-04-11 19:00:24 -04:00
parent e8bad44949
commit 3fc7a6371a
4 changed files with 47 additions and 17 deletions

View File

@ -21,6 +21,7 @@
void yyerror(const char *err);
int token_tracker;
TableNode * tn;
int counter;
%}
%union {
@ -137,6 +138,8 @@ definition:
//We are scanning through the dblock scope to get the length of the dblock (num of elements) from getRecSize
//and then putting it in the entry that we created above.
setRecSize(look_up(getParent(cur), $2), getRecSize(cur));
//putting in all the offsets
setRecOffsetInfo(cur, look_up(getParent(cur),$2));
printdebug("Moving up a scope after seeing a record definition");
cur = getParent(cur);
}
@ -236,6 +239,8 @@ definition:
}
}
}
counter = 0;
printdebug("Created a new scope after seeing a function definition");
} idlist {
printdebug("Currently see a function definition taking one paramter (with as) of name %s and number of arguments %d", $1,$5);
} R_PAREN ASSIGN sblock //check sblock type
@ -273,7 +278,15 @@ function_declaration:
idlist:
ID
{
counter ++;
TableNode *entry = getFirstEntry(cur);
int count = 1;
while(count<counter){
entry = getNextEntry(entry);
count++;
}
printdebug("RAAAAAAAAAAAAAAAAAAAAAAAAAAAAH");
printTableNode(entry);
while (strcmp(getName(entry),"undefined") != 0) {
entry = getNextEntry(entry);
}
@ -281,6 +294,8 @@ idlist:
printdebug("too many parameters at line %d column %d", @1.first_line, @1.first_column);
}
addName(entry, $1);
printdebug("name added to entry is %s", $1);
printTableNode(entry);
}
COMMA idlist
{
@ -289,7 +304,13 @@ idlist:
| ID
{
counter ++;
TableNode *entry = getFirstEntry(cur);
int count = 1;
while(count<counter){
entry = getNextEntry(entry);
count++;
}
while (strcmp(getName(entry),"undefined") != 0) {
entry = getNextEntry(entry);
}
@ -701,8 +722,8 @@ expression:
assignable:
ID
{
$$ = look_up(cur,$1);
printdebug("[ASSIGNABLE - RULE 1] assignable = type: %s | ID = %s", getTypeEntry((TableNode*)$$), $1);
$$ = getTypeEntry(look_up(cur,$1));
printdebug("[ASSIGNABLE - RULE 1] assignable = type: %s | ID = %s", getName((TableNode*)$$), $1);
}
| assignable