starting to work on grammar fixes
This commit is contained in:
@ -174,14 +174,15 @@ definition:
|
|||||||
} L_PAREN {
|
} L_PAREN {
|
||||||
TableNode * parameter = getParameter(getTypeEntry(table_lookup(getAncestor(cur), $1)));
|
TableNode * parameter = getParameter(getTypeEntry(table_lookup(getAncestor(cur), $1)));
|
||||||
//TableNode *parameter = getParameter(table_lookup(getAncestor(cur), getType(table_lookup(getAncestor(cur), $1))));
|
//TableNode *parameter = getParameter(table_lookup(getAncestor(cur), getType(table_lookup(getAncestor(cur), $1))));
|
||||||
printdebug("parameter type: %s", getType(parameter));
|
printdebug("type of parameter: %s", getName(parameter));
|
||||||
if (parameter == undefined) {
|
if (parameter == undefined) {
|
||||||
printdebug("[TYPE CHECK] function defined with as, but parameter is undefined at line %d, column %d", @1.first_line, @1.first_column);
|
printdebug("[TYPE CHECK] function defined with as, but parameter is undefined at line %d, column %d", @1.first_line, @1.first_column);
|
||||||
}else if(getAdInfoType(parameter) != TYPE_RECORD){
|
}else if(getAdInfoType(parameter) != TYPE_RECORD_TYPE){
|
||||||
int type_of_param_type = getAdInfoType(parameter);
|
int type_of_param_type = getAdInfoType(parameter);//this is an enum value defined in symbol_table.h
|
||||||
if( type_of_param_type == TYPE_UNDEFINED
|
if( type_of_param_type == TYPE_UNDEFINED
|
||||||
|| type_of_param_type == TYPE_FUNCTION_DECLARATION
|
|| type_of_param_type == TYPE_FUNCTION_DECLARATION
|
||||||
|| type_of_param_type == TYPE_ARRAY
|
|| type_of_param_type == TYPE_ARRAY
|
||||||
|
|| type_of_param_type == TYPE_PRIMITIVE
|
||||||
|| type_of_param_type == TYPE_ALL_ELSE
|
|| type_of_param_type == TYPE_ALL_ELSE
|
||||||
|| type_of_param_type == TYPE_SYSTEM_DEFINED
|
|| type_of_param_type == TYPE_SYSTEM_DEFINED
|
||||||
|| type_of_param_type == TYPE_STRING){ // note that strings are actually arrays so this is unused
|
|| type_of_param_type == TYPE_STRING){ // note that strings are actually arrays so this is unused
|
||||||
@ -355,7 +356,7 @@ declaration:
|
|||||||
printdebug("ID/TYPE: %s, ID: %s", getName((TableNode*)$1), $3) ;
|
printdebug("ID/TYPE: %s, ID: %s", getName((TableNode*)$1), $3) ;
|
||||||
int d = getAdInfoType((TableNode*)$1);
|
int d = getAdInfoType((TableNode*)$1);
|
||||||
if(d == TYPE_UNDEFINED) {
|
if(d == TYPE_UNDEFINED) {
|
||||||
printdebug("undefined type at line %d and column %d", @2.first_line, @2.first_column);
|
printdebug("[TYPE CHECK] undefined type at line %d and column %d", @2.first_line, @2.first_column);
|
||||||
CreateEntry(cur,d,(TableNode*)$1,$3,getAdInfo((TableNode*)$1));
|
CreateEntry(cur,d,(TableNode*)$1,$3,getAdInfo((TableNode*)$1));
|
||||||
}
|
}
|
||||||
else if(d == TYPE_FUNCTION_TYPE) {
|
else if(d == TYPE_FUNCTION_TYPE) {
|
||||||
@ -373,11 +374,12 @@ declaration:
|
|||||||
d = TYPE_RECORD;
|
d = TYPE_RECORD;
|
||||||
CreateEntry(cur,d,(TableNode*)$1,$3,getAdInfo((TableNode*)$1));
|
CreateEntry(cur,d,(TableNode*)$1,$3,getAdInfo((TableNode*)$1));
|
||||||
}
|
}
|
||||||
else if(d == TYPE_PRIMITIVE){
|
else if(d == TYPE_PRIMITIVE_TYPE){
|
||||||
printdebug("primitive variable at line %d and column %d", @2.first_line, @2.first_column);
|
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));
|
CreateEntry(cur,d,(TableNode*)$1,$3,getAdInfo((TableNode*)$1));
|
||||||
}else {
|
}else {
|
||||||
printdebug("other invalid type passed at %d and column %d", @2.first_line, @2.first_column);
|
printdebug("[TYPE CHECK] other invalid type passed at %d and column %d", @2.first_line, @2.first_column);
|
||||||
CreateEntry(cur,d,(TableNode*)$1,$3,getAdInfo((TableNode*)$1));
|
CreateEntry(cur,d,(TableNode*)$1,$3,getAdInfo((TableNode*)$1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1142,6 +1142,19 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getAdInfoType(entry) == TYPE_PRIMITIVE_TYPE) {
|
||||||
|
char *primAdInfo = (char *)malloc(100);
|
||||||
|
sprintf(primAdInfo, " size-%d bytes", getPrimSize(getTypeEntry(entry)));
|
||||||
|
if (parentScopeNum == 0) {
|
||||||
|
st_fprint(file_ptr, getName(entry), currentScopeNum, -100, " Primitive Type", primAdInfo);
|
||||||
|
} else {
|
||||||
|
//printdebug("%sTHIS ONE", COLOR_RED);
|
||||||
|
printTableNode(entry);
|
||||||
|
char *primType = (char *)malloc(sizeof(getType(entry) + 1));
|
||||||
|
sprintf(primType, " %s", getType(entry));
|
||||||
|
st_fprint(file_ptr, getName(entry), currentScopeNum, parentScopeNum, primType, primAdInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (getAdInfoType(entry) == TYPE_PRIMITIVE) {
|
if (getAdInfoType(entry) == TYPE_PRIMITIVE) {
|
||||||
char *primAdInfo = (char *)malloc(100);
|
char *primAdInfo = (char *)malloc(100);
|
||||||
sprintf(primAdInfo, " size-%d bytes", getPrimSize(getTypeEntry(entry)));
|
sprintf(primAdInfo, " size-%d bytes", getPrimSize(getTypeEntry(entry)));
|
||||||
@ -1152,7 +1165,7 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr) {
|
|||||||
printTableNode(entry);
|
printTableNode(entry);
|
||||||
char *primType = (char *)malloc(sizeof(getType(entry) + 1));
|
char *primType = (char *)malloc(sizeof(getType(entry) + 1));
|
||||||
sprintf(primType, " %s", getType(entry));
|
sprintf(primType, " %s", getType(entry));
|
||||||
st_fprint(file_ptr, getName(entry), currentScopeNum, parentScopeNum, primType, primAdInfo);
|
st_fprint(file_ptr, getName(entry), currentScopeNum, parentScopeNum, getType(entry), "Primitive Instance");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,8 @@ typedef enum {
|
|||||||
TYPE_UNDEFINED = 8,
|
TYPE_UNDEFINED = 8,
|
||||||
TYPE_RECORD = 9,
|
TYPE_RECORD = 9,
|
||||||
TYPE_ARRAY = 10,
|
TYPE_ARRAY = 10,
|
||||||
TYPE_SYSTEM_DEFINED = 11
|
TYPE_SYSTEM_DEFINED = 11,
|
||||||
|
TYPE_PRIMITIVE_TYPE = 12
|
||||||
} types;
|
} types;
|
||||||
|
|
||||||
AdInfo *CreatePrimitiveInfo(int size);
|
AdInfo *CreatePrimitiveInfo(int size);
|
||||||
|
Reference in New Issue
Block a user