|
|
|
@ -1,3 +1,4 @@
|
|
|
|
|
|
|
|
|
|
/* Syntax Analyzer with Bison (3.8.2) */
|
|
|
|
|
/* The Translators - Spring 2025 */
|
|
|
|
|
|
|
|
|
@ -192,15 +193,22 @@ definition:
|
|
|
|
|
}
|
|
|
|
|
if(type_of_param_type == TYPE_UNDEFINED){
|
|
|
|
|
CreateEntry(cur,type_of_param_type, undefined, NULL, NULL);
|
|
|
|
|
// throw_error(ERROR_TYPE, "Duplicate defination of parameter in function definition.");
|
|
|
|
|
} else {
|
|
|
|
|
if(type_of_param_type == TYPE_FUNCTION_TYPE){
|
|
|
|
|
CreateEntry(cur, TYPE_FUNCTION_DECLARATION, parameter,NULL, getAdInfo(parameter));
|
|
|
|
|
// throw_error(ERROR_TYPE, "Duplicate defination of parameter in function definition.");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(type_of_param_type == TYPE_ARRAY_TYPE){
|
|
|
|
|
CreateEntry(cur, TYPE_ARRAY, parameter,NULL, getAdInfo(parameter));
|
|
|
|
|
//throw_error(ERROR_TYPE, "Duplicate defination of parameter in function definition.");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(type_of_param_type == TYPE_PRIMITIVE_TYPE){
|
|
|
|
|
CreateEntry(cur, TYPE_PRIMITIVE, parameter,NULL, getAdInfo(parameter));
|
|
|
|
|
CreateEntry(cur, TYPE_PRIMITIVE, parameter,NULL, getAdInfo(parameter))==undefined;
|
|
|
|
|
// throw_error(ERROR_TYPE, "Duplicate defination of parameter in function definition.");}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
@ -223,19 +231,32 @@ definition:
|
|
|
|
|
if(type_of_param_type == TYPE_UNDEFINED){
|
|
|
|
|
printdebug("undefined type of parameter inside record");
|
|
|
|
|
CreateEntry(cur,type_of_param_type, undefined, NULL, NULL);
|
|
|
|
|
//throw_error(ERROR_TYPE, "Duplicate defination of parameter in function definition.");
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
if(type_of_param_type == TYPE_FUNCTION_DECLARATION){
|
|
|
|
|
printdebug("function declaration of parameter inside record");
|
|
|
|
|
CreateEntry(cur, TYPE_FUNCTION_DECLARATION, getTypeEntry(entry),NULL, getAdInfo(entry));
|
|
|
|
|
//throw_error(ERROR_TYPE, "Duplicate defination of parameter in function definition.");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(type_of_param_type == TYPE_ARRAY){
|
|
|
|
|
printdebug("array type of parameter inside record");
|
|
|
|
|
CreateEntry(cur, TYPE_ARRAY, getTypeEntry(entry),NULL, getAdInfo(entry));
|
|
|
|
|
//throw_error(ERROR_TYPE, "Duplicate defination of parameter in function definition.");
|
|
|
|
|
}
|
|
|
|
|
if(type_of_param_type == TYPE_PRIMITIVE){
|
|
|
|
|
printdebug("primitive type of parameter inside record");
|
|
|
|
|
CreateEntry(cur, TYPE_PRIMITIVE, getTypeEntry(entry),NULL, getAdInfo(entry));
|
|
|
|
|
|
|
|
|
|
//throw_error(ERROR_TYPE, "Duplicate defination of parameter in function definition.");}
|
|
|
|
|
}
|
|
|
|
|
if(type_of_param_type == TYPE_RECORD){
|
|
|
|
|
printdebug("record type of parameter inside record");
|
|
|
|
|
CreateEntry(cur, TYPE_RECORD, getTypeEntry(entry),NULL, getAdInfo(entry));
|
|
|
|
|
//throw_error(ERROR_TYPE, "Duplicate defination of parameter in function definition.");}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*printdebug("creating entry of type %s for function", getType(entry));
|
|
|
|
|
CreateEntry(cur, getTypeEntry(entry), "undefined", NULL);*/
|
|
|
|
|
}
|
|
|
|
@ -445,22 +466,38 @@ declaration:
|
|
|
|
|
else if(d == TYPE_FUNCTION_TYPE) {
|
|
|
|
|
printdebug("invalid (function) type passed in declaration list in dblock", @2.first_line, @2.first_column);
|
|
|
|
|
d = TYPE_FUNCTION_DECLARATION;
|
|
|
|
|
CreateEntry(cur,d,(TableNode*)$1,$3,getAdInfo((TableNode*)$1));
|
|
|
|
|
|
|
|
|
|
if(CreateEntry(cur,d,(TableNode*)$1,$3,getAdInfo((TableNode*)$1)) == undefined){
|
|
|
|
|
throw_error(ERROR_TYPE, "Duplicate defination of function in declaration list");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if(d == TYPE_ARRAY_TYPE){
|
|
|
|
|
printdebug("array variable at line %d and column %d", @2.first_line, @2.first_column);
|
|
|
|
|
d = TYPE_ARRAY;
|
|
|
|
|
CreateEntry(cur,d,(TableNode*)$1,$3,getAdInfo((TableNode*)$1));
|
|
|
|
|
|
|
|
|
|
if(CreateEntry(cur,d,(TableNode*)$1,$3,getAdInfo((TableNode*)$1)) == undefined){
|
|
|
|
|
throw_error(ERROR_TYPE, "Duplicate defination of array in declaration list");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if(d == TYPE_RECORD_TYPE){
|
|
|
|
|
printdebug("record variable at line %d and column %d", @2.first_line, @2.first_column);
|
|
|
|
|
d = TYPE_RECORD;
|
|
|
|
|
CreateEntry(cur,d,(TableNode*)$1,$3,getAdInfo((TableNode*)$1));
|
|
|
|
|
|
|
|
|
|
if(CreateEntry(cur,d,(TableNode*)$1,$3,getAdInfo((TableNode*)$1))== undefined){
|
|
|
|
|
throw_error(ERROR_TYPE, "Duplicate defination of record in declaration list");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if(d == TYPE_PRIMITIVE_TYPE){
|
|
|
|
|
printdebug("primitive variable at line %d and column %d", @2.first_line, @2.first_column);
|
|
|
|
|
d = TYPE_PRIMITIVE;
|
|
|
|
|
CreateEntry(cur,d,(TableNode*)$1,$3,getAdInfo((TableNode*)$1));
|
|
|
|
|
|
|
|
|
|
if(CreateEntry(cur,d,(TableNode*)$1,$3,getAdInfo((TableNode*)$1)) == undefined){
|
|
|
|
|
throw_error(ERROR_TYPE, "Duplicate defination of primitive in declaration list");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
throw_error(ERROR_TYPE, "%s is being defined with an undefined type", $3);
|
|
|
|
|
CreateEntry(cur,d,(TableNode*)$1,$3,getAdInfo((TableNode*)$1));
|
|
|
|
|