/*
 File: rules_phrase_th.cpp
 Date and Time: Fri Jan 30 18:55:23 2015 
*/
#include "rules_phrase_th.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_rules_phrase_th;// grammar's ns
// first set terminals
fsm_rules_reuse_table_type::fsm_rules_reuse_table_type(){
 no_rules_entries_ = 11;
 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();
 per_rule_s_table_[10] =  new Per_rule_s_reuse_table();
}
  Crules_phrase_th::
  Crules_phrase_th()
    :yacco2::CAbs_fsm
      ("rules_phrase_th.lex"
      ,"1.0"
      ,"22 mar 2004"
      ,false
      ,"Parse all of the grammar's rules."
      ,"Fri Jan 30 18:55:23 2015 "
      ,S1_Crules_phrase_th){
    
    rules_phrase_ = 0;
    end_rules_t_ = 0;
 
  }
 
Crules_phrase_th::~Crules_phrase_th(){

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

  bool Crules_phrase_th::failed(){
      return false;
  }
  void Crules_phrase_th::op(){
    if(rules_phrase_ != 0){
      delete rules_phrase_;
      rules_phrase_ = 0;
      end_rules_t_ = 0;
    }
    rules_phrase_ = new T_rules_phrase;
    rules_phrase_->set_rc(*parser__->start_token__,__FILE__,__LINE__);
    AST* t = new AST(*rules_phrase_);
    rules_phrase_->phrase_tree(t);
  
}
int Crules_phrase_th::rhs_to_rules_mapping_[26] = {
 -1
 ,0 // subrule 1 for rule 1
 ,1 // subrule 2 for rule 2
 ,2 // subrule 3 for rule 3
 ,2 // subrule 4 for rule 3
 ,3 // subrule 5 for rule 4
 ,3 // subrule 6 for rule 4
 ,3 // subrule 7 for rule 4
 ,4 // subrule 8 for rule 5
 ,4 // subrule 9 for rule 5
 ,5 // subrule 10 for rule 6
 ,5 // subrule 11 for rule 6
 ,6 // subrule 12 for rule 7
 ,6 // subrule 13 for rule 7
 ,7 // subrule 14 for rule 8
 ,7 // subrule 15 for rule 8
 ,7 // subrule 16 for rule 8
 ,8 // subrule 17 for rule 9
 ,8 // subrule 18 for rule 9
 ,9 // subrule 19 for rule 10
 ,9 // subrule 20 for rule 10
 ,10 // subrule 21 for rule 11
 ,10 // subrule 22 for rule 11
 ,10 // subrule 23 for rule 11
 ,10 // subrule 24 for rule 11
 ,10 // subrule 25 for rule 11
}; 
Rrules_phrase::Rrules_phrase(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rrules_phrase",0,Crules_phrase_th::R_Rrules_phrase_,P,false,false){
}

void Rrules_phrase::sr1(){
  
      Crules_phrase_th* fsm = (Crules_phrase_th*)rule_info__.parser__->fsm_tbl__;
      RSVP(fsm->rules_phrase_);
      fsm->rules_phrase_ = 0;
    
}

Rrule_defs_phrase::Rrule_defs_phrase(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rrule_defs_phrase",0,Crules_phrase_th::R_Rrule_defs_phrase_,P,false,false){
}

Rrule_defs::Rrule_defs(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rrule_defs",0,Crules_phrase_th::R_Rrule_defs_,P,false,false){
}

Rrule_def::Rrule_def(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rrule_def",0,Crules_phrase_th::R_Rrule_def_,P,false,false){
}

void Rrule_def::sr1(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   rule_def* 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);
  
      Crules_phrase_th* fsm = (Crules_phrase_th*)rule_info__.parser__->fsm_tbl__;
      CAbs_lr1_sym* r = 
	fsm->rules_phrase_->add_r_to_alphabet(sf->p2__,rule_info__.parser__);
      if(r != 0){
        RSVP(r);
        rule_info__.parser__->set_stop_parse(true);
        return;
      }
      AST* rt = sf->p2__->rule_s_tree();
      // ms has a bug so use temporary  
	  AST* t = fsm->rules_phrase_->phrase_tree();
      if(fsm->end_rules_t_ == 0){
         AST::join_pts(*t,*rt);
	  }else{
         AST::join_sts(*fsm->end_rules_t_,*rt);
	  }
      fsm->end_rules_t_ = rt;
    
}

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

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

Rrule_def1::Rrule_def1(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rrule_def1",0,Crules_phrase_th::R_Rrule_def1_,P,false,false){
}

void Rrule_def1::sr1(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   rule_def* 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);
  
      Crules_phrase_th* fsm = (Crules_phrase_th*)rule_info__.parser__->fsm_tbl__;
      CAbs_lr1_sym* r = fsm->rules_phrase_->add_r_to_alphabet(sf->p2__,rule_info__.parser__);
      if(r != 0){
        RSVP(r);
        rule_info__.parser__->set_stop_parse(true);
        return;
      }
      AST* rt = sf->p2__->rule_s_tree();
      AST::join_sts(*fsm->end_rules_t_,*rt);
      fsm->end_rules_t_ = rt;
    
}

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

Ropen_brace::Ropen_brace(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Ropen_brace",0,Crules_phrase_th::R_Ropen_brace_,P,false,false){
}

void Ropen_brace::sr1(){
  
        CAbs_lr1_sym* sym = new Err_no_open_brace;
        sym->set_rc(*rule_info__.parser__->current_token(),__FILE__,__LINE__);
        RSVP(sym);
        rule_info__.parser__->set_stop_parse(true);
      
}

Rclose_brace::Rclose_brace(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rclose_brace",0,Crules_phrase_th::R_Rclose_brace_,P,false,false){
}

void Rclose_brace::sr1(){
  
        CAbs_lr1_sym* sym = new Err_no_close_brace_ending_rules_defs;
        sym->set_rc(*rule_info__.parser__->current_token(),__FILE__,__LINE__);
        RSVP(sym);
        rule_info__.parser__->set_stop_parse(true);
      
}

Rlint_or_cweb_or_error::Rlint_or_cweb_or_error(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rlint_or_cweb_or_error",0,Crules_phrase_th::R_Rlint_or_cweb_or_error_,P,false,false){
}

void Rlint_or_cweb_or_error::sr2(){
  
        CAbs_lr1_sym* sym = new Err_improper_closing_of_rules;
        sym->set_rc(*rule_info__.parser__->current_token(),__FILE__,__LINE__);
        RSVP(sym);
        rule_info__.parser__->set_stop_parse(true);
      
}

Rlint_or_cweb::Rlint_or_cweb(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rlint_or_cweb",0,Crules_phrase_th::R_Rlint_or_cweb_,P,false,false){
}

Rfluffs_or_cweb::Rfluffs_or_cweb(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rfluffs_or_cweb",0,Crules_phrase_th::R_Rfluffs_or_cweb_,P,false,false){
}

Rfluff_or_cweb::Rfluff_or_cweb(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rfluff_or_cweb",0,Crules_phrase_th::R_Rfluff_or_cweb_,P,false,false){
}

void Rfluff_or_cweb::sr2(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   T_comment* 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);
  
        sf->p2__->set_auto_delete(true);
      
}

void Rfluff_or_cweb::sr3(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   T_cweb_comment* 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);
  
       Crules_phrase_th* fsm = (Crules_phrase_th*)rule_info__.parser__->fsm_tbl__;
	   AST* t = fsm->rules_phrase_->phrase_tree();
        T_cweb_comment* k = sf->p2__;
        AST* cwebk_t_ = new AST(*k);
        AST* rt = new AST();
        T_cweb_marker* cw = new T_cweb_marker(rt);
        cw->set_rc(*k,__FILE__,__LINE__);
      AST::set_content(*rt,*cw);
        AST::join_pts(*rt,*cwebk_t_);

       if(fsm->end_rules_t_ == 0){
         AST::join_pts(*t,*rt);
	   }else{
         AST::join_sts(*fsm->end_rules_t_,*rt);
	   }
       fsm->end_rules_t_ = rt;
      
}

void Rfluff_or_cweb::sr4(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   Err_comment_overrun* 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);
      
}