/* 编译从这开始 */ int main (int argc, char **argv) { int i; //share_fs (); CurrentHeap = &ProgramHeap; argc--; argv++; #if defined(_LF) init_file_layout (); init_memory_layout (); #endif CreateLogFile (); #if 1 i = ParseCommandLine (argc, argv); /* 初始化词法分析器 */ SetupLexer (); /* 按照配置文件设置基本类型和默认函数的属性 */ SetupTypeSystem (); for ( ; i < argc; i++ ) { Compile (argv[i]); } #endif CloseLogFile (); return (ErrorCount != 0 ? -1 : 0); }
void LexTest (char *filename) { ReadSourceFile (filename); PRINT ("LexTest start... \n"); SetupLexer (); int tok = 0; SkipWhiteSpace (); while (1) { tok = Scanners[*CURRENT](); if (TK_END == tok) break; PRINT ("%-8s|(%d, %d) ", TokenString[tok], TokenCoord.line, TokenCoord.col); if (TK_ID == tok) PRINT ("%s", (char*)TokenValue.p); PRINT ("\n"); } PRINT ("词法分析结束\n"); PRINT ("LexTest end... \n"); CloseSourceFile (); }
/** * The compiler's main entry point. * The compiler handles C files one by one. */ int main(int argc, char *argv[]) { int i; CurrentHeap = &ProgramHeap; argc--; argv++; i = ParseCommandLine(argc, argv); SetupRegisters(); SetupLexer(); SetupTypeSystem(); for (; i < argc; ++i) { Compile(argv[i]); } return (ErrorCount != 0); }
int main(int argc, char *argv[]) { /* setup */ char *path = "./data/ct/"; char *path2 = "/home/gyc/Sources/linux.doc/kernel/"; vector_char str; vector_char_init(&str,100); VECTOR(str)[0] = '\0'; SetupLexer(); dic_setup(); struct dictionary *dict = new_dictionary(10000); graph_t lkn; vector_int edges; catch_function_call_dir(path, dict, &edges); printf("capacity=%d,size=%d\n",dict_capacity(dict), dict_size(dict)); new_graph(&lkn, &edges, 0, GRAPH_DIRECTED); struct dictionary *filedict = new_dictionary(4); vector_funcP flist; vector_funcP_init_(&flist, dict_size(dict)); get_function_filename(path2, dict, filedict, &flist); printf("filedict: capacity=%d,size=%d\n",dict_capacity(filedict), dict_size(filedict)); /* reciprocal */ printf("reciprocal = %f \n", graph_reciprocal(&lkn)); vector_double res; vector_double_init(&res, 0); graph_betweenness(&lkn, &res, graph_vss_all(), GRAPH_DIRECTED); printf("betweenness directed:"); print_vector_double(&(res),stdout); vector_double_destroy(&res); /* degree */ graph_degree(&lkn, &edges, graph_vss_all(), GRAPH_OUT, GRAPH_NO_LOOPS); printf(">>>out, no loops"); int min, max, sum; double ave; graph_degree_minmax_avesum(&lkn, &min, &max, &ave, &sum, GRAPH_OUT, GRAPH_NO_LOOPS); printf("minout=%d\nmaxout=%d\nsumout=%d\naveout=%f\n",min,max,sum,ave); graph_degree_minmax_avesum(&lkn, &min, &max, &ave, &sum, GRAPH_IN, GRAPH_NO_LOOPS); printf("minin=%d\nmaxin=%d\nsumin=%d\navein=%f\n",min,max,sum,ave); /* fast community */ graph_reverse(&lkn); vector_int v1; vector_int_init(&v1,0); int ncom = 0; double modularity = graph_community_fastgreedy(&lkn, &v1, &ncom); printf("modularity = %f,ncom = %d\n",modularity,ncom); FILE *f = fopen("funccom.fc.xlsx","w"); fprintf(f, "comID\tname\n"); for (int i = 0; i < dict_size(dict);i++) { fprintf(f, "%d\t", VECTOR(v1)[i]); struct rb_node* e = dict_ele(dict, i); dic_traceback_string(e, &str); fprintf(f, "%s\n",VECTOR(str)); } fclose(f); f = fopen("comID.fc.xlsx","w"); output_com_filename(&flist, &v1, graph_vertices_count(&lkn), ncom, filedict, f); fclose(f); //print_vector_int(&v1, stdout); print_communities(&lkn, &v1, "community.fc.xlsx", "comedge.fc.xlsx"); vector_funcP_destroy(&flist); vector_int_destroy(&v1); vector_char_destroy(&str); vector_int_destroy(&edges); graph_destroy(&lkn); return 0; }