checking number of args in array ablock
This commit is contained in:
@ -282,7 +282,7 @@ rec_op :
|
|||||||
|
|
||||||
|
|
||||||
ablock:
|
ablock:
|
||||||
L_PAREN argument_list {$<integ>$ = $<integ>2;} R_PAREN
|
L_PAREN argument_list R_PAREN {$<integ>$ = $<integ>2; printdebug("ablock is %d", $<integ>$);}
|
||||||
;
|
;
|
||||||
|
|
||||||
argument_list:
|
argument_list:
|
||||||
@ -372,7 +372,19 @@ expression:
|
|||||||
// include type check for ablock in arrays - ablock is always the int of the elements in array/rec
|
// include type check for ablock in arrays - ablock is always the int of the elements in array/rec
|
||||||
assignable:
|
assignable:
|
||||||
ID {$$ = getType(look_up(cur,$1)); printdebug("[ASSIGNABLE - RULE 1] assignable = type: %s | ID = %s", $$, $1);}
|
ID {$$ = getType(look_up(cur,$1)); printdebug("[ASSIGNABLE - RULE 1] assignable = type: %s | ID = %s", $$, $1);}
|
||||||
| assignable ablock {$$ = getName(getReturn(table_lookup(getAncestor(cur), $1))); printdebug("[ASSIGNABLE - RULE 2] assignable = type: %s | name_func = %s", $$, $1);} // add array case
|
| assignable ablock {
|
||||||
|
int type = getAdInfoType(look_up(cur, $1));
|
||||||
|
if (type == TYPE_FUNCTION_TYPE) {
|
||||||
|
$$ = getName(getReturn(table_lookup(getAncestor(cur), $1)));
|
||||||
|
printdebug("[ASSIGNABLE - RULE 2] assignable = type: %s | name_func = %s", $$, $1);
|
||||||
|
} else if (type == TYPE_ARRAY) {
|
||||||
|
if (getNumArrDim(look_up(cur, $1)) != $<integ>2) {
|
||||||
|
printdebug("expected %d arguments but had %d at line %d and column %d\n", getNumArrDim(look_up(cur, $1)), $<integ>2, @2.first_line, @2.first_column);
|
||||||
|
}
|
||||||
|
$$ = $1;
|
||||||
|
printdebug("[ASSIGNABLE - RULE 2] assignable = type: %s | name_func = %s", $$, $1);
|
||||||
|
}
|
||||||
|
}
|
||||||
| assignable rec_op ID {if(undefined != table_lookup(getRecList(table_lookup(getAncestor(cur), $1)), $3)){
|
| assignable rec_op ID {if(undefined != table_lookup(getRecList(table_lookup(getAncestor(cur), $1)), $3)){
|
||||||
{$$ = getName(table_lookup(getRecList(table_lookup(getAncestor(cur), $1)), $3));}}; printdebug("[ASSIGNABLE - RULE 3] assignable = type: %s | ID = %s", $$, $1);}
|
{$$ = getName(table_lookup(getRecList(table_lookup(getAncestor(cur), $1)), $3));}}; printdebug("[ASSIGNABLE - RULE 3] assignable = type: %s | ID = %s", $$, $1);}
|
||||||
;
|
;
|
||||||
|
Reference in New Issue
Block a user