void executeInstructions(instruction instru, matrix ** arrayMatrix, int nMatrix) { int i; for (i = 0; i < instru.n; ++i) { if (i!=0) printf("\n"); char command[10]; strcpy(command,instru.data[i]); //Copiar el comanco char firstId, secondId,operation; firstId = command[0]; secondId = command[2]; operation = tolower(command[4]); //Separar comando en ids de matrices y operaciones int first, second; first = findMatrix(arrayMatrix,nMatrix,firstId); second = findMatrix(arrayMatrix,nMatrix,secondId); //encontrar la posicion de las matrices dentro del arreglo if(operation=='a') { printf("%c + %c\n",firstId,secondId); display(arrayMatrix[first],arrayMatrix[second],add); } else if(operation == 'm') { printf("%c * %c\n",firstId,secondId); display(arrayMatrix[first],arrayMatrix[second],mult); } } }
/** * Print the symbol table in the specified format. * @param list */ void printSymbolTable(STList list) { int a = 0; STList readList = list; while(readList != NULL) { STable entry = readList->table; while(entry->data != NULL) { printf("%20s%16s(%2d-%2d)%16s",entry->data->value,readList->functionName,readList->startLineNumber,readList->endLineNumber,getTokenName(entry->data->type)); if(entry->data->type == NUM || entry->data->type == INT) { printf("%s"," "); printf("%15d",a); a = a+2; } else if(entry->data->type == RNUM || entry->data->type == REAL) { printf("%s"," "); printf("%15d",a); a= a+4; } else if(entry->data->type == STR || entry->data->type == STRING) { printf("%s"," "); printf("%15d",a); a = a + findLength(entry->data->value,readList,0); } else if(entry->data->type == MATRIX) { matrixSizes mat = findMatrix(entry->data->value,readList); if(mat == NULL) { printf(",0,0"); } else { printf(",%d,%d",mat->rows,mat->columns); } } printf("\n"); entry = entry->nextEntry; } if(readList->childList != NULL) printSymbolTable(readList->childList); if(readList->sisterList != NULL) readList = readList->sisterList; else readList = NULL; } }