more type check fixes
This commit is contained in:
@ -266,13 +266,20 @@ simple_statement:
|
||||
{
|
||||
if(strcmp($1, $3) == 0) {
|
||||
printdebug("Passed standard type check; assignable = expression");
|
||||
} else if((strcmp($1, "rec") == 0) && (strcmp($3, "address") == 0)) {
|
||||
printdebug("Passed rec type check; rec = address");
|
||||
} else if((strcmp($1, "array") == 0) && (strcmp($3, "address") == 0)) {
|
||||
printdebug("Passed array type check; array = address");
|
||||
} else if((strcmp(getType(look_up(cur, $1)), "array") == 0) && (strcmp($3, "address") == 0)) {
|
||||
printdebug("%s[☺] Passed array type check; %s = %s", COLOR_GREEN, $1, $3);
|
||||
} else if((strcmp(getType(look_up(cur, $1)), "record") == 0) && (strcmp($3, "address") == 0)) {
|
||||
printdebug("%s[☺] Passed address type check; %s = %s", COLOR_GREEN, $1, $3);
|
||||
} else if((strcmp(getType(look_up(cur, $1)), "function type primitive") == 0) && (strcmp($3, "address") == 0)) {
|
||||
printdebug("%s[☺] Passed function type primitive type check; %s = %s", COLOR_GREEN, $1, $3);
|
||||
// } else if () {
|
||||
|
||||
// } else if(strcmp(getType(table_lookup(cur, $1)), getType(table_lookup(cur, $3))) == 0) {
|
||||
// printdebug("%s[] Passed double lookup type check; %s = %s", COLOR_GREEN, $1, $3);
|
||||
} else {
|
||||
printdebug("%s[TYPE ERROR] %sMismatch at %sline %d and column %d%s", COLOR_ORANGE, COLOR_WHITE, COLOR_YELLOW, @2.first_line, @2.first_column, COLOR_WHITE);
|
||||
printdebug(" - Invalid types %s$1: %s and $3: %s%s", COLOR_YELLOW, $1, $3, COLOR_WHITE);
|
||||
printdebug(" - %sgetType for address: %s", COLOR_YELLOW, getType(look_up(cur, $1)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -388,9 +395,12 @@ expression:
|
||||
// include type check for ablock in arrays - ablock is always the int of the elements in array/rec
|
||||
assignable:
|
||||
ID {$$ = getType(look_up(cur,$1)); printdebug("[ASSIGNABLE - RULE 1] assignable = type: %s | ID = %s", $$, $1);}
|
||||
| assignable {
|
||||
| assignable
|
||||
{
|
||||
cur = CreateScope(cur, -1,-1);
|
||||
}ablock {
|
||||
}
|
||||
ablock
|
||||
{
|
||||
int type = getAdInfoType(look_up(getParent(cur), $1));
|
||||
if (type == TYPE_FUNCTION_DECLARATION) {
|
||||
if (getAsKeyword(look_up(getParent(cur), $1))) {
|
||||
@ -403,8 +413,8 @@ assignable:
|
||||
}
|
||||
//this isn't very efficient, but will hopefully work
|
||||
while (lastCheckedAct != NULL && lastCheckedRef != NULL) {
|
||||
if (strcmp(getType(lastCheckedAct), getName(lastCheckedRef)) != 0) {
|
||||
printdebug("expected %s expression in function call but got %s at line %d and column %d",getType(lastCheckedRef), getName(lastCheckedAct), @3.first_line, @3.first_column);
|
||||
if (strcmp(getName(lastCheckedAct), getName(lastCheckedRef)) != 0) {
|
||||
printdebug("expected %s expression in function call but got %s at line %d and column %d",getName(lastCheckedRef), getName(lastCheckedAct), @3.first_line, @3.first_column);
|
||||
}
|
||||
lastCheckedAct = getNextEntry(lastCheckedAct);
|
||||
TableNode *tn = getFirstEntry(recList);
|
||||
@ -433,7 +443,7 @@ assignable:
|
||||
printdebug("expected only integer expressions in array ablock at line %d column %d", @3.first_line, @3.first_column);
|
||||
}
|
||||
}
|
||||
$$ = $1;
|
||||
$$ = getName(getArrType(look_up(getParent(cur), $1)));
|
||||
printdebug("[ASSIGNABLE - RULE 2] assignable = type: %s | name_func = %s", $$, $1);
|
||||
}
|
||||
cur = getParent(cur);
|
||||
|
@ -11,15 +11,15 @@ entry(arg) := {
|
||||
another_name(1) := 'a';
|
||||
another_name(2) := 'r';
|
||||
another_name(3) := 'l';
|
||||
a_of_s := reserve a_of_s(3);
|
||||
a_of_s(0) := one_name;
|
||||
a_of_s(1) := another_name;
|
||||
many_names := reserve many_names(3);
|
||||
many_names(0) := one_name;
|
||||
many_names(1) := another_name;
|
||||
many_names(2) := reserve many_names(2)(6); (* reserve space for an item of the same type as a_of_s(2), an array of character, with 6 members *)
|
||||
many_names(2)(0) := "P";
|
||||
many_names(2)(1) := "a";
|
||||
many_names(2)(2) := "r";
|
||||
many_names(2)(3) := "t";
|
||||
many_names(2)(4) := "h";
|
||||
many_names(2)(5) := "o";
|
||||
many_names(2)(0) := 'P';
|
||||
many_names(2)(1) := 'a';
|
||||
many_names(2)(2) := 'r';
|
||||
many_names(2)(3) := 't';
|
||||
many_names(2)(4) := 'h';
|
||||
many_names(2)(5) := 'o';
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user