/*9:*/ #line 260 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" /*22:*/ #line 462 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" #include "yacco2_stbl.h" /*:22*/ #line 261 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" ; using namespace NS_yacco2_err_symbols; using namespace NS_yacco2_terminals; using namespace yacco2; /*20:*/ #line 454 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" table_entry yacco2_stbl::stbl[hash_table_size]= {table_entry()}; char yacco2_stbl::char_pool_[char_pool_size]= {}; int yacco2_stbl::char_pool_idx_(0); /*:20*//*24:*/ #line 504 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" void yacco2_stbl::hash_fnct(T_sym_tbl_report_card&Report,const char&Key) { Report.pos_= -1; Report.key_len_= strlen(&Key); if(Report.key_len_==0){ Report.status_= T_sym_tbl_report_card::failure; Report.err_entry_= new Err_zero_len_sym; return; } Report.key_len_+= 1; const char*k= &Key; Report.pos_= *k++; for(;*k!=0;++k){ Report.pos_= ((Report.pos_*257)+*k)%hash_table_size; } Report.status_= T_sym_tbl_report_card::okay; } /*:24*//*25:*/ #line 548 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" void yacco2_stbl::add_sym_to_stbl (T_sym_tbl_report_card&Report ,const char&Name ,yacco2::CAbs_lr1_sym&Sym ,table_entry::defined_or_used_typ Why ,table_entry::entry_typ What) { static int guest_cnt(0); hash:/*21:*/ #line 459 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" yacco2_stbl::hash_fnct(Report,Name); /*:21*/ #line 557 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" ; /*26:*/ #line 566 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" if(Report.status_==T_sym_tbl_report_card::failure)return; if(Report.status_==T_sym_tbl_report_card::fatal)return; /*:26*/ #line 558 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" ; compare:/*27:*/ #line 572 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" table_entry*te= &yacco2_stbl::stbl[Report.pos_]; int r(0); if(te->vacant_==true)goto insert; r= strcmp(te->key_,&Name); if(r==0){ Report.status_= T_sym_tbl_report_card::failure; Report.err_entry_= new Err_dup_entry_in_sym_table; Report.tbl_entry_= te; Report.key_len_= 0; return; } /*:27*/ #line 559 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" ; advance:/*28:*/ #line 587 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" --Report.pos_; if(Report.pos_<0)Report.pos_+= hash_table_size; goto compare; /*:28*/ #line 560 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" ; insert:/*29:*/ #line 593 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" if(guest_cnt==hash_table_full){ Report.status_= T_sym_tbl_report_card::failure; Report.err_entry_= new Err_sym_tbl_full; return; } if(char_pool_idx_+Report.key_len_> char_pool_size){ Report.status_= T_sym_tbl_report_card::failure; Report.err_entry_= new Err_sym_tbl_char_pool_full; return; } ++guest_cnt; te->pos_= Report.pos_; te->vacant_= false; char*key_name= &char_pool_[char_pool_idx_]; strncpy(key_name,&Name,Report.key_len_); te->key_= key_name; te->key_len_= Report.key_len_; char_pool_idx_+= Report.key_len_; te->symbol_= &Sym; te->type_= What; if(Why==table_entry::used) te->used_= true; else te->defined_= true; Report.status_= T_sym_tbl_report_card::okay; Report.action_= T_sym_tbl_report_card::inserted; Report.tbl_entry_= te; /*:29*/ #line 561 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" ; } /*:25*//*30:*/ #line 644 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" void yacco2_stbl::find_sym_in_stbl(T_sym_tbl_report_card&Report,const char&Name) { hash:/*21:*/ #line 459 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" yacco2_stbl::hash_fnct(Report,Name); /*:21*/ #line 647 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" ; /*26:*/ #line 566 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" if(Report.status_==T_sym_tbl_report_card::failure)return; if(Report.status_==T_sym_tbl_report_card::fatal)return; /*:26*/ #line 648 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" ; compare:/*31:*/ #line 654 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" Report.tbl_entry_= &yacco2_stbl::stbl[Report.pos_]; table_entry*te= Report.tbl_entry_; if(te->vacant_==true){ Report.status_= T_sym_tbl_report_card::okay; Report.action_= T_sym_tbl_report_card::not_fnd; return; } int r= strcmp(te->key_,&Name); if(r==0){ Report.status_= T_sym_tbl_report_card::okay; Report.action_= T_sym_tbl_report_card::fnd; return; } /*:31*/ #line 649 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" ; advance:/*32:*/ #line 670 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" --Report.pos_; if(Report.pos_<0)Report.pos_+= hash_table_size; goto compare; /*:32*/ #line 650 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" ; } /*:30*//*33:*/ #line 684 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" void yacco2_stbl::get_sym_entry_by_sub(T_sym_tbl_report_card&Report,int Sub) { Report.pos_= Sub; if((Sub<0)||(Sub> hash_table_full)){ Report.status_= T_sym_tbl_report_card::failure; Report.err_entry_= new Err_subscript_out_of_range; return; } Report.tbl_entry_= &yacco2_stbl::stbl[Sub]; Report.status_= T_sym_tbl_report_card::okay; if(Report.tbl_entry_->vacant_==false) Report.action_= T_sym_tbl_report_card::fnd; else Report.action_= T_sym_tbl_report_card::not_fnd; } /*:33*//*34:*/ #line 710 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" void yacco2_stbl::test_program() { /*8:*/ #line 256 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" using namespace yacco2_stbl; /*:8*/ #line 713 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" ; /*35:*/ #line 724 "/usr/local/yacco2/compiler/stbl/yacco2_stbl.w" const char*zero_len_name= ""; T_eol*a_good_sym= new T_eol; int cnt(0); T_sym_tbl_report_card report_card; std::cout<<"Prime number used: "<id__<c_str(),*a_good_sym,table_entry::defed,table_entry::rule); if(report_card.status_==T_sym_tbl_report_card::failure){ std::cout<<"Error first entry failed: "<id__<id__<c_str(),*a_good_sym,table_entry::defed,table_entry::rule); if(report_card.status_==T_sym_tbl_report_card::failure){ std::cout<<"Error same key address: "<id__<c_str() ,*a_good_sym,table_entry::defed,table_entry::rule); if(report_card.status_==T_sym_tbl_report_card::failure){ std::cout<<"Error entry failed: "<id__<id__<c_str()); if(report_card.status_==T_sym_tbl_report_card::failure){ std::cout<<"Error Should have been found: "<id__<id__<id__<