checking diff
This commit is contained in:
@ -154,7 +154,7 @@ 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(cur, $2), getRecSize(cur));
|
||||
setRecSize(look_up(getParent(cur), $2), getRecSize(cur));
|
||||
cur = getParent(cur);
|
||||
}
|
||||
|
||||
@ -206,27 +206,7 @@ definition:
|
||||
CreateEntry(cur,type_of_param_type, type_of_param, $4, getAdInfo(type_of_param));
|
||||
}
|
||||
R_PAREN ASSIGN sblock //leaving scope is being taken care of in sblock
|
||||
|
||||
/* | ID
|
||||
{
|
||||
TableNode *node = table_lookup(getAncestor(cur), $1);
|
||||
if (node == undefined) {
|
||||
printdebug("null check");
|
||||
}
|
||||
if (node == undefined) {
|
||||
printdebug("function not declared at line %d, column %d", @1.first_line, @1.first_column);
|
||||
} else if(getAdInfoType(node) != TYPE_FUNCTION_DECLARATION) {
|
||||
printdebug("function not declared at line %d, column %d", @1.first_line, @1.first_column);
|
||||
} else {
|
||||
setStartLine(node, @1.first_line);
|
||||
setAsKeyword(node, false);
|
||||
}
|
||||
cur = CreateScope(cur, 0, 0);
|
||||
} L_PAREN ID {
|
||||
printdebug("Currently see a function definition taking only one parameter (no as) of name %s and argument name %s",
|
||||
$1,$4);
|
||||
CreateEntry(cur, getParameter(table_lookup(getAncestor(cur), getType(table_lookup(getAncestor(cur), $<words>1)))), $<words>4, NULL);
|
||||
}R_PAREN ASSIGN sblock */
|
||||
|
||||
| ID {
|
||||
TableNode *node = table_lookup(getAncestor(cur), $1);
|
||||
if (node == undefined) {
|
||||
@ -394,7 +374,7 @@ id_or_types:
|
||||
ID
|
||||
{
|
||||
printdebug("string of id is %s in ID pattern of id_or_type rule.", $1);
|
||||
$$ = look_up(cur, $1);
|
||||
$$ = table_lookup(getAncestor(cur), $1);
|
||||
}
|
||||
|
||||
| types
|
||||
@ -428,11 +408,11 @@ simple_statement:
|
||||
{
|
||||
if(strcmp(getName($1), getName($3)) == 0) {
|
||||
printdebug("Passed standard type check; assignable = expression");
|
||||
} else if((strcmp(getName($1), "array") == 0) && (strcmp(getName($3), "address") == 0)) {
|
||||
} else if((strcmp(getType($1), "array") == 0) && (strcmp(getName($3), "address") == 0)) {
|
||||
printdebug("%s[☺] Passed array type check; %s = %s", COLOR_GREEN, getName($1), getName($3));
|
||||
} else if((strcmp(getName($1), "record") == 0) && (strcmp(getName($3), "address") == 0)) {
|
||||
} else if((strcmp(getType($1), "record") == 0) && (strcmp(getName($3), "address") == 0)) {
|
||||
printdebug("%s[☺] Passed address type check; %s = %s", COLOR_GREEN, getName($1), getName($3));
|
||||
} else if((strcmp(getName($1), "function type primitive") == 0) && (strcmp(getName($3), "address") == 0)) {
|
||||
} else if((strcmp(getType($1), "function type primitive") == 0) && (strcmp(getName($3), "address") == 0)) {
|
||||
printdebug("%s[☺] Passed function type primitive type check; %s = %s", COLOR_GREEN, getName($1), getName($3));
|
||||
// } else if () {
|
||||
|
||||
@ -613,7 +593,7 @@ expression:
|
||||
| assignable
|
||||
{
|
||||
printdebug("assignable expression. current type is %s",$1);
|
||||
$$= getTypeEntry($1);//idk if this is correct
|
||||
$$= getTypeEntry($1);
|
||||
}
|
||||
|
||||
| L_PAREN expression R_PAREN
|
||||
@ -648,7 +628,7 @@ assignable:
|
||||
}
|
||||
ablock
|
||||
{
|
||||
int type = getAdInfoType(look_up(cur, getName($1)));
|
||||
int type = getAdInfoType(look_up(getParent(cur), getName($1)));
|
||||
printdebug("%stype is %d", COLOR_PURPLE, type);
|
||||
printdebug("%s", $1);
|
||||
|
||||
@ -658,7 +638,7 @@ assignable:
|
||||
printdebug("as function");
|
||||
//char *funtype = getType(look_up(cur, $1));
|
||||
printdebug("%s", getType(look_up(cur, getName($1))));
|
||||
TableNode *param = getParameter(look_up(cur, getType(look_up(cur, getName($1)))));
|
||||
TableNode *param = getParameter(look_up(getParent(cur), getName($1)));
|
||||
SymbolTable *recList = getRecList(param);
|
||||
TableNode *lastCheckedRef = getFirstEntry(recList);
|
||||
TableNode *lastCheckedAct = getFirstEntry(cur);
|
||||
@ -669,7 +649,7 @@ assignable:
|
||||
|
||||
//this isn't very efficient, but will hopefully work
|
||||
while (lastCheckedAct != NULL && lastCheckedRef != NULL) {
|
||||
if (strcmp(getName(lastCheckedAct), getType(lastCheckedRef)) != 0) {
|
||||
if (strcmp(getName(lastCheckedAct), getName(lastCheckedRef)) != 0) {
|
||||
printdebug("expected %s. expression in function call got %s. at line %d and column %d",getType(lastCheckedRef), getName(lastCheckedAct), @3.first_line, @3.first_column);
|
||||
printdebug("%d", strcmp(getName(lastCheckedAct), getName(lastCheckedRef)));
|
||||
}
|
||||
@ -691,7 +671,7 @@ assignable:
|
||||
printdebug("expected %s expression in function call but got %s at line %d and column %d",expected, actual, @3.first_line, @3.first_column);
|
||||
}
|
||||
}
|
||||
$$ = getReturn((look_up(cur, getType(look_up(cur, getName($1))))));
|
||||
$$ = getReturn((table_lookup(getAncestor(cur), getType($1))));
|
||||
printdebug("[ASSIGNABLE - RULE 2] assignable = type: %s | name_func = %s", getName($$), getName($1));
|
||||
|
||||
} else if (type == TYPE_ARRAY_TYPE) {
|
||||
|
@ -143,7 +143,7 @@ int run(FILE *alpha) {
|
||||
|
||||
if (st_flag != NULL) {
|
||||
yyparse();
|
||||
print_symbol_table(getAncestor(cur), st_flag);
|
||||
print_symbol_table(top, st_flag);
|
||||
fclose(st_flag);
|
||||
if (yyin != NULL) {
|
||||
fclose(yyin);
|
||||
|
@ -1330,7 +1330,7 @@ SymbolTable *getParent(SymbolTable *st) {
|
||||
if (st->Parent_Scope == NULL) {
|
||||
printdebug("passed a top level scope to getParent function. "
|
||||
"Invalid.");
|
||||
return NULL;
|
||||
return st;
|
||||
}
|
||||
return st->Parent_Scope;
|
||||
}
|
||||
|
Reference in New Issue
Block a user