/*
 File: prt_sr_elements.cpp
 Date and Time: Fri Jan 30 18:55:20 2015 
*/
#include "prt_sr_elements.h"
using namespace NS_yacco2_T_enum;// enumerate
using namespace NS_yacco2_err_symbols;// error symbols
using namespace NS_yacco2_k_symbols;// lrk 
using namespace NS_yacco2_terminals;// terminals
using namespace NS_yacco2_characters;// rc 
using namespace yacco2;// yacco2 library
using namespace NS_prt_sr_elements;// grammar's ns
// first set terminals
fsm_rules_reuse_table_type::fsm_rules_reuse_table_type(){
 no_rules_entries_ = 5;
 per_rule_s_table_[0] =  new Per_rule_s_reuse_table();
 per_rule_s_table_[1] =  new Per_rule_s_reuse_table();
 per_rule_s_table_[2] =  new Per_rule_s_reuse_table();
 per_rule_s_table_[3] =  new Per_rule_s_reuse_table();
 per_rule_s_table_[4] =  new Per_rule_s_reuse_table();
}
  Cprt_sr_elements::
  Cprt_sr_elements()
    :yacco2::CAbs_fsm
      ("prt_sr_elements.lex"
      ,"1.0"
      ,"Sep. 2007"
      ,false
      ,"Print the subrule's symbol string."
      ,"Fri Jan 30 18:55:20 2015 "
      ,S1_Cprt_sr_elements){
    
  }
 
Cprt_sr_elements::~Cprt_sr_elements(){

  for(int x = 0;x < 5;++x){
   ///delete fsm_rules_reuse_table.per_rule_s_table_[x];
  }
} 

  bool Cprt_sr_elements::failed(){
      return false;
  }
  void Cprt_sr_elements::op(){
elem_no_= 0;
  
}
int Cprt_sr_elements::rhs_to_rules_mapping_[12] = {
 -1
 ,0 // subrule 1 for rule 1
 ,1 // subrule 2 for rule 2
 ,2 // subrule 3 for rule 3
 ,3 // subrule 4 for rule 4
 ,3 // subrule 5 for rule 4
 ,4 // subrule 6 for rule 5
 ,4 // subrule 7 for rule 5
 ,4 // subrule 8 for rule 5
 ,4 // subrule 9 for rule 5
 ,4 // subrule 10 for rule 5
 ,4 // subrule 11 for rule 5
}; 
Rprt_sr_elements::Rprt_sr_elements(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rprt_sr_elements",0,Cprt_sr_elements::R_Rprt_sr_elements_,P,false,false){
}

Rsubrule::Rsubrule(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rsubrule",0,Cprt_sr_elements::R_Rsubrule_,P,false,false){
}

Rsubrule_def::Rsubrule_def(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rsubrule_def",0,Cprt_sr_elements::R_Rsubrule_def_,P,false,false){
}

void Rsubrule_def::sr1(){
  
    Cprt_sr_elements* fsm = (Cprt_sr_elements*)rule_info__.parser__->fsm_tbl__;
    fsm->elem_no_ = 0;
  
}

Relements::Relements(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Relements",0,Cprt_sr_elements::R_Relements_,P,false,false){
}

Relement::Relement(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Relement",0,Cprt_sr_elements::R_Relement_,P,false,false){
}

void Relement::sr1(){
  struct SF{
   refered_T* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   CAbs_lr1_sym* p2__;
   State* s2__;
   bool abort2__;
   Rule_s_reuse_entry* rule_s_reuse_entry2__;
  };
  SF* sf = (SF*)rule_info__.parser__->parse_stack__.sf_by_top(2);
  
    Cprt_sr_elements* fsm = (Cprt_sr_elements*)rule_info__.parser__->fsm_tbl__;
    ++fsm->elem_no_;
       char xlated_sym[Max_cweb_item_size];
       XLATE_SYMBOLS_FOR_cweave(sf->p1__->its_t_def()->t_name()->c_str(),xlated_sym);
       strcat(xlated_sym,"\\ \\ ");
       *fsm->ow_index_file_ << xlated_sym << endl;
  
}

void Relement::sr2(){
  struct SF{
   refered_rule* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
  };
  SF* sf = (SF*)rule_info__.parser__->parse_stack__.sf_by_top(1);
  
    Cprt_sr_elements* fsm = (Cprt_sr_elements*)rule_info__.parser__->fsm_tbl__;
    ++fsm->elem_no_;
       char xlated_sym[Max_cweb_item_size];
       XLATE_SYMBOLS_FOR_cweave(sf->p1__->its_rule_def()->rule_name()->c_str(),xlated_sym);
       strcat(xlated_sym,"\\ \\ ");
       *fsm->ow_index_file_ << xlated_sym << endl;
  
}

void Relement::sr3(){
  
    Cprt_sr_elements* fsm = (Cprt_sr_elements*)rule_info__.parser__->fsm_tbl__;
    ++fsm->elem_no_;
    if(fsm->elem_no_ == 1){// epsilon
	  KCHARP eps = "$\\epsilon$";
        *fsm->ow_index_file_ << eps << endl;
	}
  
}

void Relement::sr4(){
  struct SF{
   refered_T* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   refered_T* p2__;
   State* s2__;
   bool abort2__;
   Rule_s_reuse_entry* rule_s_reuse_entry2__;
   T_called_thread_eosubrule* p3__;
   State* s3__;
   bool abort3__;
   Rule_s_reuse_entry* rule_s_reuse_entry3__;
  };
  SF* sf = (SF*)rule_info__.parser__->parse_stack__.sf_by_top(3);
  
    Cprt_sr_elements* fsm = (Cprt_sr_elements*)rule_info__.parser__->fsm_tbl__;
    ++fsm->elem_no_;    
       char xlated_sym[Max_cweb_item_size];
       XLATE_SYMBOLS_FOR_cweave(sf->p1__->its_t_def()->t_name()->c_str(),xlated_sym);
       strcat(xlated_sym,"\\ \\ ");
       *fsm->ow_index_file_ << xlated_sym << endl;
    ++fsm->elem_no_;
       char rtned_xlated_sym[Max_cweb_item_size];
      XLATE_SYMBOLS_FOR_cweave(sf->p2__->its_t_def()->t_name()->c_str(),rtned_xlated_sym);
       strcat(rtned_xlated_sym,"\\ \\ ");
       *fsm->ow_index_file_ << rtned_xlated_sym << endl;

    ++fsm->elem_no_;
        char thd_xlated_sym[Max_cweb_item_size];
        char full_thd_name[Max_cweb_item_size];
        KCHARP full_thd_name_template = "%s::%s";
        sprintf(full_thd_name,full_thd_name_template
              ,sf->p3__->ns()->identifier()->c_str()
              ,sf->p3__->called_thread_name()->identifier()->c_str()
              );
       XLATE_SYMBOLS_FOR_cweave((const char*)full_thd_name,thd_xlated_sym);
       *fsm->ow_index_file_ << thd_xlated_sym << endl;
  
}

void Relement::sr5(){
  struct SF{
   refered_T* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   refered_T* p2__;
   State* s2__;
   bool abort2__;
   Rule_s_reuse_entry* rule_s_reuse_entry2__;
   T_null_call_thread_eosubrule* p3__;
   State* s3__;
   bool abort3__;
   Rule_s_reuse_entry* rule_s_reuse_entry3__;
  };
  SF* sf = (SF*)rule_info__.parser__->parse_stack__.sf_by_top(3);
  
    Cprt_sr_elements* fsm = (Cprt_sr_elements*)rule_info__.parser__->fsm_tbl__;
    ++fsm->elem_no_;    
       char xlated_sym[Max_cweb_item_size];
       XLATE_SYMBOLS_FOR_cweave(sf->p1__->its_t_def()->t_name()->c_str(),xlated_sym);
       strcat(xlated_sym,"\\ \\ ");
       *fsm->ow_index_file_ << xlated_sym << endl;
    ++fsm->elem_no_;
       char rtned_xlated_sym[Max_cweb_item_size];
       XLATE_SYMBOLS_FOR_cweave(sf->p2__->its_t_def()->t_name()->c_str(),rtned_xlated_sym);
       strcat(rtned_xlated_sym,"\\ \\ ");
       *fsm->ow_index_file_ << rtned_xlated_sym << endl;
    ++fsm->elem_no_;
       *fsm->ow_index_file_ << "NULL" << endl;
  
}

void Relement::sr6(){
  struct SF{
   refered_T* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   refered_T* p2__;
   State* s2__;
   bool abort2__;
   Rule_s_reuse_entry* rule_s_reuse_entry2__;
   CAbs_lr1_sym* p3__;
   State* s3__;
   bool abort3__;
   Rule_s_reuse_entry* rule_s_reuse_entry3__;
  };
  SF* sf = (SF*)rule_info__.parser__->parse_stack__.sf_by_top(3);
  
    Cprt_sr_elements* fsm = (Cprt_sr_elements*)rule_info__.parser__->fsm_tbl__;
    ++fsm->elem_no_;    
       char xlated_sym[Max_cweb_item_size];
       XLATE_SYMBOLS_FOR_cweave(sf->p1__->its_t_def()->t_name()->c_str(),xlated_sym);
       strcat(xlated_sym,"\\ \\ ");
       *fsm->ow_index_file_ << xlated_sym << endl;
    ++fsm->elem_no_;
       char xlated_2_sym[Max_cweb_item_size];
       XLATE_SYMBOLS_FOR_cweave(sf->p2__->its_t_def()->t_name()->c_str(),xlated_2_sym);
       strcat(xlated_2_sym,"\\ \\ ");
       *fsm->ow_index_file_ <<  xlated_2_sym << endl;
  
}

