/*89:*/ //line 40 "/usr/local/yacco2/o2linker/includes.w" /*87:*/ //line 23 "/usr/local/yacco2/o2linker/includes.w" #include "o2linker.h" /*:87*/ //line 41 "/usr/local/yacco2/o2linker/includes.w" /*20:*/ //line 125 "/usr/local/yacco2/o2linker/prog.w" void load_linkkw_into_tbl(yacco2::CAbs_lr1_sym*Kw){ using namespace yacco2_stbl; T_sym_tbl_report_card report_card; KCHARP kwkey= Kw->id(); if(*kwkey=='#')++kwkey; kw_in_stbl*kw= new kw_in_stbl(Kw); add_sym_to_stbl(report_card,*kwkey,*kw,table_entry::defed,table_entry::keyword); kw->stbl_idx(report_card.pos_); } void load_linkkws_into_tbl() { cout<<"Load linker's keywords "<symbol_; th_in_stbl*th_tbl2= (th_in_stbl*)P2->symbol_; thread_attributes*p1= th_tbl1->thread_in_stbl(); thread_attributes*p2= th_tbl2->thread_in_stbl(); int len_a= p1->thread_name_->c_string()->size(); int len_b= p2->thread_name_->c_string()->size(); string ucase_a; for(int x= 0;xthread_name_->c_string())[x]); } string ucase_b; for(int x= 0;xthread_name_->c_string())[x]); } if(len_amonolithic_=='n'){ if(p2->monolithic_=='n'){ result= strcmp(ucase_a.c_str(),ucase_b.c_str()); if(result<0)return true; return false; } return true; } if(p2->monolithic_=='n'){ return false; } int len_fqna= p1->thread_name_->c_string()->size(); int len_fqnb= p2->thread_name_->c_string()->size(); string ucase_fqna; for(int x= 0;xthread_name_->c_string())[x]); } string ucase_fqnb; for(int x= 0;xthread_name_->c_string())[x]); } if(len_fqna ::iterator fi= Visited_th.list_of_Ts_.begin(); std::vector ::iterator fie= Visited_th.list_of_Ts_.end(); for(;fi!=fie;++fi){ int t_enum= *fi; if(t_enum==LR1_ALL_SHIFT_OPERATOR){ /*29:*/ //line 332 "/usr/local/yacco2/o2linker/prog.w" INT_SET_ITER_type t_listi= Root_thread.fs_.find(LR1_EOLR); if(t_listi==Root_thread.fs_.end()){ Root_thread.fs_.insert(LR1_EOLR); } int no_of_T= T_DICTIONARY.size(); for(int x= 0;x ::iterator li= Visited_th.list_of_transitive_threads_.begin(); std::vector ::iterator lie= Visited_th.list_of_transitive_threads_.end(); for(;li!=lie;++li){ thread_attributes*th_att= *li; lrclog<<"------->process called thread's list thd: " <thread_name_->c_string()->c_str() <<" for root thd id: "< &Thd_list,AST*Mother_thd_t){ if(Thd_list.begin()==Thd_list.end())return; std::vector ::iterator li= Thd_list.begin(); std::vector ::iterator lie= Thd_list.end(); for(;li!=lie;++li){ thread_attributes*th_att= *li; if(Visit_graph[th_att->th_enum_]=='y')continue; Visit_graph[th_att->th_enum_]= 'y'; AST*called_t= new AST(*th_att); AST::add_child_at_end(*Mother_thd_t,*called_t); walk_called_thread_list(th_att->list_of_transitive_threads_,called_t); } } /*:38*//*39:*/ //line 519 "/usr/local/yacco2/o2linker/prog.w" void crt_called_thread_graph(thread_attributes&Visited_th){ if(Visit_graph[Visited_th.th_enum_]=='y')return; Visit_graph[Visited_th.th_enum_]= 'y'; AST*mother_thd_t= new AST(Visited_th); Visited_th.called_thread_graph_= mother_thd_t; walk_called_thread_list(Visited_th.list_of_transitive_threads_,mother_thd_t); } /*:39*//*40:*/ //line 528 "/usr/local/yacco2/o2linker/prog.w" void gen_each_grammar_s_referenced_threads(){ std::vector ::iterator thi= GRAMMAR_DICTIONARY.begin(); std::vector ::iterator thie= GRAMMAR_DICTIONARY.end(); for(;thi!=thie;++thi){ th_in_stbl*th_tbl= (th_in_stbl*)(*thi)->symbol_; thread_attributes*th_att= th_tbl->thread_in_stbl(); /*35:*/ //line 454 "/usr/local/yacco2/o2linker/prog.w" for(int vi= 0;vi ::iterator thi= GRAMMAR_DICTIONARY.begin(); std::vector ::iterator thie= GRAMMAR_DICTIONARY.end(); for(;thi!=thie;++thi){ th_in_stbl*th_tbl= (th_in_stbl*)(*thi)->symbol_; thread_attributes*th_att= th_tbl->thread_in_stbl(); if(th_att->monolithic_=='y')break; int x= sprintf (a ,thread_include_ns ,th_att->grammar_file_name_->c_string()->c_str() ); ofile.write(a,x); ofile< ::iterator thi= GRAMMAR_DICTIONARY.begin(); std::vector ::iterator thie= GRAMMAR_DICTIONARY.end(); for(;thi!=thie;++thi){ th_in_stbl*th_tbl= (th_in_stbl*)(*thi)->symbol_; thread_attributes*th_att= th_tbl->thread_in_stbl(); if(th_att->monolithic_=='y')break; quoted_name.clear(); const char*th_name= th_att->thread_name_->c_string()->c_str(); quoted_name+= '"'; quoted_name+= th_name; quoted_name+= '"'; int x= sprintf(a,thread_entry,th_name,quoted_name.c_str() ,th_att->fully_qualified_th_name_.c_str(),th_att->th_enum_ ,th_att->name_space_name_->c_string()->c_str() ,th_att->thread_name_->c_string()->c_str()); ofile.write(a,x); ofile<symbol_; thread_attributes*th_att= th_tbl->thread_in_stbl(); if(th_att->monolithic_=='y')break; if(first_entry==true){ first_entry= false; ofile<<" "; }else{ ofile<<" ,"; } int x= sprintf(a,thread_entry_name,th_att->thread_name_->c_string()->c_str()); ofile.write(a,x); ofile<symbol_; T_attributes*t_att= t_in_stbl->t_in_stbl(); x= sprintf(a ,T_list_to_thd_list_var ,terminal_id ,terminal_id ,t_att->fully_qualified_T_name_.c_str() ); ofile.write(a,x); ofile<symbol_; thread_attributes*th_att= th_tbl->thread_in_stbl(); div_t bb= div(th_id,BITS_PER_WORD); ULINT bit_pos_value= 1<thread_name_->c_string()->c_str()); ofile.write(a,x); ofile<symbol_; T_attributes*t_att= t_in_stbl->t_in_stbl(); INT_SET_type&th_list= *i; if(th_list.empty()==true){ if(first_item==true)first_item= false; else ofile<<" ,"; KCHARP T_array_entries= "%s// %s"; int x= sprintf(a,T_array_entries,"0",t_att->fully_qualified_T_name_.c_str()); ofile.write(a,x); ofile<fully_qualified_T_name_.c_str()); ofile.write(a,x); ofile< GRAMMAR_DICTIONARY; std::map > USED_THREADS_LIST; std::vector T_DICTIONARY; INT_SET_LIST_type T_THREAD_ID_LIST; int NO_OF_THREADS(0); int NO_WORDS_FOR_BIT_MAP(0); char Visit_graph[RESERVE_FIXED_NO_THREADS]; extern void XLATE_SYMBOLS_FOR_cweave(const char*Sym_to_xlate,char*Xlated_sym); extern void PRINT_CALLED_THREAD_LIST (yacco2::AST*Node,std::ofstream*Ow_linker_file,int Recursion_level); string cntl_file_name; yacco2::CHAR PRT_SW('n'); int main(int argc,char*argv[]) { cout< cntl_file_tokens(cntl_file_name.c_str()); TOKEN_GAGGLE P3_tokens; Clinker_pass3 linker_cntl_file_fsm; Parser linker_cntl_file(linker_cntl_file_fsm,&cntl_file_tokens,&P3_tokens,0,&Error_queue,0,0); linker_cntl_file.parse(); /*15:*/ //line 34 "/usr/local/yacco2/o2linker/prog.w" if(Error_queue.empty()!=true){ DUMP_ERROR_QUEUE(Error_queue); return 1; } /*:15*/ //line 53 "/usr/local/yacco2/o2linker/prog.w" /*:17*/ //line 1121 "/usr/local/yacco2/o2linker/prog.w" /*18:*/ //line 66 "/usr/local/yacco2/o2linker/prog.w" cout<<"Parse alphabet"< T_file_tokens(linker_cntl_file_fsm.t_alphabet_filename_.c_str()); TOKEN_GAGGLE cleanser_tokens; Clink_cleanser cleanser_fsm; Parser cleanser(cleanser_fsm,&T_file_tokens,&cleanser_tokens,0,&Error_queue,0,0); cleanser.parse(); using namespace NS_t_alphabet; TOKEN_GAGGLE T_tokens; Ct_alphabet T_fsm; Parser T_pass3(T_fsm,&cleanser_tokens,&T_tokens,0,&Error_queue,0,0); T_pass3.parse(); /*15:*/ //line 34 "/usr/local/yacco2/o2linker/prog.w" if(Error_queue.empty()!=true){ DUMP_ERROR_QUEUE(Error_queue); return 1; } /*:15*/ //line 80 "/usr/local/yacco2/o2linker/prog.w" /*:18*/ //line 1122 "/usr/local/yacco2/o2linker/prog.w" /*19:*/ //line 88 "/usr/local/yacco2/o2linker/prog.w" cout<<"Parse fsc files"< ::iterator ii= linker_cntl_file_fsm.grammars_fsc_files_.begin(); std::vector ::iterator iie= linker_cntl_file_fsm.grammars_fsc_files_.end(); for(;ii!=iie;++ii){ tok_can T_fsc_file_tokens(ii->c_str()); Clink_cleanser cleanser_fsc; Parser fsc_cleanser(cleanser_fsc,&T_fsc_file_tokens ,&cleanser_fsc_tokens,0,&Error_queue,0,0); fsc_cleanser.parse(); /*15:*/ //line 34 "/usr/local/yacco2/o2linker/prog.w" if(Error_queue.empty()!=true){ DUMP_ERROR_QUEUE(Error_queue); return 1; } /*:15*/ //line 100 "/usr/local/yacco2/o2linker/prog.w" using namespace NS_fsc_file; Cfsc_file fsc_file_fsm; Parser fsc_file_pass(fsc_file_fsm,&cleanser_fsc_tokens ,&fsc_file_output_tokens,0,&Error_queue,0,0); fsc_file_pass.parse(); /*15:*/ //line 34 "/usr/local/yacco2/o2linker/prog.w" if(Error_queue.empty()!=true){ DUMP_ERROR_QUEUE(Error_queue); return 1; } /*:15*/ //line 107 "/usr/local/yacco2/o2linker/prog.w" cleanser_fsc_tokens.clear(); fsc_file_output_tokens.clear(); } /*15:*/ //line 34 "/usr/local/yacco2/o2linker/prog.w" if(Error_queue.empty()!=true){ DUMP_ERROR_QUEUE(Error_queue); return 1; } /*:15*/ //line 111 "/usr/local/yacco2/o2linker/prog.w" /*:19*/ //line 1123 "/usr/local/yacco2/o2linker/prog.w" /*21:*/ //line 173 "/usr/local/yacco2/o2linker/prog.w" std::vector ::iterator th_i= GRAMMAR_DICTIONARY.begin(); std::vector ::iterator th_ie= GRAMMAR_DICTIONARY.end(); for(;th_i!=th_ie;++th_i){ table_entry*tbl_entry= *th_i; if(tbl_entry->defined_==true)continue; CAbs_lr1_sym*sym= new Err_bad_th_in_list; sym->set_who_created("linker.w",__LINE__); thread_attributes*th_goodies= ((th_in_stbl*)tbl_entry->symbol_)->thread_in_stbl(); sym->set_rc(*th_goodies); Error_queue.push_back(*sym); } /*15:*/ //line 34 "/usr/local/yacco2/o2linker/prog.w" if(Error_queue.empty()!=true){ DUMP_ERROR_QUEUE(Error_queue); return 1; } /*:15*/ //line 187 "/usr/local/yacco2/o2linker/prog.w" /*:21*/ //line 1124 "/usr/local/yacco2/o2linker/prog.w" /*23:*/ //line 263 "/usr/local/yacco2/o2linker/prog.w" cout<<"Sort thread dictionary"< ::iterator dth_i= GRAMMAR_DICTIONARY.begin(); std::vector ::iterator dth_ie= GRAMMAR_DICTIONARY.end(); int pos(-1); for(;dth_i!=dth_ie;++dth_i){ ++pos; table_entry*tbl_entry= *dth_i; thread_attributes*th_goodies= ((th_in_stbl*)tbl_entry->symbol_)->thread_in_stbl(); yacco2::lrclog<<"tbl entry*: " <th_enum_ <<" mono: "<monolithic_ <<" thread name: "<thread_name_->c_string()->c_str() <<" FQN: "<fully_qualified_th_name_.c_str() <<" K: "<fsm_comments_->c_string()->c_str() < ::iterator ri= GRAMMAR_DICTIONARY.begin(); std::vector ::iterator rie= GRAMMAR_DICTIONARY.end(); for(int p= -1;ri!=rie;++ri){ ++p; table_entry*tbl_entry= *ri; thread_attributes*th_goodies= ((th_in_stbl*)tbl_entry->symbol_)->thread_in_stbl(); th_goodies->th_enum_= p; if(th_goodies->monolithic_=='n')++NO_OF_THREADS; } /*:25*/ //line 1127 "/usr/local/yacco2/o2linker/prog.w" /*26:*/ //line 304 "/usr/local/yacco2/o2linker/prog.w" int max_thds_supported= SPECULATIVE_NO_BIT_WORDS*BITS_PER_WORD; if(NO_OF_THREADS> max_thds_supported){ char a[SMALL_BUFFER_4K]; KCHARP msg= "Error: not enough space for thread bit map manufacture!" " # threads: %i, Linker's maximum no of threads supported: %i. \n" " Please expand SPECULATIVE_NO_BIT_WORDS"; sprintf(a,msg,NO_OF_THREADS,max_thds_supported); Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } /*:26*/ //line 1128 "/usr/local/yacco2/o2linker/prog.w" /*36:*/ //line 475 "/usr/local/yacco2/o2linker/prog.w" /*34:*/ //line 447 "/usr/local/yacco2/o2linker/prog.w" for(int vi= 0;vi ::iterator thi= GRAMMAR_DICTIONARY.begin(); std::vector ::iterator thie= GRAMMAR_DICTIONARY.end(); for(;thi!=thie;++thi){ th_in_stbl*th_tbl= (th_in_stbl*)(*thi)->symbol_; thread_attributes*th_att= th_tbl->thread_in_stbl(); if(th_att->monolithic_=='n'){ yacco2::lrclog<<"thread being walked: " <thread_name_->c_string()->c_str()<<" id: " <th_enum_<th_enum_,*th_att); } } thi= GRAMMAR_DICTIONARY.begin(); thie= GRAMMAR_DICTIONARY.end(); for(;thi!=thie;++thi){ th_in_stbl*th_tbl= (th_in_stbl*)(*thi)->symbol_; thread_attributes*th_att= th_tbl->thread_in_stbl(); /*35:*/ //line 454 "/usr/local/yacco2/o2linker/prog.w" for(int vi= 0;visyntax_code()->c_str()); emit_global_thread_include_files(ofile); emit_global_bit_maps(ofile); if(NO_OF_THREADS==0){ emit_no_threads(ofile); }else{ emit_global_thread_stable(ofile); emit_T_fs_of_potential_threads(ofile); } ofile.close(); /*:51*/ //line 1130 "/usr/local/yacco2/o2linker/prog.w" /*50:*/ //line 727 "/usr/local/yacco2/o2linker/prog.w" gen_each_grammar_s_referenced_threads(); char big_buf_[BIG_BUFFER_32K]; std::string w_linker_filename_("o2linker_doc.w"); std::ofstream ow_linker_file_; ow_linker_file_.open(w_linker_filename_.c_str(),ios_base::out|ios::trunc); /*46:*/ //line 640 "/usr/local/yacco2/o2linker/prog.w" KCHARP w_doc_index= "\\input \"supp-pdf\"\n" "\\input \"/usr/local/yacco2/diagrams/o2mac.tex\"\n" "\\IDXlinkerdoctitle{%s}{%s}{%s}"; char xlate_file[Max_cweb_item_size];xlate_file[0]= (char)0; char xlate_fscfile[Max_cweb_item_size];xlate_fscfile[0]= (char)0; XLATE_SYMBOLS_FOR_cweave(w_linker_filename_.c_str(),xlate_file); XLATE_SYMBOLS_FOR_cweave(cntl_file_name.c_str(),xlate_fscfile); int x= sprintf(big_buf_ ,w_doc_index ,xlate_file ,xlate_file ,xlate_fscfile ); ow_linker_file_.write(big_buf_,x); ow_linker_file_< ::iterator ithi= GRAMMAR_DICTIONARY.begin(); std::vector ::iterator ithie= GRAMMAR_DICTIONARY.end(); for(;ithi!=ithie;++ithi){ xlate_gfile[0]= (char)0; rebuild_comment[0]= (char)0; fandk[0]= (char)0; xlate_thnm[0]= (char)0; xlate_tnm[0]= (char)0; table_entry*tbl_entry= *ithi; thread_attributes*th_att= ((th_in_stbl*)tbl_entry->symbol_)->thread_in_stbl(); /*42:*/ //line 547 "/usr/local/yacco2/o2linker/prog.w" XLATE_SYMBOLS_FOR_cweave(th_att->thread_name_->c_string()->c_str(),xlate_gfile); XLATE_SYMBOLS_FOR_cweave(th_att->fsm_comments_->c_string()->c_str(),rebuild_comment); strcat(fandk,xlate_gfile); strcat(fandk," --- "); strcat(fandk,rebuild_comment); int fandk_len= strlen(fandk); if(fandk_lencalled_thread_graph_,&prt_functr); while(pre.base_stk_.cur_stk_rec()!=0){ pre.exec(); } /*:43*/ //line 694 "/usr/local/yacco2/o2linker/prog.w" /*45:*/ //line 619 "/usr/local/yacco2/o2linker/prog.w" ow_linker_file_<<"{\\parindent=6pc"<"; INT_SET_ITER_type fsi= th_att->fs_.begin(); INT_SET_ITER_type fsie= th_att->fs_.end(); char xlate_tnm[Max_cweb_item_size]; for(;fsi!=fsie;++fsi){ int tenum= *fsi; table_entry*t_entry= T_DICTIONARY[tenum]; tth_in_stbl*t_in_stbl= (tth_in_stbl*)t_entry->symbol_; T_attributes*t_att= t_in_stbl->t_in_stbl(); XLATE_SYMBOLS_FOR_cweave(t_att->fully_qualified_T_name_.c_str(),xlate_tnm); int x= sprintf(big_buf_,fs,xlate_tnm,xlate_tnm); ow_linker_file_.write(big_buf_,x); ow_linker_file_< > ::iterator ti= USED_THREADS_LIST.find(th_att->thread_name_->c_string()->c_str()); ow_linker_file_<<"{\\parindent=6pc"<"; std::vector &tt= ti->second; std::vector ::iterator tti= tt.begin(); std::vector ::iterator ttie= tt.end(); char xlate_thnm[Max_cweb_item_size]; for(;tti!=ttie;++tti){ XLATE_SYMBOLS_FOR_cweave(tti->c_str(),xlate_thnm); int x= sprintf(big_buf_,used_threads,xlate_thnm,xlate_thnm); ow_linker_file_.write(big_buf_,x); ow_linker_file_<second.empty()==YES)ow_linker_file_<<" none"<