/* *********************************************************************************************************** * generateASM: * filename : This has the filename of the file in which the ASM code will be written. * This function initiates the process of generation of code. This is called after * startGenertation which is actually responsible for creation three address code for all instructions * This function is responsible to print those three address code in meaningful way in the file specified. *********************************************************************************************************** */ void generateASM(char* filename){ InstructionList* head = CODE_HEAD; FILE* filePtr = fopen(filename,"w"); initializeCode(filePtr); while(head!=NULL){ printInstruction(filePtr,head); head = head->next; } finalizeCode(filePtr); fclose(filePtr); }
int main(void) { struct symbol sym; wk_table = hmap_init(MAP_SIZE, 15*sizeof(char), sizeof(int), hash); init_wk_table(wk_table); sym_table = hmap_init(MAP_SIZE, ID_SIZE*sizeof(char), sizeof(struct symbol), hash); undeclared_vars = squeue_init(100, sizeof(struct symbol)); codeInit(); yyparse(); finalizeCode(); hmap_free(wk_table); hmap_free(sym_table); squeue_free(undeclared_vars); return SUCCESS; }