/*
 File: parallel_monitor_ph.cpp
 Date and Time: Fri Jan 30 18:55:18 2015 
*/
#include "parallel_monitor_ph.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_parallel_monitor_ph;// grammar's ns
// first set terminals
fsm_rules_reuse_table_type::fsm_rules_reuse_table_type(){
 no_rules_entries_ = 8;
 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();
}
  Cparallel_monitor_ph::
  Cparallel_monitor_ph()
    :yacco2::CAbs_fsm
      ("parallel_monitor_ph.lex"
      ,"1.0"
      ,"24 mar 2004"
      ,false
      ,"Parse a rule's arbitration code: \n into the valley of someone's dementia..."
      ,"Fri Jan 30 18:55:18 2015 "
      ,S1_Cparallel_monitor_ph){
    
    parallel_monitor_phrase_ = 0;
  
  }
 
Cparallel_monitor_ph::~Cparallel_monitor_ph(){

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

  bool Cparallel_monitor_ph::failed(){
      return false;
  }
  void Cparallel_monitor_ph::op(){
    if(parallel_monitor_phrase_ != 0){
      delete parallel_monitor_phrase_;
      parallel_monitor_phrase_ = 0;
    }
    parallel_monitor_phrase_ = new T_parallel_monitor_phrase;
    parallel_monitor_phrase_->set_rc(*parser__->start_token__,__FILE__,__LINE__);
    AST* t = new AST(*parallel_monitor_phrase_);
    parallel_monitor_phrase_->phrase_tree(t);
  
}
int Cparallel_monitor_ph::rhs_to_rules_mapping_[18] = {
 -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
 ,3 // subrule 6 for rule 4
 ,4 // subrule 7 for rule 5
 ,4 // subrule 8 for rule 5
 ,4 // subrule 9 for rule 5
 ,5 // subrule 10 for rule 6
 ,5 // subrule 11 for rule 6
 ,5 // subrule 12 for rule 6
 ,6 // subrule 13 for rule 7
 ,6 // subrule 14 for rule 7
 ,7 // subrule 15 for rule 8
 ,7 // subrule 16 for rule 8
 ,7 // subrule 17 for rule 8
}; 

    void Cparallel_monitor_ph::
    add_sdc_to_directive(yacco2::CAbs_lr1_sym* Dir,T_syntax_code* Sdc){
      using namespace NS_yacco2_T_enum;
      using namespace NS_yacco2_terminals;
      yacco2::INT eid = Dir->enumerated_id__;
      switch (eid){
		case T_Enum::T_T_arbitrator_code_: {
		  T_arbitrator_code* k = (T_arbitrator_code*)Dir;
		  k->syntax_code(Sdc);
		  break;
		}      
		default: {
          CAbs_lr1_sym* sym = new Err_improper_directive;
          sym->set_rc(*Dir,__FILE__,__LINE__);
          RSVP_FSM(sym);
          parser__->set_stop_parse(true);
   		}      
      }    
    }
  
Rparallel_monitor_phrase::Rparallel_monitor_phrase(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rparallel_monitor_phrase",0,Cparallel_monitor_ph::R_Rparallel_monitor_phrase_,P,false,false){
}

void Rparallel_monitor_phrase::sr1(){
  
      Cparallel_monitor_ph* fsm = 
	(Cparallel_monitor_ph*)rule_info__.parser__->fsm_tbl__;
      RSVP(fsm->parallel_monitor_phrase_);
      fsm->parallel_monitor_phrase_ = 0;
    
}

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

void Ropen_brace::sr1(){
  struct SF{
   CAbs_lr1_sym* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
  };
  SF* sf = (SF*)rule_info__.parser__->parse_stack__.sf_by_top(1);
  
        CAbs_lr1_sym* sym = new Err_no_open_brace;
        sym->set_rc(*sf->p1__,__FILE__,__LINE__);
        RSVP(sym);
        rule_info__.parser__->set_stop_parse(true);
      
}

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

void Rclose_brace::sr1(){
  struct SF{
   CAbs_lr1_sym* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
  };
  SF* sf = (SF*)rule_info__.parser__->parse_stack__.sf_by_top(1);
  
        CAbs_lr1_sym* sym = new Err_no_close_brace;
        sym->set_rc(*sf->p1__,__FILE__,__LINE__);
       RSVP(sym);
        rule_info__.parser__->set_stop_parse(true);
      
}

Rdirective_phrase::Rdirective_phrase(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rdirective_phrase",0,Cparallel_monitor_ph::R_Rdirective_phrase_,P,false,false){
}

void Rdirective_phrase::sr1(){
  struct SF{
   Rlint* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   Rparallel_directive_cweb_k* p2__;
   State* s2__;
   bool abort2__;
   Rule_s_reuse_entry* rule_s_reuse_entry2__;
   Rlint* p3__;
   State* s3__;
   bool abort3__;
   Rule_s_reuse_entry* rule_s_reuse_entry3__;
   Rdirective* p4__;
   State* s4__;
   bool abort4__;
   Rule_s_reuse_entry* rule_s_reuse_entry4__;
   Rsyntax_code* p5__;
   State* s5__;
   bool abort5__;
   Rule_s_reuse_entry* rule_s_reuse_entry5__;
   Rlint* p6__;
   State* s6__;
   bool abort6__;
   Rule_s_reuse_entry* rule_s_reuse_entry6__;
  };
  SF* sf = (SF*)rule_info__.parser__->parse_stack__.sf_by_top(6);
  
      AST* cwebt = sf->p2__->cweb_t_;
      Rdirective* dir = sf->p4__;
      Rsyntax_code* sdc = sf->p5__;
      if(cwebt != 0)
        sdc->syntax_code_->add_cweb_marker(cwebt);
      Cparallel_monitor_ph* fsm = 
	(Cparallel_monitor_ph*)rule_info__.parser__->fsm_tbl__;
      fsm->add_sdc_to_directive(dir->directive_,sdc->syntax_code_);
    
}

Rdirective::Rdirective(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rdirective",0,Cparallel_monitor_ph::R_Rdirective_,P,false,false){
}

void Rdirective::op(){
  sstrace_rulesss
 
    if(directive_ == 0) return;
    Cparallel_monitor_ph* fsm = (Cparallel_monitor_ph*)rule_info__.parser__->fsm_tbl__;
    CAbs_lr1_sym* result = 
	fsm->parallel_monitor_phrase_->add_directive_to_mntr(directive_,rule_info__.parser__);
    if(result == 0) return;// ok added
    directive_->set_auto_delete(true);//dup: delete when popped from stack
    RSVP(result);
    rule_info__.parser__->set_stop_parse(true);
  
}
void Rdirective::sr1(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   T_arbitrator_code* 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);
  
      directive_ = sf->p2__;
    
}

void Rdirective::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);
  
     directive_ = 0;
     CAbs_lr1_sym* sym = new Err_not_arbitration_code_kw;
      sym->set_rc(*sf->p2__,__FILE__,__LINE__);
      RSVP(sym);
      rule_info__.parser__->set_stop_parse(true);
    
}

void Rdirective::sr3(){
  struct SF{
   CAbs_lr1_sym* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
  };
  SF* sf = (SF*)rule_info__.parser__->parse_stack__.sf_by_top(1);
  
      CAbs_lr1_sym* sym = new Err_no_directive_present;
      sym->set_rc(*sf->p1__,__FILE__,__LINE__);
      RSVP(sym);
      rule_info__.parser__->set_stop_parse(true);
    
}

Rsyntax_code::Rsyntax_code(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rsyntax_code",0,Cparallel_monitor_ph::R_Rsyntax_code_,P,false,false){
}

void Rsyntax_code::sr1(){
  struct SF{
   LR1_parallel_operator* p1__;
   State* s1__;
   bool abort1__;
   Rule_s_reuse_entry* rule_s_reuse_entry1__;
   T_syntax_code* 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);
  
        syntax_code_ = sf->p2__;
      
}

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

void Rsyntax_code::sr3(){
  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);
  
        syntax_code_ = 0;
        RSVP(sf->p2__);
        rule_info__.parser__->set_stop_parse(true);
      
}

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

Rparallel_directive_cweb_k::Rparallel_directive_cweb_k(yacco2::Parser* P)
 :CAbs_lr1_sym
  ("Rparallel_directive_cweb_k",0,Cparallel_monitor_ph::R_Rparallel_directive_cweb_k_,P,false,false){
}

void Rparallel_directive_cweb_k::ctor(){
 
	  cweb_t_ = 0;
	
}
void Rparallel_directive_cweb_k::sr2(){
  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);
  
        T_cweb_comment* k = sf->p2__;
        AST* cwebk_t_ = new AST(*k);
        cweb_t_ = new AST();
        T_cweb_marker* cw = new T_cweb_marker(cweb_t_);
        cw->set_rc(*k,__FILE__,__LINE__);
        AST::set_content(*cweb_t_,*cw);
        AST::join_pts(*cweb_t_,*cwebk_t_);
	
}

void Rparallel_directive_cweb_k::sr3(){
  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); 
      
}

