/*
 File: knu3sym.cpp
 Date and Time: Tue Nov  4 18:08:44 2008 
*/
#include "knu3.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_knu3;// grammar's ns
// first set terminals
// monolithic grammar --- no thread
void 
Cknu3::reduce_rhs_of_rule
    (yacco2::UINT Sub_rule_no,yacco2::Recycled_rule_struct* Recycled_rule){
   char a[BUFFER_SIZE];
   int bbb(0);
   int reducing_rule = rhs_to_rules_mapping_[Sub_rule_no];
   Per_rule_s_reuse_table* rule_entry_tbl_ptr = 
        fsm_rules_reuse_table.per_rule_s_table_[reducing_rule];
   int no_entries = rule_entry_tbl_ptr->no_rule_s_entries_;
   Rule_s_reuse_entry* re(0);
   for(;;){
     re = &rule_entry_tbl_ptr->rule_s_reuse_entry_[bbb];
     if(re->rule_on_stk_ == OFF){
       re->rule_on_stk_ = ON;
       Recycled_rule->rule_s_reuse_entry_ = re;
       break;
     }
     ++bbb;
     if(bbb >= no_entries){
      KCHARP msg = "Error ran out of rule recycled entries for %s --- major bug";
      sprintf(a,msg,re->rule_->id());
      Yacco2_faulty_precondition(a,__FILE__,__LINE__);
      exit(1);
     }
   }
   switch (Sub_rule_no){
    case rhs1_RS_:{
       RS* sym;
     if(re->rule_ == 0){
       sym = new RS(parser__);
       Recycled_rule->rule_ = sym;
     }else{
       sym = (RS*)re->rule_;
       //if ctor present on code sym->reset_ctor();
     }
     sym->rule_info__.rhs_no_of_parms__ = 2;
     return;}
    case rhs1_RB_:{
       RB* sym;
     if(re->rule_ == 0){
       sym = new RB(parser__);
       Recycled_rule->rule_ = sym;
     }else{
       sym = (RB*)re->rule_;
       //if ctor present on code sym->reset_ctor();
     }
     sym->rule_info__.rhs_no_of_parms__ = 1;
     return;}
    case rhs2_RB_:{
       RB* sym;
     if(re->rule_ == 0){
       sym = new RB(parser__);
       Recycled_rule->rule_ = sym;
     }else{
       sym = (RB*)re->rule_;
       //if ctor present on code sym->reset_ctor();
     }
     sym->rule_info__.rhs_no_of_parms__ = 2;
     return;}
    case rhs1_RL_:{
       RL* sym;
     if(re->rule_ == 0){
       sym = new RL(parser__);
       Recycled_rule->rule_ = sym;
     }else{
       sym = (RL*)re->rule_;
       //if ctor present on code sym->reset_ctor();
     }
     sym->rule_info__.rhs_no_of_parms__ = 1;
     return;}
    case rhs2_RL_:{
       RL* sym;
     if(re->rule_ == 0){
       sym = new RL(parser__);
       Recycled_rule->rule_ = sym;
     }else{
       sym = (RL*)re->rule_;
       //if ctor present on code sym->reset_ctor();
     }
     sym->rule_info__.rhs_no_of_parms__ = 3;
     return;}
    case rhs1_RR_:{
       RR* sym;
     if(re->rule_ == 0){
       sym = new RR(parser__);
       Recycled_rule->rule_ = sym;
     }else{
       sym = (RR*)re->rule_;
       //if ctor present on code sym->reset_ctor();
     }
     sym->rule_info__.rhs_no_of_parms__ = 1;
     return;}
    case rhs2_RR_:{
       RR* sym;
     if(re->rule_ == 0){
       sym = new RR(parser__);
       Recycled_rule->rule_ = sym;
     }else{
       sym = (RR*)re->rule_;
       //if ctor present on code sym->reset_ctor();
     }
     sym->rule_info__.rhs_no_of_parms__ = 3;
     return;}
    case rhs1_RN_:{
       RN* sym;
     if(re->rule_ == 0){
       sym = new RN(parser__);
       Recycled_rule->rule_ = sym;
     }else{
       sym = (RN*)re->rule_;
       //if ctor present on code sym->reset_ctor();
     }
     sym->rule_info__.rhs_no_of_parms__ = 1;
     return;}
    case rhs2_RN_:{
       RN* sym;
     if(re->rule_ == 0){
       sym = new RN(parser__);
       Recycled_rule->rule_ = sym;
     }else{
       sym = (RN*)re->rule_;
       //if ctor present on code sym->reset_ctor();
     }
     sym->rule_info__.rhs_no_of_parms__ = 4;
     return;}
    default: return;
   }
}
