/*
 File: rules_use_cnt.h
 Date and Time: Fri Jan 30 18:55:23 2015 
*/
#ifndef __rules_use_cnt_h__
#define __rules_use_cnt_h__ 1
#include "yacco2.h"
#include "yacco2_T_enumeration.h"
#include "yacco2_k_symbols.h"
#include "yacco2_err_symbols.h"
#include "yacco2_terminals.h"
#include "yacco2_characters.h"

#include "o2_externs.h"
extern int MAX_USE_CNT_RxR
	(NS_yacco2_terminals::rule_def* Rule_use
	,NS_yacco2_terminals::rule_def* Against_rule);
  
// monolithic grammar: no thread
extern yacco2::State S1_Crules_use_cnt;
namespace NS_rules_use_cnt {
using namespace NS_yacco2_T_enum;// enumerate
using namespace yacco2;
struct fsm_rules_reuse_table_type{
 fsm_rules_reuse_table_type();
 int no_rules_entries_;
 Per_rule_s_reuse_table* per_rule_s_table_[9];
};
class Crules_use_cnt: public yacco2::CAbs_fsm {
 public:
  enum rules_and_subrules{
   start_of_rule_list = NS_yacco2_T_enum::T_Enum::sum_total_T
   ,R_Rrules_use_cnt_ = 569//start_of_rule_list + 0
    ,rhs1_Rrules_use_cnt_ = 1
   ,R_Rrules_ = 570//start_of_rule_list + 2
    ,rhs1_Rrules_ = 2
    ,rhs2_Rrules_ = 3
   ,R_Rrule_ = 571//start_of_rule_list + 4
    ,rhs1_Rrule_ = 4
   ,R_Rrule_def_ = 572//start_of_rule_list + 6
    ,rhs1_Rrule_def_ = 5
   ,R_Rsubrules_ = 573//start_of_rule_list + 8
    ,rhs1_Rsubrules_ = 6
    ,rhs2_Rsubrules_ = 7
   ,R_Rsubrule_ = 574//start_of_rule_list + 10
    ,rhs1_Rsubrule_ = 8
   ,R_Rsubrule_def_ = 575//start_of_rule_list + 12
    ,rhs1_Rsubrule_def_ = 9
   ,R_Rsubrule_s_used_rules_epi_ = 576//start_of_rule_list + 14
    ,rhs1_Rsubrule_s_used_rules_epi_ = 10
    ,rhs2_Rsubrule_s_used_rules_epi_ = 11
   ,R_Rsubrule_s_used_rules_ = 577//start_of_rule_list + 16
    ,rhs1_Rsubrule_s_used_rules_ = 12
    ,rhs2_Rsubrule_s_used_rules_ = 13
  };
  //no of la sets = 5
  //no of states = 17
  Crules_use_cnt();
  ~Crules_use_cnt();
  void op();
  bool failed();
  void reduce_rhs_of_rule
      (yacco2::UINT Sub_rule_no,yacco2::Rule_s_reuse_entry** Recycled_rule);
  fsm_rules_reuse_table_type fsm_rules_reuse_table;
  static int rhs_to_rules_mapping_[14];
  
    public:
	std::list<NS_yacco2_terminals::rule_def* > rules_list_for_use_cnt_;
	NS_yacco2_terminals::rule_def* rule_def_;
	NS_yacco2_terminals::T_subrule_def* subrule_def_;
	void mark_recursion_rule_use(NS_yacco2_terminals::refered_rule* Refered_rule);
        yacco2::AST* bld_rule_s_use_skeleton(yacco2::AST* Rule_t);
  
 };
struct Rrules_use_cnt;
struct Rrules;
struct Rrule;
struct Rrule_def;
struct Rsubrules;
struct Rsubrule;
struct Rsubrule_def;
struct Rsubrule_s_used_rules_epi;
struct Rsubrule_s_used_rules;
struct Rrules_use_cnt:public yacco2::CAbs_lr1_sym {
  Rrules_use_cnt(yacco2::Parser* P);
  public:
};

struct Rrules:public yacco2::CAbs_lr1_sym {
  Rrules(yacco2::Parser* P);
  public:
};

struct Rrule:public yacco2::CAbs_lr1_sym {
  Rrule(yacco2::Parser* P);
  public:
};

struct Rrule_def:public yacco2::CAbs_lr1_sym {
  Rrule_def(yacco2::Parser* P);
  public:
  void sr1();
};

struct Rsubrules:public yacco2::CAbs_lr1_sym {
  Rsubrules(yacco2::Parser* P);
  public:
};

struct Rsubrule:public yacco2::CAbs_lr1_sym {
  Rsubrule(yacco2::Parser* P);
  public:
};

struct Rsubrule_def:public yacco2::CAbs_lr1_sym {
  Rsubrule_def(yacco2::Parser* P);
  public:
  void sr1();
};

struct Rsubrule_s_used_rules_epi:public yacco2::CAbs_lr1_sym {
  Rsubrule_s_used_rules_epi(yacco2::Parser* P);
  public:
};

struct Rsubrule_s_used_rules:public yacco2::CAbs_lr1_sym {
  Rsubrule_s_used_rules(yacco2::Parser* P);
  public:
  void sr1();
  void sr2();
};

} // end of namespace

#endif
