/*
 File: subrules_phrase.cpp
 Date and Time: Fri Jan 30 18:55:25 2015 
*/
#include "subrules_phrase.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_subrules_phrase;// grammar's ns
// first set terminals
fsm_rules_reuse_table_type::fsm_rules_reuse_table_type(){
 no_rules_entries_ = 5;
 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();
}
  Csubrules_phrase::
  Csubrules_phrase()
    :yacco2::CAbs_fsm
      ("subrules_phrase.lex"
      ,"1.0"
      ,"24 mar 2004"
      ,false
      ,"Parse subrules: into the valley of ..."
      ,"Fri Jan 30 18:55:25 2015 "
      ,S1_Csubrules_phrase){
    
      subrules_phrase_ = 0;
  
  }
 
Csubrules_phrase::~Csubrules_phrase(){

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

  bool Csubrules_phrase::failed(){
      return false;
  }
  void Csubrules_phrase::op(){
    if(subrules_phrase_ != 0){
      delete subrules_phrase_;
      subrules_phrase_ = 0;
    }
    subrules_phrase_ = new T_subrules_phrase;
    subrules_phrase_->set_rc(*parser__->start_token__,__FILE__,__LINE__);
    AST* t = new AST(*subrules_phrase_);
    subrules_phrase_->phrase_tree(t);
    subrule_no_=0;
  
}
int Csubrules_phrase::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
 ,2 // subrule 6 for rule 3
 ,3 // subrule 7 for rule 4
 ,3 // subrule 8 for rule 4
 ,4 // subrule 9 for rule 5
 ,4 // subrule 10 for rule 5
}; 
Rsubrules_phrase::Rsubrules_phrase(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rsubrules_phrase",0,Csubrules_phrase::R_Rsubrules_phrase_,P,false,false){
}

void Rsubrules_phrase::sr1(){
  
      Csubrules_phrase* fsm = (Csubrules_phrase*)rule_info__.parser__->fsm_tbl__;
      RSVP(fsm->subrules_phrase_);
      fsm->subrules_phrase_ = 0;
    
}

Rsubrule_defs::Rsubrule_defs(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rsubrule_defs",0,Csubrules_phrase::R_Rsubrule_defs_,P,false,false){
}

Rsubrule_def::Rsubrule_def(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rsubrule_def",0,Csubrules_phrase::R_Rsubrule_def_,P,false,false){
}

void Rsubrule_def::sr1(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   T_subrule_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);
   
        Csubrules_phrase* fsm = (Csubrules_phrase*)rule_info__.parser__->fsm_tbl__;
        ++fsm->subrule_no_;
        sf->p2__->subrule_no_of_rule(fsm->subrule_no_);
        fsm->subrules_phrase_->add_sr_to_subrules(sf->p2__);
      
}

void Rsubrule_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 Rsubrule_def::sr3(){
  
        CAbs_lr1_sym* sym = new Err_no_sub_rule_present;
        sym->set_rc(*rule_info__.parser__->current_token(),__FILE__,__LINE__);
        RSVP(sym);
        rule_info__.parser__->set_stop_parse(true);
      
}

Rsubrule_def1::Rsubrule_def1(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rsubrule_def1",0,Csubrules_phrase::R_Rsubrule_def1_,P,false,false){
}

void Rsubrule_def1::sr1(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   T_subrule_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);
   
        Csubrules_phrase* fsm = (Csubrules_phrase*)rule_info__.parser__->fsm_tbl__;
        ++fsm->subrule_no_;
        sf->p2__->subrule_no_of_rule(fsm->subrule_no_);
        fsm->subrules_phrase_->add_sr_to_subrules(sf->p2__);
      
}

void Rsubrule_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);
      
}

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

