/** * @param argc Number of arguments on the command line. * @param argv Value of arguments on the command line. * @return Whether this was a success or not. * @brief Main entry point for MIPS assembler. * */ int main ( int argc, char *argv[] ) { unsigned int nlines = 0; char *file = NULL; if ( argc <2 ) { print_usage(argv[0]); exit( EXIT_FAILURE ); } file = argv[argc-1]; if ( NULL == file ) { fprintf( stderr, "Missing ASM source file, aborting.\n" ); exit( EXIT_FAILURE ); } L_lexem L = NULL; L_lexem l_etiq = NULL; int nb_inst; instru_def* dico = load_dico("dico/dico_instr",&nb_inst); /* ---------------- do the lexical analysis -------------------*/ lex_load_file( file, &nlines, &L); DEBUG_MSG("source code got %d lines", nlines); L_lexem nL = reverse_list_lex(L); free_liste(L,1); afficher_liste_lex(nL); char test[20]; sprintf(test,"%ld",int_to_int(4096)); printf("\n%ld %s\n",strlen(test),test); printf("\n%ld \n",sizeof(unsigned long)); verif_gram(nlines, nL, &l_etiq, dico, nb_inst); /* ---------------- Free memory and terminate -------------------*/ /* TODO free everything properly*/ free_liste(nL,0); free_liste(l_etiq,1); free_dico(&dico,nb_inst); free(dico); dico = NULL; exit( EXIT_SUCCESS ); }
void free_liste(liste* l){ if(l == NULL){ return; } else{ free_liste(l->suivant); free(l); } }