/*
 File: rtn_component.cpp
 Date and Time: Fri Jan 30 18:55:22 2015 
*/
#include "rtn_component.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_rtn_component;// grammar's ns
// first set terminals
fsm_rules_reuse_table_type::fsm_rules_reuse_table_type(){
 no_rules_entries_ = 1;
 per_rule_s_table_[0] =  new Per_rule_s_reuse_table();
}
  Crtn_component::
  Crtn_component()
    :yacco2::CAbs_fsm
      ("rtn_component.lex"
      ,"1.0"
      ,"16 dec. 2005"
      ,false
      ,"Recognizer of returned T from a thread call expression."
      ,"Fri Jan 30 18:55:22 2015 "
      ,S1_Crtn_component){
    
  }
 
Crtn_component::~Crtn_component(){

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

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

      void Crtn_component::fnd_T_of_chr_str(const char* Str,yacco2::CAbs_lr1_sym* Tok){
        T_sym_tbl_report_card report_card;
        using namespace yacco2_stbl;
        find_sym_in_stbl(report_card,*Str);
        if(report_card.action_ == T_sym_tbl_report_card::not_fnd){
          CAbs_lr1_sym* sym = new Err_subrule_use_undefined_T;
          sym->set_rc(*parser__->start_token__,__FILE__,__LINE__);
          RSVP_FSM(sym);
          parser__->set_stop_parse(true); 
          return; 
        }
        if(report_card.tbl_entry_->type_ != table_entry::terminal){
          CAbs_lr1_sym* sym = new Err_not_T_for_rtned_token_from_th;
          sym->set_rc(*parser__->start_token__,__FILE__,__LINE__);
          RSVP_FSM(sym);
          parser__->set_stop_parse(true); 
          return; 
        }
	report_card.tbl_entry_->used_ = true;
        CAbs_lr1_sym* sym = report_card.tbl_entry_->symbol_;
        T_in_stbl* T = (T_in_stbl*)sym;
        refered_T* rT = new refered_T(*T);
        rT->set_rc(*Tok,__FILE__,__LINE__);
        
        T->add_T_into_xref(*rT);

        RSVP_FSM(T);
        parser__->set_stop_parse(true);  
      }
  
yacco2::THR _YACCO2_CALL_TYPE
NS_rtn_component::AR_Rrtn_component(yacco2::Parser* Caller_pp){
 yacco2::KCHARP ar_name = "AR_Rrtn_component";
#include "war_begin_code.h"
 
	using namespace NS_yacco2_T_enum;
         for(i=1;i<=ie;++i){
	     if(Caller_pp->pp_accept_queue__[i].accept_token__->enumerated_id__ 
                != NS_yacco2_T_enum::T_Enum::T_T_unquoted_string_){// bypass unq str
	        goto arbitrated_parameter;
             }
         }
  
#include "war_end_code.h"
}

Rrtn_component::Rrtn_component(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rrtn_component",0,Crtn_component::R_Rrtn_component_,P,false,false){
}

void Rrtn_component::sr1(){
   // used rule and not defined, so create it
	CAbs_lr1_sym* sym = new Err_not_T_for_rtned_token_from_th;
	sym->set_rc(*rule_info__.parser__->start_token__,__FILE__,__LINE__);
	RSVP(sym);
	rule_info__.parser__->set_stop_parse(true); 
    
}

void Rrtn_component::sr2(){
  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);
  
      Crtn_component* fsm = (Crtn_component*)rule_info__.parser__->fsm_tbl__;
      fsm->fnd_T_of_chr_str(sf->p2__->c_string()->c_str(),sf->p2__);// stop parsing in call
      sf->p2__->set_auto_delete(true);
	rule_info__.parser__->set_stop_parse(true); 
    
}

void Rrtn_component::sr3(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   T_unquoted_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);
   // only accept when no identifier
      Crtn_component* fsm = (Crtn_component*)rule_info__.parser__->fsm_tbl__;
      fsm->fnd_T_of_chr_str(sf->p2__->unquoted_string()->c_str(),sf->p2__);// stop parsing in call
	  sf->p2__->set_auto_delete(true);
	rule_info__.parser__->set_stop_parse(true); 
     
}

void Rrtn_component::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);
  
      RSVP(sf->p2__);
      rule_info__.parser__->set_stop_parse(true);       
    
}

void Rrtn_component::sr5(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   T_in_stbl* 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);
   
	using namespace yacco2_stbl;
	T_sym_tbl_report_card report_card;
	find_sym_in_stbl(report_card,*sf->p2__->t_def()->t_name()->c_str());
	if(report_card.action_ == T_sym_tbl_report_card::not_fnd){
		CAbs_lr1_sym* sym = new Err_T_not_in_stbl;
		sym->set_rc(*rule_info__.parser__->start_token__,__FILE__,__LINE__);
		RSVP(sym);
		rule_info__.parser__->set_stop_parse(true); 
		return;        
	}
	report_card.tbl_entry_->used_ = true;
	refered_T* rt = new refered_T(*sf->p2__);
	rt->set_rc(*sf->p2__,__FILE__,__LINE__);

        sf->p2__->add_T_into_xref(*rt);
	RSVP(sf->p2__);
	rule_info__.parser__->set_stop_parse(true); 
      
}

void Rrtn_component::sr6(){
   
	CAbs_lr1_sym* sym = new Err_not_T_for_rtned_token_from_th;
	sym->set_rc(*rule_info__.parser__->start_token__,__FILE__,__LINE__);
	RSVP(sym);
	rule_info__.parser__->set_stop_parse(true); 
      
}

void Rrtn_component::sr7(){
   
	CAbs_lr1_sym* sym = new Err_not_T_for_rtned_token_from_th;
	sym->set_rc(*rule_info__.parser__->start_token__,__FILE__,__LINE__);
	RSVP(sym);
	rule_info__.parser__->set_stop_parse(true); 
	return;        
      
}

