fixed several small issues
This commit is contained in:
@ -365,11 +365,12 @@ sblock:
|
|||||||
}
|
}
|
||||||
statement_list
|
statement_list
|
||||||
{
|
{
|
||||||
$<tn>$ = $3;
|
//$<tn>$ = $3;
|
||||||
printdebug("Moving up a scope after seeing sblock");
|
printdebug("Moving up a scope after seeing sblock");
|
||||||
cur = getParent(cur);
|
cur = getParent(cur);
|
||||||
}
|
}
|
||||||
R_BRACE
|
R_BRACE
|
||||||
|
{$$ = $3;}
|
||||||
|
|
||||||
| L_BRACE
|
| L_BRACE
|
||||||
{
|
{
|
||||||
@ -390,9 +391,10 @@ sblock:
|
|||||||
{
|
{
|
||||||
printdebug("Moving up a scope after seeing sblock with dblock");
|
printdebug("Moving up a scope after seeing sblock with dblock");
|
||||||
cur = getParent(cur);
|
cur = getParent(cur);
|
||||||
$<tn>$ = $5;
|
//$<tn>$ = $5;
|
||||||
}
|
}
|
||||||
R_BRACE
|
R_BRACE
|
||||||
|
{$$ = $5;}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
@ -880,7 +882,8 @@ assignable:
|
|||||||
if (getNumArrDim(look_up(getParent(cur), getName((TableNode*)$1))) != $<integ>2) {
|
if (getNumArrDim(look_up(getParent(cur), getName((TableNode*)$1))) != $<integ>2) {
|
||||||
printdebug("expected %d arguments but had %d at line %d and column %d\n", getNumArrDim(look_up(cur, getName((TableNode*)$1))), $<integ>2, @2.first_line, @2.first_column);
|
printdebug("expected %d arguments but had %d at line %d and column %d\n", getNumArrDim(look_up(cur, getName((TableNode*)$1))), $<integ>2, @2.first_line, @2.first_column);
|
||||||
}
|
}
|
||||||
$$ = getArrType(look_up(getParent(cur), getName((TableNode*)$1)));
|
$$ = getArrType(look_up(cur, getName((TableNode*)$1)));
|
||||||
|
printdebug("[ASSIGNABLE - RULE 2] assignable = type: %s | name_func = %s", getName((TableNode*)$$), getName((TableNode*)$1));
|
||||||
printdebug("[ASSIGNABLE - RULE 2] assignable = type: %s | name_func = %s", getName((TableNode*)$$), getName((TableNode*)$1));
|
printdebug("[ASSIGNABLE - RULE 2] assignable = type: %s | name_func = %s", getName((TableNode*)$$), getName((TableNode*)$1));
|
||||||
}
|
}
|
||||||
cur = getParent(cur);
|
cur = getParent(cur);
|
||||||
|
@ -92,9 +92,10 @@ int getNumArrDim(TableNode *definition) {
|
|||||||
"function. Invalid.");
|
"function. Invalid.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (strcmp(getType(definition), "array") != 0) {
|
if(getAdInfoType(definition) != TYPE_ARRAY_TYPE){
|
||||||
printdebug("not checking the dim of an array -- invalid op");
|
printdebug(
|
||||||
return 0;
|
"passed an invalid node to getNumArrDim. Seeing tag %d in getNumArrDim. Invalid.",getAdInfoType(definition));
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
return definition->additionalinfo->ArrayAdInfo->numofdimensions;
|
return definition->additionalinfo->ArrayAdInfo->numofdimensions;
|
||||||
}
|
}
|
||||||
@ -113,8 +114,9 @@ TableNode *getArrType(TableNode *definition) {
|
|||||||
"function. Invalid.");
|
"function. Invalid.");
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
if (strcmp(getType(definition), "array") != 0) {
|
if(getAdInfoType(definition) != TYPE_ARRAY_TYPE){
|
||||||
printdebug("not checking the type of an array -- invalid op");
|
printdebug(
|
||||||
|
"passed an invalid node to getArrType. Seeing tag %d. Invalid.",getAdInfoType(definition));
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
return definition->additionalinfo->ArrayAdInfo->typeofarray;
|
return definition->additionalinfo->ArrayAdInfo->typeofarray;
|
||||||
@ -1132,8 +1134,8 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr) {
|
|||||||
}
|
}
|
||||||
if (getAdInfoType(entry) == TYPE_ARRAY) {
|
if (getAdInfoType(entry) == TYPE_ARRAY) {
|
||||||
char *arrayType = (char *)malloc(100);
|
char *arrayType = (char *)malloc(100);
|
||||||
sprintf(arrayType, " %d -> %s", getNumArrDim(entry),
|
//sprintf(arrayType, " %d -> %s", getNumArrDim(entry),
|
||||||
getName(getArrType(entry)));
|
// getName(getArrType(entry)));
|
||||||
|
|
||||||
if (parentScopeNum == 0) {
|
if (parentScopeNum == 0) {
|
||||||
st_fprint(file_ptr, getName(entry), currentScopeNum, -100, getType(entry), " Array Instance");
|
st_fprint(file_ptr, getName(entry), currentScopeNum, -100, getType(entry), " Array Instance");
|
||||||
|
@ -2,6 +2,6 @@ type main: string -> integer
|
|||||||
function entry: main
|
function entry: main
|
||||||
|
|
||||||
entry(arg) := {
|
entry(arg) := {
|
||||||
[int : x]
|
[integer : x]
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
type tom : [integer : x; integer: y]
|
type tom : [integer : x; integer: y]
|
||||||
type rec : [integer : x; tom : prev; character : c; character : d; Boolean: b; integer : y]
|
type rec : [integer : x; tom : prev; character : c; character : d; Boolean: b; integer : y]
|
||||||
|
type tricky : [Boolean : b1; integer : k1; Boolean : b2; integer : k2]
|
Reference in New Issue
Block a user