void *analyse(Program *prog) { //Generate the symbol table isValid = TRUE; sym_table *table = gen_sym_table(prog); //Analyse each proc Procs *procs = prog->procedures; while (procs != NULL) { Proc *p = procs->first; analyse_statements(p->body->statements, table, p->header->id); procs = procs->rest; } //For debug purposes; #ifdef DEBUG dump_symbol_table(table); #endif //Check for unused symbols check_unused_symbols(table, prog); //Perform simple analysis check_main(table); if (isValid) { return (void *) table; } else { return NULL; } }
int main( int argc,char *argv[]) { /* el alumno debera inicializar la variable yyin segun corresponda */ linea = (char *) malloc (2); strcat(linea, ""); nro_linea=0; // inicializo la tabla de simbolos inic_tablas(); // inicializo lista parametros init_lista_param(); if (argc != 3) { error_handler(6); error_handler(COD_IMP_ERRORES); exit(1); } else { if(strcmp(argv[1],"-c") == 0) { if ((yyin = fopen(argv[2], "r" )) == NULL) { error_handler(7); error_handler(COD_IMP_ERRORES); exit(1); } } else { printf("falta el -c\n"); } } sbol=&token1 ;/* la variable token */ scanner(); unidad_traduccion(); check_main(); // if (sbol->codigo != CEOF) { error_handler(8); } }
/** * The main function. * @param argc * Number of arguments. * @param argv * Arguments. * @return * 0. */ int main(int argc, char **argv) { #ifdef WIN32 /* Open all files in binary mode by default. */ _set_fmode(_O_BINARY); #endif init(argc, argv); memset(&marker, 0, sizeof(struct obj)); if (settings.plugin_unit_tests) { LOG(INFO, "Running plugin unit tests..."); object *activator = player_get_dummy(PLAYER_TESTING_NAME1, NULL); object *me = player_get_dummy(PLAYER_TESTING_NAME2, NULL); trigger_unit_event(activator, me); if (!settings.unit_tests) { cleanup(); exit(0); } } if (settings.unit_tests) { #ifdef HAVE_CHECK LOG(INFO, "Running unit tests..."); cleanup(); check_main(argc, argv); exit(0); #else LOG(ERROR, "Unit tests have not been compiled, aborting."); exit(1); #endif } atexit(cleanup); if (settings.world_maker) { #ifdef HAVE_WORLD_MAKER LOG(INFO, "Running the world maker..."); world_maker(); exit(0); #else LOG(ERROR, "Cannot run world maker; server was not compiled with libgd, exiting..."); exit(1); #endif } if (!settings.no_console) { console_start_thread(); } process_delay = 0; LOG(INFO, "Server ready. Waiting for connections..."); for (; ; ) { if (unlikely(shutdown_timer_check())) { break; } console_command_handle(); socket_server_process(); if (++process_delay >= max_time_multiplier) { process_delay = 0; main_process(); } socket_server_post_process(); /* Sleep proper amount of time before next tick */ sleep_delta(); } server_shutdown(); return 0; }
void typeCheck(TreeNode * syntaxTree){ cur_symtab=root_symtab; traverse(syntaxTree,checkNode_Pre,checkNode_Post); check_main(); }
void modify(FILE *fp) { FILE *ft; ft=fopen("copy.c","w"); char ch; int count=1,flag=0,no=0; fputs("#include<stdio.h>\n#include<signal.h>\n#include<stdlib.h>\n",ft); fputs("int ABCDEF=0;\n",ft); fprintf(ft,"void sig_handler(int signum){\n"); fprintf(ft,"printf(\"Segmentation fault arrived at line="); fputs("%d\\n\",ABCDEF);\n",ft); fputs("exit(0);\n}\n",ft); while((ch=fgetc(fp))!=EOF) { if(ch=='{') no++; if(ch=='}'&&no>0) no--; if(ch=='m') { int ret=check_main(fp); if(ret==1) { fputs("main(",ft); while((ch=fgetc(fp))!='{') { if(ch=='\n') count++; fputc(ch,ft); } if(ch=='{') no++; fputc(ch,ft); fputs("signal(SIGSEGV,sig_handler);",ft); continue; } } if(ch=='\n') { count++; //printf("count=%d\n",count); fseek(fp,-2,SEEK_CUR); ch=fgetc(fp); if(ch==')'||ch=='>'||ch=='}') flag=1; ch=fgetc(fp); if(!flag&&no>0) fprintf(ft,"\nABCDEF=%d;\n",count); flag=0; } fputc(ch,ft); } fclose(ft); // fseek(ft,5,SEEK_SET); // printf("%c\n",fgetc(ft)); // while(fgetc(ft)!='{') // ; // fputs("signal(SIGSEGV,sig_handler);",ft); /* fscanf(ft,"%s",temp); printf("%s\n",temp); char str[]="int main()"; int i=10; while(i--) { if(strcmp(temp,str)==0) { printf("sdjf\n"); fputs("hello",ft); break; } fscanf(fp,"%s",temp); printf("%s\n",temp); } */ }