/*
 File: cweb_or_c_k.cpp
 Date and Time: Fri Jan 30 18:55:08 2015 
*/
#include "cweb_or_c_k.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_cweb_or_c_k;// 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();
}
  Ccweb_or_c_k::
  Ccweb_or_c_k()
    :yacco2::CAbs_fsm
      ("cweb_or_c_k.lex"
      ,"1.0"
      ,"10 feb. 2008"
      ,false
      ,"C++ or cweb type comments lexer."
      ,"Fri Jan 30 18:55:08 2015 "
      ,S1_Ccweb_or_c_k){
    
    ddd_idx_ = 0;
    ddd_[ddd_idx_] = 0;
 
  }
 
Ccweb_or_c_k::~Ccweb_or_c_k(){

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

  bool Ccweb_or_c_k::failed(){
      return false;
  }
  void Ccweb_or_c_k::op(){
    ddd_idx_ = 0;
    ddd_[ddd_idx_] = 0;
  
}
int Ccweb_or_c_k::rhs_to_rules_mapping_[7] = {
 -1
 ,0 // subrule 1 for rule 1
 ,0 // subrule 2 for rule 1
 ,0 // subrule 3 for rule 1
 ,1 // subrule 4 for rule 2
 ,2 // subrule 5 for rule 3
 ,3 // subrule 6 for rule 4
}; 

    void Ccweb_or_c_k::copy_str_into_buffer(std::string* Str){   
      const char* y = Str->c_str(); 
      int x(0);
      for(;y[x]!=0;++x,++ddd_idx_)ddd_[ddd_idx_] = y[x];
      ddd_[ddd_idx_] = 0;
    }

    void Ccweb_or_c_k::copy_kstr_into_buffer(const char* Str){
      const char* y = Str; 
      int x(0);
      for(;y[x]!=0;++x,++ddd_idx_)ddd_[ddd_idx_] = y[x];
      ddd_[ddd_idx_] = 0;
    }
  
Rcweb_or_c_k::Rcweb_or_c_k(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rcweb_or_c_k",0,Ccweb_or_c_k::R_Rcweb_or_c_k_,P,false,false){
}

void Rcweb_or_c_k::sr1(){
  
      Ccweb_or_c_k* fsm = (Ccweb_or_c_k*) rule_info__.parser__->fsm_tbl__;
      T_comment* com = new T_comment((const char*)&fsm->ddd_);
      com->set_rc(*rule_info__.parser__->start_token__,__FILE__,__LINE__);
      RSVP(com);
  
  
}

void Rcweb_or_c_k::sr2(){
  
      Ccweb_or_c_k* fsm = (Ccweb_or_c_k*) rule_info__.parser__->fsm_tbl__;
      T_comment* com = new T_comment((const char*)&fsm->ddd_);
      com->set_rc(*rule_info__.parser__->start_token__,__FILE__,__LINE__);
      RSVP(com);
  
}

void Rcweb_or_c_k::sr3(){
  
      Ccweb_or_c_k* fsm = (Ccweb_or_c_k*) rule_info__.parser__->fsm_tbl__;
      T_cweb_comment* com = new T_cweb_comment((const char*)&fsm->ddd_);
      com->set_rc(*rule_info__.parser__->start_token__,__FILE__,__LINE__);// file marker
      RSVP(com);
  
  
}

Rslash_at::Rslash_at(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rslash_at",0,Ccweb_or_c_k::R_Rslash_at_,P,false,false){
}

void Rslash_at::sr1(){
  
      Ccweb_or_c_k* fsm = (Ccweb_or_c_k*) rule_info__.parser__->fsm_tbl__;
loop:
	  switch (rule_info__.parser__->current_token()->enumerated_id__){
	  case T_Enum::T_raw_lf_: goto other;
	  case T_Enum::T_raw_cr_: goto cr;
	  case T_Enum::T_LR1_eog_: goto overrun;	
	  case T_Enum::T_raw_at_sign_: goto atsign;
          default: goto other;
          }
    cr:{// cr lf?
        fsm->copy_kstr_into_buffer(rule_info__.parser__->current_token()->id__);
          rule_info__.parser__->get_next_token();
        if(rule_info__.parser__->current_token()->enumerated_id__ 
            != T_Enum::T_raw_lf_) goto loop;// not cr lf

        fsm->copy_kstr_into_buffer(rule_info__.parser__->current_token()->id__);
        rule_info__.parser__->get_next_token();
        goto loop;
    };
    atsign:{ // end of k?
          rule_info__.parser__->get_next_token();
        if(rule_info__.parser__->current_token()->enumerated_id__ 
            != T_Enum::T_raw_slash_){
        fsm->copy_kstr_into_buffer("@");
            goto loop;// false eok
        }
        rule_info__.parser__->get_next_token();
        return;
    }
    overrun:{
      CAbs_lr1_sym* sym = new Err_comment_overrun;
      sym->set_rc(*rule_info__.parser__->start_token__,__FILE__,__LINE__);
      RSVP(sym);
      rule_info__.parser__->set_stop_parse(true);
      return;
    }
    other:{
        fsm->copy_kstr_into_buffer(rule_info__.parser__->current_token()->id__);
          rule_info__.parser__->get_next_token();
goto loop;
      }
  
}

Rslash_asterisk::Rslash_asterisk(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rslash_asterisk",0,Ccweb_or_c_k::R_Rslash_asterisk_,P,false,false){
}

void Rslash_asterisk::sr1(){
  
      Ccweb_or_c_k* fsm = (Ccweb_or_c_k*) rule_info__.parser__->fsm_tbl__;
        fsm->copy_kstr_into_buffer("/");// due to lex scanner
        fsm->copy_kstr_into_buffer("*");

loop:
	  switch (rule_info__.parser__->current_token()->enumerated_id__){
	  case T_Enum::T_raw_lf_: goto other;
	  case T_Enum::T_raw_cr_: goto cr;
	  case T_Enum::T_LR1_eog_: goto overrun;	
	  case T_Enum::T_raw_asteric_: goto aster;
          default: goto other;
          }
    cr:{// cr lf?
        fsm->copy_kstr_into_buffer(rule_info__.parser__->current_token()->id__);
         rule_info__.parser__->get_next_token();
        if(rule_info__.parser__->current_token()->enumerated_id__ 
            != T_Enum::T_raw_lf_) goto loop;// not cr lf
        fsm->copy_kstr_into_buffer(rule_info__.parser__->current_token()->id__);
        rule_info__.parser__->get_next_token();
goto loop;
    };
    aster:{ // end of k?
        fsm->copy_kstr_into_buffer(rule_info__.parser__->current_token()->id__);
          rule_info__.parser__->get_next_token();
        if(rule_info__.parser__->current_token()->enumerated_id__ 
            != T_Enum::T_raw_slash_) goto loop;// false eok
        fsm->copy_kstr_into_buffer(rule_info__.parser__->current_token()->id__);
          rule_info__.parser__->get_next_token();
        return;
    }
    overrun:{
      CAbs_lr1_sym* sym = new Err_comment_overrun;
      sym->set_rc(*rule_info__.parser__->start_token__,__FILE__,__LINE__);
      RSVP(sym);
      rule_info__.parser__->set_stop_parse(true);
      return;
    }
    other:{
        fsm->copy_kstr_into_buffer(rule_info__.parser__->current_token()->id__);
          rule_info__.parser__->get_next_token();
goto loop;
      }
    
}

R2slash::R2slash(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("R2slash",0,Ccweb_or_c_k::R_R2slash_,P,false,false){
}

void R2slash::sr1(){
  
      Ccweb_or_c_k* fsm = (Ccweb_or_c_k*) rule_info__.parser__->fsm_tbl__;
        fsm->copy_kstr_into_buffer("/");
        fsm->copy_kstr_into_buffer("/");
      for(;;){
	  switch (rule_info__.parser__->current_token()->enumerated_id__){
	  case T_Enum::T_raw_lf_: {
            return;
          }
	  case T_Enum::T_raw_cr_:{
            return;
          }
	  case T_Enum::T_LR1_eog_: return;	
          }
        fsm->copy_kstr_into_buffer(rule_info__.parser__->current_token()->id__);
          rule_info__.parser__->get_next_token();
      }
    
}

