/*
 File: linker_pass3.cpp
 Date and Time: Fri Jan 30 18:55:14 2015 
*/
#include "linker_pass3.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_linker_pass3;// grammar's ns
// first set terminals
fsm_rules_reuse_table_type::fsm_rules_reuse_table_type(){
 no_rules_entries_ = 10;
 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();
 per_rule_s_table_[5] =  new Per_rule_s_reuse_table();
 per_rule_s_table_[6] =  new Per_rule_s_reuse_table();
 per_rule_s_table_[7] =  new Per_rule_s_reuse_table();
 per_rule_s_table_[8] =  new Per_rule_s_reuse_table();
 per_rule_s_table_[9] =  new Per_rule_s_reuse_table();
}
  Clinker_pass3::
  Clinker_pass3()
    :yacco2::CAbs_fsm
      ("linker_pass3.lex"
      ,"1.0"
      ,"9 Feb. 2005"
      ,false
      ,"Lexer: constructing tokens for \\olinker parsing stage."
      ,"Fri Jan 30 18:55:14 2015 "
      ,S1_Clinker_pass3){
    
  }
 
Clinker_pass3::~Clinker_pass3(){

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

  bool Clinker_pass3::failed(){
      return false;
  }
  void Clinker_pass3::op(){
}
int Clinker_pass3::rhs_to_rules_mapping_[36] = {
 -1
 ,0 // subrule 1 for rule 1
 ,1 // subrule 2 for rule 2
 ,1 // subrule 3 for rule 2
 ,1 // subrule 4 for rule 2
 ,2 // subrule 5 for rule 3
 ,2 // subrule 6 for rule 3
 ,2 // subrule 7 for rule 3
 ,2 // subrule 8 for rule 3
 ,2 // subrule 9 for rule 3
 ,2 // subrule 10 for rule 3
 ,3 // subrule 11 for rule 4
 ,3 // subrule 12 for rule 4
 ,3 // subrule 13 for rule 4
 ,4 // subrule 14 for rule 5
 ,4 // subrule 15 for rule 5
 ,4 // subrule 16 for rule 5
 ,4 // subrule 17 for rule 5
 ,4 // subrule 18 for rule 5
 ,4 // subrule 19 for rule 5
 ,5 // subrule 20 for rule 6
 ,5 // subrule 21 for rule 6
 ,5 // subrule 22 for rule 6
 ,6 // subrule 23 for rule 7
 ,6 // subrule 24 for rule 7
 ,6 // subrule 25 for rule 7
 ,7 // subrule 26 for rule 8
 ,7 // subrule 27 for rule 8
 ,7 // subrule 28 for rule 8
 ,8 // subrule 29 for rule 9
 ,8 // subrule 30 for rule 9
 ,8 // subrule 31 for rule 9
 ,8 // subrule 32 for rule 9
 ,8 // subrule 33 for rule 9
 ,9 // subrule 34 for rule 10
 ,9 // subrule 35 for rule 10
}; 

    bool  Clinker_pass3::chk_ofilename(const char* Filename,CAbs_lr1_sym* Tok){
      std::ofstream fle_chk;
      fle_chk.open(Filename,ios::out);
      if(!fle_chk.good()){
         CAbs_lr1_sym* sym = new Err_bad_filename(Filename);
         sym->set_rc(*Tok,__FILE__,__LINE__);
         parser__->add_token_to_error_queue(*sym);
         parser__->set_stop_parse(true);
         return false;
      }else{
        fle_chk.close();
      }
      return true;
    }
    bool  Clinker_pass3::chk_filename(const char* Filename
	,CAbs_lr1_sym* Tok,CAbs_lr1_sym* Err){
      std::ifstream fle_chk;
      fle_chk.open(Filename);
      if(!fle_chk.good()){
         Err->set_rc(*Tok,__FILE__,__LINE__);
        parser__->add_token_to_error_queue(*Err);
        parser__->set_stop_parse(true);
         return false;
      }else{
        delete Err;
        fle_chk.close();
      }
      return true;
    }
    yacco2::CAbs_lr1_sym* Clinker_pass3::chk_for_overrun(){
	  switch (parser__->current_token()->enumerated_id__){
		case T_Enum::T_LR1_eog_: break;
		default: return 0;		
      }
      yacco2::CAbs_lr1_sym* sym = new Err_end_preamble_kw_not_present;
      sym->set_rc(*parser__->start_token__,__FILE__,__LINE__);
      parser__->set_use_all_shift_off();
      return sym;
    }
  
Rlinker_pass3::Rlinker_pass3(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rlinker_pass3",0,Clinker_pass3::R_Rlinker_pass3_,P,false,false){
}

void Rlinker_pass3::op(){
  sstrace_rulesss
 
    using namespace NS_yacco2_k_symbols;
       ADD_TOKEN_TO_PRODUCER_QUEUE(*yacco2::PTR_LR1_eog__);   
       ADD_TOKEN_TO_PRODUCER_QUEUE(*yacco2::PTR_LR1_eog__);  
  
}
RT_alphabet::RT_alphabet(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("RT_alphabet",0,Clinker_pass3::R_RT_alphabet_,P,false,false){
}

void RT_alphabet::sr2(){
  struct SF{
   LR1_parallel_operator* 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);
   
      CAbs_lr1_sym* sym = new Err_file_of_T_alphabet_kw_not_present;
      sym->set_rc(*sf->p2__,__FILE__,__LINE__);
      ADD_TOKEN_TO_ERROR_QUEUE(*sym);
      rule_info__.parser__->set_stop_parse(true);
      sf->p2__->set_auto_delete(true);
    
}

void RT_alphabet::sr3(){
  
      CAbs_lr1_sym* sym = new Err_file_of_T_alphabet_kw_not_present;
      sym->set_rc(*rule_info__.parser__->current_token(),__FILE__,__LINE__);
      ADD_TOKEN_TO_ERROR_QUEUE(*sym);
      rule_info__.parser__->set_stop_parse(true);
    
}

RT_alphabet_filename::RT_alphabet_filename(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("RT_alphabet_filename",0,Clinker_pass3::R_RT_alphabet_filename_,P,false,false){
}

void RT_alphabet_filename::sr1(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   T_c_string* 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);
  
      Clinker_pass3* fsm = (Clinker_pass3*) rule_info__.parser__->fsm_tbl__;
      const char* fn = sf->p2__->c_string()->c_str(); 
      if(fsm->chk_filename(fn,sf->p2__,
	new Err_T_alphabet_file_does_not_exist) == false) return;
      fsm->t_alphabet_filename_ += fn;
      sf->p2__->set_auto_delete(true);
    
}

void RT_alphabet_filename::sr2(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   Err_bad_eos* 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);
  
      ADD_TOKEN_TO_ERROR_QUEUE(*sf->p2__);
      rule_info__.parser__->set_stop_parse(true);
    
}

void RT_alphabet_filename::sr3(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   Err_bad_esc* 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);
  
      ADD_TOKEN_TO_ERROR_QUEUE(*sf->p2__);
      rule_info__.parser__->set_stop_parse(true);
   
}

void RT_alphabet_filename::sr4(){
  struct SF{
   LR1_parallel_operator* 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);
   
      CAbs_lr1_sym* sym = new Err_no_filename_present;
      sym->set_rc(*sf->p2__,__FILE__,__LINE__);
      ADD_TOKEN_TO_ERROR_QUEUE(*sym);
      rule_info__.parser__->set_stop_parse(true);
      sf->p2__->set_auto_delete(true);
    
}

void RT_alphabet_filename::sr5(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   T_angled_string* 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);
   
      Clinker_pass3* fsm = (Clinker_pass3*) rule_info__.parser__->fsm_tbl__;
      const char* fn = sf->p2__->angled_string()->c_str(); 
      if(fsm->chk_filename(fn,sf->p2__
	,new Err_T_alphabet_file_does_not_exist) == false) return;
      fsm->t_alphabet_filename_ += fn;
      sf->p2__->set_auto_delete(true);
    
}

void RT_alphabet_filename::sr6(){
  
      CAbs_lr1_sym* sym = new Err_T_alphabet_file_not_present;
      sym->set_rc(*rule_info__.parser__->current_token(),__FILE__,__LINE__);
      ADD_TOKEN_TO_ERROR_QUEUE(*sym);
      rule_info__.parser__->set_stop_parse(true);
    
}

Remitfile::Remitfile(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Remitfile",0,Clinker_pass3::R_Remitfile_,P,false,false){
}

void Remitfile::sr2(){
  struct SF{
   LR1_parallel_operator* 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);
   
      CAbs_lr1_sym* sym = new Err_emitfile_kw_not_present;
      sym->set_rc(*sf->p2__,__FILE__,__LINE__);
      ADD_TOKEN_TO_ERROR_QUEUE(*sym);
      rule_info__.parser__->set_stop_parse(true);
      sf->p2__->set_auto_delete(true);
    
}

void Remitfile::sr3(){
  
      CAbs_lr1_sym* sym = new Err_emitfile_kw_not_present;
      sym->set_rc(*rule_info__.parser__->current_token(),__FILE__,__LINE__);
      ADD_TOKEN_TO_ERROR_QUEUE(*sym);
      rule_info__.parser__->set_stop_parse(true);
    
}

Remitfile_filename::Remitfile_filename(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Remitfile_filename",0,Clinker_pass3::R_Remitfile_filename_,P,false,false){
}

void Remitfile_filename::sr1(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   T_c_string* 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);
  
      Clinker_pass3* fsm = (Clinker_pass3*) rule_info__.parser__->fsm_tbl__;
      const char* fn = sf->p2__->c_string()->c_str(); 
      if(fsm->chk_ofilename(fn,sf->p2__) == false) return;
      fsm->emitfile_filename_ += fn;
      sf->p2__->set_auto_delete(true);
    
}

void Remitfile_filename::sr2(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   Err_bad_eos* 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);
  
      ADD_TOKEN_TO_ERROR_QUEUE(*sf->p2__);
      rule_info__.parser__->set_stop_parse(true);
    
}

void Remitfile_filename::sr3(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   Err_bad_esc* 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);
  
      ADD_TOKEN_TO_ERROR_QUEUE(*sf->p2__);
      rule_info__.parser__->set_stop_parse(true);
   
}

void Remitfile_filename::sr4(){
  struct SF{
   LR1_parallel_operator* 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);
   
      CAbs_lr1_sym* sym = new Err_emitfile_file_not_present;
      sym->set_rc(*sf->p2__,__FILE__,__LINE__);
      ADD_TOKEN_TO_ERROR_QUEUE(*sym);
      rule_info__.parser__->set_stop_parse(true);
      sf->p2__->set_auto_delete(true);
    
}

void Remitfile_filename::sr5(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   T_angled_string* 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);
   
      Clinker_pass3* fsm = (Clinker_pass3*) rule_info__.parser__->fsm_tbl__;
      const char* fn = sf->p2__->angled_string()->c_str(); 
      if(fsm->chk_ofilename(fn,sf->p2__) == false) return;
      fsm->emitfile_filename_ += fn;
      sf->p2__->set_auto_delete(true);
    
}

void Remitfile_filename::sr6(){
  
      CAbs_lr1_sym* sym = new Err_emitfile_file_not_present;
      sym->set_rc(*rule_info__.parser__->current_token(),__FILE__,__LINE__);
      ADD_TOKEN_TO_ERROR_QUEUE(*sym);
      rule_info__.parser__->set_stop_parse(true);
    
}

Rpreamble::Rpreamble(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rpreamble",0,Clinker_pass3::R_Rpreamble_,P,false,false){
}

void Rpreamble::sr2(){
  struct SF{
   LR1_parallel_operator* 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);
   
      CAbs_lr1_sym* sym = new Err_preamble_kw_not_present;
      sym->set_rc(*sf->p2__,__FILE__,__LINE__);
      ADD_TOKEN_TO_ERROR_QUEUE(*sym);
      rule_info__.parser__->set_stop_parse(true);
      sf->p2__->set_auto_delete(true);
    
}

void Rpreamble::sr3(){
  
      CAbs_lr1_sym* sym = new Err_preamble_kw_not_present;
      sym->set_rc(*rule_info__.parser__->current_token(),__FILE__,__LINE__);
      ADD_TOKEN_TO_ERROR_QUEUE(*sym);
      rule_info__.parser__->set_stop_parse(true);
    
}

Rpreamble_code::Rpreamble_code(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rpreamble_code",0,Clinker_pass3::R_Rpreamble_code_,P,false,false){
}

void Rpreamble_code::sr1(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   T_syntax_code* 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);
   
      Clinker_pass3* fsm = (Clinker_pass3*) rule_info__.parser__->fsm_tbl__;
      fsm->preamble_srce_ = sf->p2__;
    
}

void Rpreamble_code::sr2(){
  struct SF{
   LR1_parallel_operator* 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);
   
      ADD_TOKEN_TO_ERROR_QUEUE(*sf->p2__);
      rule_info__.parser__->set_stop_parse(true);
    
}

void Rpreamble_code::sr3(){
  
      CAbs_lr1_sym* sym = new Err_preamble_srce_code_not_present;
      sym->set_rc(*rule_info__.parser__->current_token(),__FILE__,__LINE__);
      ADD_TOKEN_TO_ERROR_QUEUE(*sym);
      rule_info__.parser__->set_stop_parse(true);
    
}

R_fsc_files::R_fsc_files(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("R_fsc_files",0,Clinker_pass3::R_R_fsc_files_,P,false,false){
}

void R_fsc_files::sr3(){
  
      CAbs_lr1_sym* sym = new Err_fsc_cntl_file_not_present;
      sym->set_rc(*rule_info__.parser__->current_token(),__FILE__,__LINE__);
      ADD_TOKEN_TO_ERROR_QUEUE(*sym);
      rule_info__.parser__->set_stop_parse(true);
    
}

R_fsc_file::R_fsc_file(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("R_fsc_file",0,Clinker_pass3::R_R_fsc_file_,P,false,false){
}

void R_fsc_file::sr1(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   T_c_string* 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);
  
	  Clinker_pass3* fsm = (Clinker_pass3*) rule_info__.parser__->fsm_tbl__;
      const char* fn = sf->p2__->c_string()->c_str(); 
      if(fsm->chk_filename(fn,sf->p2__
	,new Err_fsc_file_does_not_exist) == false) return;
      fsm->grammars_fsc_files_.push_back(string(fn));
      sf->p2__->set_auto_delete(true);
    
}

void R_fsc_file::sr2(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   Err_bad_eos* 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);
  
      ADD_TOKEN_TO_ERROR_QUEUE(*sf->p2__);
      rule_info__.parser__->set_stop_parse(true);
    
}

void R_fsc_file::sr3(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   Err_bad_esc* 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);
  
      ADD_TOKEN_TO_ERROR_QUEUE(*sf->p2__);
      rule_info__.parser__->set_stop_parse(true);
   
}

void R_fsc_file::sr4(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   T_angled_string* 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);
   
      Clinker_pass3* fsm = (Clinker_pass3*) rule_info__.parser__->fsm_tbl__;
      const char* fn = sf->p2__->angled_string()->c_str(); 
      if(fsm->chk_filename(fn,sf->p2__
	,new Err_fsc_file_does_not_exist) == false) return;
      fsm->grammars_fsc_files_.push_back(string(fn));
      sf->p2__->set_auto_delete(true);
    
}

void R_fsc_file::sr5(){
  struct SF{
   LR1_parallel_operator* 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);
  
        ADD_TOKEN_TO_ERROR_QUEUE(*sf->p2__);
        rule_info__.parser__->set_stop_parse(true);
      
}

Rlint::Rlint(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rlint",0,Clinker_pass3::R_Rlint_,P,false,false){
}

