/*
 File: prefile_include.cpp
 Date and Time: Fri Jan 30 18:55:20 2015 
*/
#include "prefile_include.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_prefile_include;// grammar's ns
// first set terminals
fsm_rules_reuse_table_type::fsm_rules_reuse_table_type(){
 no_rules_entries_ = 4;
 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();
}
  Cprefile_include::
  Cprefile_include()
    :yacco2::CAbs_fsm
      ("prefile_include.lex"
      ,"1.0"
      ,"17 Juin 2003"
      ,false
      ,"Preprocessor source file from the ``include file'' directive."
      ,"Fri Jan 30 18:55:20 2015 "
      ,S1_Cprefile_include){
    
    chrs_ = 0;
    error_raised_ = 0;
  
  }
 
Cprefile_include::~Cprefile_include(){

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

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

void Rprefile_include::op(){
  sstrace_rulesss
 
    Cprefile_include* fsm = (Cprefile_include*) rule_info__.parser__->fsm_tbl__;
    T_file_inclusion* typ = new T_file_inclusion(fsm->chrs_,fsm->error_raised_);
    typ->set_rc(*rule_info__.parser__->start_token__,__FILE__,__LINE__);
    RSVP(typ);
	fsm->chrs_=0;
  
}
Reof::Reof(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Reof",0,Cprefile_include::R_Reof_,P,false,false){
}

Rpossible_ws::Rpossible_ws(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rpossible_ws",0,Cprefile_include::R_Rpossible_ws_,P,false,false){
}

Rfile_string::Rfile_string(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rfile_string",0,Cprefile_include::R_Rfile_string_,P,false,false){
}

void Rfile_string::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);
  
	Cprefile_include* fsm = (Cprefile_include*) rule_info__.parser__->fsm_tbl__;
      fsm->chrs_ = sf->p2__;
      string* ps_fn = fsm->chrs_->c_string();
      std::ifstream fle_chk;
      fle_chk.open(ps_fn->c_str());
      if(!fle_chk.good()){
        fsm->error_raised_ = new Err_bad_filename(*ps_fn);
        fsm->error_raised_->set_rc(*rule_info__.parser__->start_token__,__FILE__,__LINE__);
      }else{
        fle_chk.close();
      }
    
}

void Rfile_string::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);
  
	  Cprefile_include* fsm = (Cprefile_include*) rule_info__.parser__->fsm_tbl__;
      fsm->error_raised_ = sf->p2__;
    
}

void Rfile_string::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);
  
	  Cprefile_include* fsm = 
	(Cprefile_include*) rule_info__.parser__->fsm_tbl__;
      fsm->error_raised_ = sf->p2__;
   
}

void Rfile_string::sr4(){
  
	  Cprefile_include* fsm = (Cprefile_include*) rule_info__.parser__->fsm_tbl__;
      fsm->error_raised_ = new Err_no_filename;
      fsm->error_raised_->set_rc(*rule_info__.parser__->current_token(),__FILE__,__LINE__);
    
}

void Rfile_string::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);
  
        Cprefile_include* fsm = 
	(Cprefile_include*) rule_info__.parser__->fsm_tbl__;
        fsm->error_raised_ = sf->p2__;
      
}

