/*141:*/
//line 2215 "/usr/local/yacco2/compiler/o2/o2_defs.w"

#include "o2.h"
/*44:*/
//line 242 "/usr/local/yacco2/compiler/o2/o2_defs.w"

gen_context::gen_context(state*S,Voc_ENO Ve):for_closure_state_(S),gen_vector_(Ve){}

/*:44*//*46:*/
//line 259 "/usr/local/yacco2/compiler/o2/o2_defs.w"

state_element::state_element(AST*Elem)
:cs_vector_combo_gening_it_(0,-1)
,sr_element_(Elem)
,sr_def_element_(0)
,its_enum_id_(-1)
,subrule_def_(0)
,closure_state_(0)
,goto_state_(0)
,previous_state_(0)
,reduced_state_(0)
,self_state_(0)
,previous_state_element_(0)
,next_state_element_(0)
,la_set_(0)
,common_la_set_idx_(-1)
{
/*47:*/
//line 280 "/usr/local/yacco2/compiler/o2/o2_defs.w"

CAbs_lr1_sym*sym= AST::content(*Elem);
Voc_ENO id= sym->enumerated_id__;
switch(id){
case T_Enum::T_refered_rule_:{
/*108:*/
//line 1885 "/usr/local/yacco2/compiler/o2/o2_defs.w"

refered_rule* rr = (refered_rule*)sym;

/*:108*/
//line 285 "/usr/local/yacco2/compiler/o2/o2_defs.w"

rule_def*rd= rr->its_rule_def();
sr_def_element_= rd;
its_enum_id_= rd->enum_id();
break;
}
case T_Enum::T_T_eosubrule_:{
/*110:*/
//line 1893 "/usr/local/yacco2/compiler/o2/o2_defs.w"

T_eosubrule* eos = (T_eosubrule*)sym;
/*:110*/
//line 292 "/usr/local/yacco2/compiler/o2/o2_defs.w"

sr_def_element_= eos;
its_enum_id_= eos->enumerated_id__;
la_set_= new LA_SET_type();
break;
}
case T_Enum::T_T_null_call_thread_eosubrule_:{
/*111:*/
//line 1896 "/usr/local/yacco2/compiler/o2/o2_defs.w"

T_null_call_thread_eosubrule* eos = (T_null_call_thread_eosubrule*)sym;
/*:111*/
//line 299 "/usr/local/yacco2/compiler/o2/o2_defs.w"

sr_def_element_= eos;
its_enum_id_= eos->enumerated_id__;
break;
}
case T_Enum::T_T_called_thread_eosubrule_:{
/*112:*/
//line 1899 "/usr/local/yacco2/compiler/o2/o2_defs.w"

T_called_thread_eosubrule* eos = (T_called_thread_eosubrule*)sym;

/*:112*/
//line 305 "/usr/local/yacco2/compiler/o2/o2_defs.w"

sr_def_element_= eos;
its_enum_id_= eos->enumerated_id__;
break;
}
case T_Enum::T_refered_T_:{
/*109:*/
//line 1889 "/usr/local/yacco2/compiler/o2/o2_defs.w"

refered_T* rt = (refered_T*)sym;

/*:109*/
//line 311 "/usr/local/yacco2/compiler/o2/o2_defs.w"

T_terminal_def*td= rt->its_t_def();
sr_def_element_= td;
its_enum_id_= td->enum_id();
break;
}
}

/*:47*/
//line 276 "/usr/local/yacco2/compiler/o2/o2_defs.w"

}
/*:46*//*48:*/
//line 320 "/usr/local/yacco2/compiler/o2/o2_defs.w"

state_element::~state_element(){
if(la_set_!=0)delete la_set_;
}

/*:48*//*50:*/
//line 334 "/usr/local/yacco2/compiler/o2/o2_defs.w"

void state_element::add_fs_setA_to_LA(follow_element&Fe,LA_SET_type&La_to_fill_in){
FOLLOW_SETS_ITER_type i= Fe.follow_set_.begin();
FOLLOW_SETS_ITER_type ie= Fe.follow_set_.end();
for(;i!=ie;++i){
LA_SET_ITER_type j= La_to_fill_in.find(*i);
if(j==La_to_fill_in.end()){
T_in_stbl*t_sym= *i;
/*51:*/
//line 351 "/usr/local/yacco2/compiler/o2/o2_defs.w"

if(t_sym->t_def()->enum_id()!=LR1_PARALLEL_OPERATOR){
La_to_fill_in.insert(t_sym);
}else{
using namespace yacco2_stbl;
T_sym_tbl_report_card report_card;
find_sym_in_stbl(report_card,*LR1_REDUCE_OPERATOR_LITERAL);
T_in_stbl* td = (T_in_stbl*)report_card.tbl_entry_->symbol_;
La_to_fill_in.insert(td);
}

/*:51*/
//line 342 "/usr/local/yacco2/compiler/o2/o2_defs.w"

}
}
}
/*:50*//*52:*/
//line 368 "/usr/local/yacco2/compiler/o2/o2_defs.w"

bool state_element::calc_la(state_element&La_to_fill_in){
if(La_to_fill_in.la_set_==NULL){
return false;
}
if(La_to_fill_in.reduced_state_!=La_to_fill_in.self_state_)return true;
VISITED_MERGE_STATES_IN_LA_CALC.clear();
La_to_fill_in.la_set_->clear();
state*cs= La_to_fill_in.closure_state_;
CAbs_lr1_sym*sym= AST::content(*La_to_fill_in.sr_element_);
T_ENO id= sym->enumerated_id__;
switch(id){
case T_Enum::T_T_eosubrule_:{
/*110:*/
//line 1893 "/usr/local/yacco2/compiler/o2/o2_defs.w"

T_eosubrule* eos = (T_eosubrule*)sym;
/*:110*/
//line 381 "/usr/local/yacco2/compiler/o2/o2_defs.w"

rule_def*rd= eos->its_rule_def();
RULE_ENO r_id= rd->enum_id();
S_FOLLOW_SETS_ITER_type i= cs->state_s_follow_set_map_.find(r_id);
follow_element*fe= i->second;
add_fs_setA_to_LA(*fe,*La_to_fill_in.la_set_);
if(fe->transitions_.empty()!=true){
fill_la_from_transition(La_to_fill_in,fe->transitions_);
}
if(fe->merges_.empty()!=true){
fill_la_from_merge(La_to_fill_in,fe->merges_,r_id);
}
break;
}
case T_Enum::T_T_null_call_thread_eosubrule_:{
break;
}
case T_Enum::T_T_called_thread_eosubrule_:{
break;
}
}
if(La_to_fill_in.la_set_->empty()==true){
return false;
}else{
return true;
}
}

/*:52*//*53:*/
//line 410 "/usr/local/yacco2/compiler/o2/o2_defs.w"

void
state_element::
fill_la_from_merge(state_element&La_to_fill_in,MERGES_type&Merge,RULE_ENO Rule_no){
MERGES_ITER_type i= Merge.begin();
MERGES_ITER_type ie= Merge.end();
for(;i!=ie;++i){
state*cs= *i;
STATES_SET_ITER_type ii= VISITED_MERGE_STATES_IN_LA_CALC.find(cs);
if(ii!=VISITED_MERGE_STATES_IN_LA_CALC.end())return;
VISITED_MERGE_STATES_IN_LA_CALC.insert(cs);
S_FOLLOW_SETS_ITER_type i= cs->state_s_follow_set_map_.find(Rule_no);
follow_element*fe= i->second;
add_fs_setA_to_LA(*fe,*La_to_fill_in.la_set_);
if(fe->transitions_.empty()!=true){
fill_la_from_transition(La_to_fill_in,fe->transitions_);
}
if(fe->merges_.empty()!=true){
fill_la_from_merge(La_to_fill_in,fe->merges_,fe->rule_no_);
}
}
}

/*:53*//*54:*/
//line 434 "/usr/local/yacco2/compiler/o2/o2_defs.w"

void
state_element::
fill_la_from_transition(state_element&La_to_fill_in,TRANSITIONS_type&Transition){
TRANSITIONS_ITER_type i= Transition.begin();
TRANSITIONS_ITER_type ie= Transition.end();
for(;i!=ie;++i){
follow_element*fe= *i;
add_fs_setA_to_LA(*fe,*La_to_fill_in.la_set_);
if(fe->transitions_.empty()!=true){
fill_la_from_transition(La_to_fill_in,fe->transitions_);
}
if(fe->merges_.empty()!=true){
fill_la_from_merge(La_to_fill_in,fe->merges_,fe->rule_no_);
}
}
}

/*:54*//*55:*/
//line 454 "/usr/local/yacco2/compiler/o2/o2_defs.w"

RULE_ENO state_element::find_state_element_s_rule_no(){
return subrule_def_->its_rule_def()->enum_id();
}

/*:55*//*57:*/
//line 472 "/usr/local/yacco2/compiler/o2/o2_defs.w"

AST*follow_element::rule_def_t(){return rule_def_t_;}
state*follow_element::its_state(){return its_state_;}
follow_element::follow_element(state*State)
:rule_no_(-1)
,rule_def_t_(0)
,its_state_(State)
{}
follow_element::follow_element(RULE_ENO Rule_no,state_element&State_elem,AST&Rule_def_t)
:rule_no_(Rule_no)
,rule_def_t_(&Rule_def_t)
,its_state_(State_elem.closure_state_)
{}

void follow_element::add_follow_set_contributor(AST*SR_element){
sr_elements_.push_back(SR_element);
}
/*:57*//*58:*/
//line 495 "/usr/local/yacco2/compiler/o2/o2_defs.w"

void follow_element::add_follow_set_transition(state_element&State_elem,T_eosubrule&Eos){
rule_def*rd= Eos.its_rule_def();
RULE_ENO eno= rd->enum_id();

S_FOLLOW_SETS_ITER_type fsi= 
State_elem.closure_state_->state_s_follow_set_map_.find(eno);
if(fsi==State_elem.closure_state_->state_s_follow_set_map_.end()){
return;
}
follow_element*fe= fsi->second;
/*59:*/
//line 513 "/usr/local/yacco2/compiler/o2/o2_defs.w"

if((rule_no_==eno)
&&
(its_state_->state_no_==State_elem.closure_state_->state_no_))
return;

/*:59*/
//line 506 "/usr/local/yacco2/compiler/o2/o2_defs.w"

transitions_.push_back(fe);
}

/*:58*//*60:*/
//line 521 "/usr/local/yacco2/compiler/o2/o2_defs.w"

void follow_element::add_T_to_follow_set(AST*Refered_T){
/*61:*/
//line 527 "/usr/local/yacco2/compiler/o2/o2_defs.w"

refered_T* t = (refered_T*)AST::content(*Refered_T);

/*:61*/
//line 523 "/usr/local/yacco2/compiler/o2/o2_defs.w"

follow_set_.insert(t->t_in_stbl());
}
/*:60*//*62:*/
//line 531 "/usr/local/yacco2/compiler/o2/o2_defs.w"

void follow_element::remove_merge_closure_info(){
merges_.pop_front();
}

/*:62*//*63:*/
//line 539 "/usr/local/yacco2/compiler/o2/o2_defs.w"

void follow_element::add_merge_closure_info(state&To_merge_closure_state){
state*tm= &To_merge_closure_state;
MERGES_ITER_type i= merges_.begin();
MERGES_ITER_type ie= merges_.end();
for(;i!=ie;++i){
state*s= *i;
if(s==tm)return;
}
merges_.push_front(&To_merge_closure_state);
}

/*:63*//*66:*/
//line 640 "/usr/local/yacco2/compiler/o2/o2_defs.w"



/*:66*//*67:*/
//line 644 "/usr/local/yacco2/compiler/o2/o2_defs.w"

state::state(AST*Start_rule_t)
:cs_vector_combo_gening_it_(0,-1)
,vectored_into_by_elem_(START_STATE_ENUMERATE)
,vectored_into_by_elem_sym_(0)
,state_no_(0)
,closure_state_birthing_it_(0)
,state_type_(0)
,arbitrator_name_(0)
{
create_start_state(*Start_rule_t);
add_state_to_gbl_lr1_state_tbls(this);
}

/*:67*//*68:*/
//line 659 "/usr/local/yacco2/compiler/o2/o2_defs.w"

state::state()
:cs_vector_combo_gening_it_(0,-1)
,vectored_into_by_elem_(START_STATE_ENUMERATE)
,vectored_into_by_elem_sym_(0)
,state_no_(0)
,closure_state_birthing_it_(0)
,state_type_(0)
,arbitrator_name_(0)
{}

/*:68*//*69:*/
//line 671 "/usr/local/yacco2/compiler/o2/o2_defs.w"

state::state(Voc_ENO Eno,CAbs_lr1_sym*Entry_sym)
:cs_vector_combo_gening_it_(0,-1)
,vectored_into_by_elem_(Eno)
,vectored_into_by_elem_sym_(Entry_sym)
,state_no_(0)
,closure_state_birthing_it_(0)
,state_type_(0)
,arbitrator_name_(0)
{}

/*:69*//*70:*/
//line 686 "/usr/local/yacco2/compiler/o2/o2_defs.w"

void state::closure_only_derives(AST*Rule_tree){
gen_context gening_context(0,-1);
add_rule_s_subrules_to_state(*Rule_tree,gening_context,*this);
add_closure_rules_subrules_to_state(gening_context,*this);
}


/*:70*//*72:*/
//line 708 "/usr/local/yacco2/compiler/o2/o2_defs.w"

void state::add_element_to_state_vector
(Voc_ENO Elem_id,state_element&Elem){
S_VECTORS_ITER_type i= state_s_vector_.find(Elem_id);
if(i==state_s_vector_.end()){
state_s_vector_[Elem_id]= S_VECTOR_ELEMS_type();
i= state_s_vector_.find(Elem_id);
}
S_VECTOR_ELEMS_type&el= i->second;
if(el.empty()==true){
el.push_back(&Elem);
return;
}
S_VECTOR_ELEMS_ITER_type j= el.begin();
S_VECTOR_ELEMS_ITER_type je= el.end();
for(;j!=je;++j){
state_element*se= *j;
if(Elem.sr_element_<se->sr_element_){
el.insert(j,&Elem);
return;
}
}
el.push_back(&Elem);
}

/*:72*//*73:*/
//line 739 "/usr/local/yacco2/compiler/o2/o2_defs.w"

void state::add_closure_rules_subrules_to_state(gen_context&Possible_gen_context,state&Closure_state){
CLOSURE_RULES_type processed_rules_set;
loop_until_empty:;
if(closure_rule_list_.empty()==true)return;
CLOSURE_RULES_ITER_type i= closure_rule_list_.begin();
if(processed_rules_set.find(*i)!=processed_rules_set.end()){
closure_rule_list_.erase(*i);
goto loop_until_empty;
}
processed_rules_set.insert(*i);
rule_def*rd= (*i)->r_def();
AST*t= rd->rule_s_tree();
add_rule_s_subrules_to_state(*t,Possible_gen_context,Closure_state);
goto loop_until_empty;
}

/*:73*//*74:*/
//line 757 "/usr/local/yacco2/compiler/o2/o2_defs.w"

void state::add_rule_to_closure_list(rule_in_stbl*Rule_in_stbl){
CLOSURE_RULES_ITER_type i= closure_rule_list_.find(Rule_in_stbl);
if(i==closure_rule_list_.end()){
closure_rule_list_.insert(Rule_in_stbl);
derives_closure_rule_list_.insert(Rule_in_stbl);
rule_def*rd= Rule_in_stbl->r_def();
if(rd->closure_rules_making_up_first_set()->empty()==true)return;
CLOSURE_RULES_type*cr= rd->closure_rules_making_up_first_set();
CLOSURE_RULES_ITER_type j= cr->begin();
CLOSURE_RULES_ITER_type je= cr->end();
for(;j!=je;++j){
rule_in_stbl*ris= *j;
i= closure_rule_list_.find(ris);
if(i==closure_rule_list_.end()){
derives_closure_rule_list_.insert(ris);
closure_rule_list_.insert(ris);
}
}
}
}
/*:74*//*75:*/
//line 785 "/usr/local/yacco2/compiler/o2/o2_defs.w"

void
state::
add_rule_s_subrules_to_state(AST&Start_Rule_def_t,gen_context&Possible_gen_context,state&Closure_state_associate_with){
AST*subrules_t= AST::get_1st_son(Start_Rule_def_t);
AST*first_element_t(0);
CAbs_lr1_sym*first_element(0);
Voc_ENO id(START_STATE_ENUMERATE);
Voc_ENO cs_id(START_STATE_ENUMERATE);
for(;subrules_t!=0;subrules_t= AST::brother(*subrules_t)){
T_subrule_def* srd = (T_subrule_def*)AST::content(*subrules_t);
first_element_t= AST::get_1st_son(*subrules_t);
first_element= AST::content(*first_element_t);
state_element*se= new state_element(first_element_t);
se->subrule_def_= srd;
se->self_state_= this;
se->closure_state_= this;
se->closured_state_gening_it_= &Closure_state_associate_with;
id= first_element->enumerated_id__;
switch(id){
case T_Enum::T_refered_rule_:{
refered_rule* rr = (refered_rule*)first_element;
rule_def*rd= rr->its_rule_def();
rule_in_stbl*ris= rr->Rule_in_stbl();
RULE_ENO r_id= rd->enum_id();
cs_id= r_id;
se->cs_vector_combo_gening_it_.gen_vector_= r_id;
add_element_to_state_vector(r_id,*se);
add_rule_to_follow_list(r_id);
add_rule_to_closure_list(ris);
break;
}
case T_Enum::T_T_eosubrule_:{
T_ENO t_id= T_Enum::T_T_eosubrule_;
cs_id= t_id;
se->reduced_state_= this;
se->cs_vector_combo_gening_it_.gen_vector_= t_id;
add_element_to_state_vector(-t_id,*se);
break;
}
case T_Enum::T_T_null_call_thread_eosubrule_:{
T_ENO t_id= T_Enum::T_T_null_call_thread_eosubrule_;
cs_id= t_id;
se->reduced_state_= this;
se->cs_vector_combo_gening_it_.gen_vector_= t_id;
add_element_to_state_vector(-t_id,*se);
break;
}
case T_Enum::T_T_called_thread_eosubrule_:{
T_ENO t_id= T_Enum::T_T_called_thread_eosubrule_;
cs_id= t_id;
se->reduced_state_= this;
se->cs_vector_combo_gening_it_.gen_vector_= t_id;
add_element_to_state_vector(-t_id,*se);
break;
}
case T_Enum::T_refered_T_:{
refered_T* rt = (refered_T*)first_element;
T_terminal_def*td= rt->its_t_def();
T_ENO t_id= td->enum_id();
cs_id= t_id;
se->cs_vector_combo_gening_it_.gen_vector_= t_id;
add_element_to_state_vector(t_id,*se);
break;
}
}
if(Possible_gen_context.gen_vector_!=-1){
se->cs_vector_combo_gening_it_= Possible_gen_context;
}else{
se->cs_vector_combo_gening_it_.for_closure_state_= this;
se->cs_vector_combo_gening_it_.gen_vector_= cs_id;
}

}
}

/*:75*//*76:*/
//line 877 "/usr/local/yacco2/compiler/o2/o2_defs.w"

bool state::crt_core_items_of_state
(S_VECTOR_ELEMS_ITER_type&Iter_begin
,S_VECTOR_ELEMS_ITER_type&Iter_end
,gen_context&Gening_context){
bool rt_bnded(false);
AST*to_element_t(0);
CAbs_lr1_sym*to_element(0);
Voc_ENO id(START_STATE_ENUMERATE);
for(;Iter_begin!=Iter_end;++Iter_begin){
state_element*from_se= *Iter_begin;
to_element_t= AST::brother(*from_se->sr_element_);
bool se_rt_bnded_condition= is_str_rt_bnded(to_element_t);
if(se_rt_bnded_condition==true)rt_bnded= se_rt_bnded_condition;
to_element= AST::content(*to_element_t);
switch(to_element->enumerated_id__){
case T_Enum::T_T_null_call_thread_eosubrule_:{
to_element_t= AST::brother(*to_element_t);
se_rt_bnded_condition= is_str_rt_bnded(to_element_t);
if(se_rt_bnded_condition==true)rt_bnded= se_rt_bnded_condition;
to_element= AST::content(*to_element_t);
break;
}
case T_Enum::T_T_called_thread_eosubrule_:{
to_element_t= AST::brother(*to_element_t);
se_rt_bnded_condition= is_str_rt_bnded(to_element_t);
if(se_rt_bnded_condition==true)rt_bnded= se_rt_bnded_condition;
to_element= AST::content(*to_element_t);
break;
}
}
state_element*se= new state_element(to_element_t);
se->subrule_def_= from_se->subrule_def_;
se->self_state_= this;
se->closure_state_= from_se->closure_state_;
se->closured_state_gening_it_= Gening_context.for_closure_state_;

se->cs_vector_combo_gening_it_= Gening_context;

if(se_rt_bnded_condition==true){
if(from_se->closured_state_gening_it_!=Gening_context.for_closure_state_){

se->cs_vector_combo_gening_it_= from_se->cs_vector_combo_gening_it_;
se->closured_state_gening_it_= from_se->closured_state_gening_it_;
}else{
se->cs_vector_combo_gening_it_= Gening_context;
se->closured_state_gening_it_= Gening_context.for_closure_state_;
}
}
from_se->goto_state_= se->self_state_;
se->previous_state_= from_se->self_state_;

from_se->next_state_element_= se;
se->previous_state_element_= from_se;
id= to_element->enumerated_id__;
/*77:*/
//line 938 "/usr/local/yacco2/compiler/o2/o2_defs.w"

switch(id){
case T_Enum::T_refered_rule_:{
refered_rule* rr = (refered_rule*)to_element;
rule_def*rd= rr->its_rule_def();
rule_in_stbl*ris= rr->Rule_in_stbl();
RULE_ENO r_id= rd->enum_id();
add_element_to_state_vector(r_id,*se);
add_rule_to_follow_list(r_id);
add_rule_to_closure_list(ris);
break;
}
case T_Enum::T_T_eosubrule_:{
T_ENO t_id= T_Enum::T_T_eosubrule_;
add_element_to_state_vector(-t_id,*se);
break;
}
case T_Enum::T_T_null_call_thread_eosubrule_:{
T_ENO t_id= T_Enum::T_T_null_call_thread_eosubrule_;
add_element_to_state_vector(-t_id,*se);
break;
}
case T_Enum::T_T_called_thread_eosubrule_:{
T_ENO t_id= T_Enum::T_T_called_thread_eosubrule_;
add_element_to_state_vector(-t_id,*se);
break;
}
case T_Enum::T_refered_T_:{
refered_T* rt = (refered_T*)to_element;
T_terminal_def*td= rt->its_t_def();
T_ENO t_id= td->enum_id();
add_element_to_state_vector(t_id,*se);
break;
}
}

/*:77*/
//line 932 "/usr/local/yacco2/compiler/o2/o2_defs.w"

}
return rt_bnded;
}

/*:76*//*78:*/
//line 975 "/usr/local/yacco2/compiler/o2/o2_defs.w"

void state::create_start_state(AST&Start_rule_t){
gen_context gening_context(0,-1);
add_rule_s_subrules_to_state(Start_rule_t,gening_context,*this);
add_closure_rules_subrules_to_state(gening_context,*this);
crt_start_rule_s_follow_set(Start_rule_t);
create_follow_sets_of_state();
this->state_type_= determine_reduced_state_type(this);

}
/*:78*//*79:*/
//line 993 "/usr/local/yacco2/compiler/o2/o2_defs.w"

bool
state::
gen_transitive_states_for_closure_context
(gen_context&For_gening_context,state&For_closure_state,state&State){
/*137:*/
//line 2200 "/usr/local/yacco2/compiler/o2/o2_defs.w"

/*138:*/
//line 2205 "/usr/local/yacco2/compiler/o2/o2_defs.w"

++RECURSION_INDEX__;
/*:138*/
//line 2201 "/usr/local/yacco2/compiler/o2/o2_defs.w"

/*139:*/
//line 2208 "/usr/local/yacco2/compiler/o2/o2_defs.w"

for(int y__(1);y__<=RECURSION_INDEX__;++y__)lrclog<<'.';
/*:139*/
//line 2202 "/usr/local/yacco2/compiler/o2/o2_defs.w"


/*:137*/
//line 998 "/usr/local/yacco2/compiler/o2/o2_defs.w"

lrclog<<"gen_transitive_states_for_closure_context for closure state: "
<<For_gening_context.for_closure_state_->state_no_
<<endl;
S_VECTORS_ITER_type i= State.state_s_vector_.begin();
S_VECTORS_ITER_type ie= State.state_s_vector_.end();
for(;i!=ie;++i){
Voc_ENO eno= i->first;
/*80:*/
//line 1025 "/usr/local/yacco2/compiler/o2/o2_defs.w"

if(eno==-T_Enum::T_T_eosubrule_)
{
S_VECTOR_ELEMS_type elem_list= i->second;
S_VECTOR_ELEMS_ITER_type j= elem_list.begin();
S_VECTOR_ELEMS_ITER_type je= elem_list.end();
for(;j!=je;++j){
state_element*se= *j;
se->reduced_state_= se->self_state_;
state*reduced_state= se->self_state_;
while(se->previous_state_element_!=0){
se->previous_state_element_->reduced_state_= reduced_state;
se= se->previous_state_element_;
}
}
continue;
}

/*:80*/
//line 1006 "/usr/local/yacco2/compiler/o2/o2_defs.w"

For_gening_context.gen_vector_= eno;
/*139:*/
//line 2208 "/usr/local/yacco2/compiler/o2/o2_defs.w"

for(int y__(1);y__<=RECURSION_INDEX__;++y__)lrclog<<'.';
/*:139*/
//line 1008 "/usr/local/yacco2/compiler/o2/o2_defs.w"

lrclog<<" for vector: "
<<For_gening_context.gen_vector_
<<endl;
bool continue_gening= gen_a_state(For_gening_context,For_closure_state,State,i);
if(continue_gening==NOT_LR1_COMPATIBLE){
/*140:*/
//line 2211 "/usr/local/yacco2/compiler/o2/o2_defs.w"

--RECURSION_INDEX__;

/*:140*/
//line 1014 "/usr/local/yacco2/compiler/o2/o2_defs.w"

return NOT_LR1_COMPATIBLE;
}
}
/*140:*/
//line 2211 "/usr/local/yacco2/compiler/o2/o2_defs.w"

--RECURSION_INDEX__;

/*:140*/
//line 1018 "/usr/local/yacco2/compiler/o2/o2_defs.w"

return LR1_COMPATIBLE;
}

/*:79*//*81:*/
//line 1044 "/usr/local/yacco2/compiler/o2/o2_defs.w"

bool
state::
gen_transitive_states_balance_for_closure_vector
(gen_context&Gen_context,state&For_closure_state,state&Goto_state){
/*137:*/
//line 2200 "/usr/local/yacco2/compiler/o2/o2_defs.w"

/*138:*/
//line 2205 "/usr/local/yacco2/compiler/o2/o2_defs.w"

++RECURSION_INDEX__;
/*:138*/
//line 2201 "/usr/local/yacco2/compiler/o2/o2_defs.w"

/*139:*/
//line 2208 "/usr/local/yacco2/compiler/o2/o2_defs.w"

for(int y__(1);y__<=RECURSION_INDEX__;++y__)lrclog<<'.';
/*:139*/
//line 2202 "/usr/local/yacco2/compiler/o2/o2_defs.w"


/*:137*/
//line 1049 "/usr/local/yacco2/compiler/o2/o2_defs.w"


lrclog<<"gen_transitive_states_balance_for_closure_vector for <"
<<Gen_context.for_closure_state_->state_no_
<<","
<<Gen_context.gen_vector_
<<"> goto state: "
<<Goto_state.state_no_
<<endl;
S_VECTORS_ITER_type i= Goto_state.state_s_vector_.begin();
S_VECTORS_ITER_type ie= Goto_state.state_s_vector_.end();
for(;i!=ie;++i){
Voc_ENO eno= i->first;
/*80:*/
//line 1025 "/usr/local/yacco2/compiler/o2/o2_defs.w"

if(eno==-T_Enum::T_T_eosubrule_)
{
S_VECTOR_ELEMS_type elem_list= i->second;
S_VECTOR_ELEMS_ITER_type j= elem_list.begin();
S_VECTOR_ELEMS_ITER_type je= elem_list.end();
for(;j!=je;++j){
state_element*se= *j;
se->reduced_state_= se->self_state_;
state*reduced_state= se->self_state_;
while(se->previous_state_element_!=0){
se->previous_state_element_->reduced_state_= reduced_state;
se= se->previous_state_element_;
}
}
continue;
}

/*:80*/
//line 1062 "/usr/local/yacco2/compiler/o2/o2_defs.w"

bool continue_gening= gen_a_state(Gen_context,For_closure_state,Goto_state,i);
if(continue_gening==NOT_LR1_COMPATIBLE){
/*140:*/
//line 2211 "/usr/local/yacco2/compiler/o2/o2_defs.w"

--RECURSION_INDEX__;

/*:140*/
//line 1065 "/usr/local/yacco2/compiler/o2/o2_defs.w"

return NOT_LR1_COMPATIBLE;
}
}
/*140:*/
//line 2211 "/usr/local/yacco2/compiler/o2/o2_defs.w"

--RECURSION_INDEX__;

/*:140*/
//line 1069 "/usr/local/yacco2/compiler/o2/o2_defs.w"

return LR1_COMPATIBLE;
}


/*:81*//*82:*/
//line 1117 "/usr/local/yacco2/compiler/o2/o2_defs.w"

bool state::gen_a_state
(gen_context&For_gening_context
,state&For_closure_state
,state&Requesting_state,S_VECTORS_ITER_type&Elem_iter){
/*137:*/
//line 2200 "/usr/local/yacco2/compiler/o2/o2_defs.w"

/*138:*/
//line 2205 "/usr/local/yacco2/compiler/o2/o2_defs.w"

++RECURSION_INDEX__;
/*:138*/
//line 2201 "/usr/local/yacco2/compiler/o2/o2_defs.w"

/*139:*/
//line 2208 "/usr/local/yacco2/compiler/o2/o2_defs.w"

for(int y__(1);y__<=RECURSION_INDEX__;++y__)lrclog<<'.';
/*:139*/
//line 2202 "/usr/local/yacco2/compiler/o2/o2_defs.w"


/*:137*/
//line 1122 "/usr/local/yacco2/compiler/o2/o2_defs.w"

lrclog<<"gen_a_state for <"
<<For_gening_context.for_closure_state_->state_no_
<<","
<<For_gening_context.gen_vector_
<<"> requesting state: "
<<Requesting_state.state_no_
<<endl;

gen_context associated_rt_bnded_cs(0,-1);
Voc_ENO eno= Elem_iter->first;
S_VECTOR_ELEMS_type elem_list= Elem_iter->second;
S_VECTOR_ELEMS_ITER_type i= elem_list.begin();
S_VECTOR_ELEMS_ITER_type ie= elem_list.end();
bool compatible(false);
for(;i!=ie;++i){
state_element*se= *i;
/*83:*/
//line 1173 "/usr/local/yacco2/compiler/o2/o2_defs.w"

if((
(se->cs_vector_combo_gening_it_.for_closure_state_==For_gening_context.for_closure_state_)
&&
(se->cs_vector_combo_gening_it_.gen_vector_==For_gening_context.gen_vector_)
)!=true){
/*139:*/
//line 2208 "/usr/local/yacco2/compiler/o2/o2_defs.w"

for(int y__(1);y__<=RECURSION_INDEX__;++y__)lrclog<<'.';
/*:139*/
//line 1179 "/usr/local/yacco2/compiler/o2/o2_defs.w"

lrclog<<"gen_a_state Bypass subrule as its gening <"
<<se->cs_vector_combo_gening_it_.for_closure_state_->state_no_
<<","
<<se->cs_vector_combo_gening_it_.gen_vector_
<<"> different then gening <"
<<For_gening_context.for_closure_state_->state_no_
<<","
<<For_gening_context.gen_vector_
<<">"
<<endl;
continue;
}

/*:83*/
//line 1139 "/usr/local/yacco2/compiler/o2/o2_defs.w"

/*84:*/
//line 1194 "/usr/local/yacco2/compiler/o2/o2_defs.w"

if(se->goto_state_!=0){
/*139:*/
//line 2208 "/usr/local/yacco2/compiler/o2/o2_defs.w"

for(int y__(1);y__<=RECURSION_INDEX__;++y__)lrclog<<'.';
/*:139*/
//line 1196 "/usr/local/yacco2/compiler/o2/o2_defs.w"


lrclog<<"gen_a_state subrule COMMON PREFIX state gened by a different gening context.  <"
<<se->cs_vector_combo_gening_it_.for_closure_state_->state_no_
<<","
<<se->cs_vector_combo_gening_it_.gen_vector_
<<"> goto state: "
<<se->goto_state_->state_no_
<<endl;
add_state_to_conflict_states_list_if(For_gening_context,*se->goto_state_);
bool gen_ok= gen_transitive_states_balance_for_closure_vector(For_gening_context,For_closure_state,*se->goto_state_);
/*140:*/
//line 2211 "/usr/local/yacco2/compiler/o2/o2_defs.w"

--RECURSION_INDEX__;

/*:140*/
//line 1207 "/usr/local/yacco2/compiler/o2/o2_defs.w"

return gen_ok;
}
/*:84*/
//line 1140 "/usr/local/yacco2/compiler/o2/o2_defs.w"

/*85:*/
//line 1211 "/usr/local/yacco2/compiler/o2/o2_defs.w"

state*s= new state(eno,se->sr_def_element_);
s->closure_state_birthing_it_= For_gening_context.for_closure_state_;
s->cs_vector_combo_gening_it_= For_gening_context;
S_VECTOR_ELEMS_ITER_type j= elem_list.begin();
S_VECTOR_ELEMS_ITER_type je= elem_list.end();

bool rt_bnded= s->crt_core_items_of_state(j,je,For_gening_context);
if(rt_bnded==true){
associated_rt_bnded_cs= For_gening_context;
}else{
associated_rt_bnded_cs.for_closure_state_= 0;
associated_rt_bnded_cs.gen_vector_= -1;
}
s->add_closure_rules_subrules_to_state(associated_rt_bnded_cs,*s);
s->create_follow_sets_of_state();

/*:85*/
//line 1141 "/usr/local/yacco2/compiler/o2/o2_defs.w"

/*86:*/
//line 1231 "/usr/local/yacco2/compiler/o2/o2_defs.w"

int compatibility_result= find_2_states_compatible_and_merge(*s);
switch(compatibility_result){
case MERGED:{
delete s;
/*140:*/
//line 2211 "/usr/local/yacco2/compiler/o2/o2_defs.w"

--RECURSION_INDEX__;

/*:140*/
//line 1236 "/usr/local/yacco2/compiler/o2/o2_defs.w"

return true;
}
case ABORT_GENING_STATES:{
/*140:*/
//line 2211 "/usr/local/yacco2/compiler/o2/o2_defs.w"

--RECURSION_INDEX__;

/*:140*/
//line 1240 "/usr/local/yacco2/compiler/o2/o2_defs.w"

return NOT_LR1_COMPATIBLE;
}
case NOT_MERGED:{
break;
}
}

/*:86*/
//line 1142 "/usr/local/yacco2/compiler/o2/o2_defs.w"

add_state_to_gbl_lr1_state_tbls(s);
/*139:*/
//line 2208 "/usr/local/yacco2/compiler/o2/o2_defs.w"

for(int y__(1);y__<=RECURSION_INDEX__;++y__)lrclog<<'.';
/*:139*/
//line 1144 "/usr/local/yacco2/compiler/o2/o2_defs.w"


lrclog<<"gen_a_state for <"
<<For_gening_context.for_closure_state_->state_no_
<<","
<<For_gening_context.gen_vector_
<<"> requesting state: "
<<Requesting_state.state_no_
<<" NEW STATE CREATED: "
<<s->state_no_
<<endl;
add_state_to_conflict_states_list_if(For_gening_context,*s);
compatible= is_state_lr1_compatible(*s);
if(compatible==NOT_LR1_COMPATIBLE){
/*140:*/
//line 2211 "/usr/local/yacco2/compiler/o2/o2_defs.w"

--RECURSION_INDEX__;

/*:140*/
//line 1158 "/usr/local/yacco2/compiler/o2/o2_defs.w"

return NOT_LR1_COMPATIBLE;
}

s->state_type_= determine_reduced_state_type(s);
bool gen_ok= gen_transitive_states_balance_for_closure_vector(For_gening_context,For_closure_state,*s);
/*140:*/
//line 2211 "/usr/local/yacco2/compiler/o2/o2_defs.w"

--RECURSION_INDEX__;

/*:140*/
//line 1164 "/usr/local/yacco2/compiler/o2/o2_defs.w"

return gen_ok;
}
/*140:*/
//line 2211 "/usr/local/yacco2/compiler/o2/o2_defs.w"

--RECURSION_INDEX__;

/*:140*/
//line 1167 "/usr/local/yacco2/compiler/o2/o2_defs.w"


return LR1_COMPATIBLE;
}

/*:82*//*87:*/
//line 1251 "/usr/local/yacco2/compiler/o2/o2_defs.w"

int state::determine_reduced_state_type(state*S){

using namespace NS_yacco2_T_enum;
int no_reduces(0);
int no_reduce_types(0);
S_VECTORS_ITER_type svi= S->state_s_vector_.begin();
S_VECTORS_ITER_type svie= S->state_s_vector_.end();
S_VECTORS_ITER_type tvi= S->state_s_vector_.find(-T_Enum::T_T_eosubrule_);
if(tvi!=svie){
no_reduces+= tvi->second.size();
++no_reduce_types;
}
tvi= S->state_s_vector_.find(-T_Enum::T_T_called_thread_eosubrule_);
if(tvi!=svie){
no_reduces+= tvi->second.size();
++no_reduce_types;
}
tvi= S->state_s_vector_.find(-T_Enum::T_T_null_call_thread_eosubrule_);
if(tvi!=svie){
no_reduces+= tvi->second.size();
++no_reduce_types;
}
if(no_reduces> 1)no_reduces= 3;
if(S->state_s_vector_.size()> no_reduce_types){
if(no_reduce_types> 0){
++no_reduces;
}
}
return no_reduces;
}

/*:87*//*88:*/
//line 1284 "/usr/local/yacco2/compiler/o2/o2_defs.w"

void state::add_state_to_gbl_lr1_state_tbls(state*State){
++NO_LR1_STATES;
State->state_no_= NO_LR1_STATES;
LR1_STATES.push_back(State);
Voc_ENO eno= State->vectored_into_by_elem_;
LR1_STATES_ITER_type i= LR1_COMMON_STATES.find(eno);
if(i==LR1_COMMON_STATES.end()){
LR1_COMMON_STATES[eno]= STATES_type();
i= LR1_COMMON_STATES.find(eno);
}
i->second.push_back(State);
}

/*:88*//*89:*/
//line 1303 "/usr/local/yacco2/compiler/o2/o2_defs.w"

void state::add_state_to_conflict_states_list_if(gen_context&Gening_context,state&State){
S_VECTORS_ITER_type i= State.state_s_vector_.find(-T_Enum::T_T_eosubrule_);
if(i!=State.state_s_vector_.end())goto reduce_fnd;
return;
reduce_fnd:;
if(i->second.size()> 1){
Gening_context.for_closure_state_->state_s_conflict_state_list_.push_back(&State);
return;
}
if(State.state_s_vector_.size()<2)return;
Gening_context.for_closure_state_->state_s_conflict_state_list_.push_back(&State);
}

/*:89*//*91:*/
//line 1353 "/usr/local/yacco2/compiler/o2/o2_defs.w"

bool state::are_states_equivalent(state&Merge_into_state,state&To_merge_state){
if(Merge_into_state.vectored_into_by_elem_!=To_merge_state.vectored_into_by_elem_){
return false;
}
if(Merge_into_state.state_s_vector_.size()!=To_merge_state.state_s_vector_.size()){
return false;
}
S_VECTORS_ITER_type i= Merge_into_state.state_s_vector_.begin();
S_VECTORS_ITER_type ie= Merge_into_state.state_s_vector_.end();
S_VECTORS_ITER_type j= To_merge_state.state_s_vector_.begin();
S_VECTORS_ITER_type je= To_merge_state.state_s_vector_.end();
for(;i!=ie;++i,++j){
Voc_ENO ieno= i->first;
Voc_ENO jeno= j->first;
if(ieno!=jeno){
return false;
}
if(i->second.size()!=j->second.size()){
return false;
}
S_VECTOR_ELEMS_ITER_type l= i->second.begin();
S_VECTOR_ELEMS_ITER_type le= i->second.end();
S_VECTOR_ELEMS_ITER_type m= j->second.begin();
S_VECTOR_ELEMS_ITER_type me= j->second.end();
for(;l!=le;++l,++m){
state_element*ls= *l;
state_element*ms= *m;
if(ls->sr_element_!=ms->sr_element_){
return false;
}
}
}
return true;
}

/*:91*//*92:*/
//line 1407 "/usr/local/yacco2/compiler/o2/o2_defs.w"

bool state::is_state_lr1_compatible(state&State_to_eval){
T_COUNT_type t_cnt(START_OF_RULES_ENUM);
for(int x= 0;x<START_OF_RULES_ENUM;++x)t_cnt[x]= 0;
S_VECTORS_ITER_type i;
i= State_to_eval.state_s_vector_.find(-T_Enum::T_T_eosubrule_);
if(i!=State_to_eval.state_s_vector_.end()){
goto assess_state;
}
i= State_to_eval.state_s_vector_.find(-T_Enum::T_T_called_thread_eosubrule_);
if(i!=State_to_eval.state_s_vector_.end()){
goto assess_state;
}
i= State_to_eval.state_s_vector_.find(-T_Enum::T_T_null_call_thread_eosubrule_);
if(i!=State_to_eval.state_s_vector_.end()){
goto assess_state;
}
return LR1_COMPATIBLE;
assess_state:
int no_reduces= 0;
S_VECTOR_ELEMS_ITER_type j= i->second.begin();
S_VECTOR_ELEMS_ITER_type je= i->second.end();
bool T_not_meta(false);
for(;j!=je;++j){
++no_reduces;
state_element*se= *j;
if(se->calc_la(*se)==false){
return NOT_LR1_COMPATIBLE;
}
LA_SET_ITER_type k= se->la_set_->begin();
LA_SET_ITER_type ke= se->la_set_->end();
for(;k!=ke;++k){
T_in_stbl*tintbl= *k;
T_ENO teno= tintbl->t_def()->enum_id();
if(teno<=END_OF_LR1_DEFS){
if(teno==LR1_EOG){
T_not_meta= true;
}
}else{
T_not_meta= true;
}
++t_cnt[teno];
if(t_cnt[teno]> 1)return NOT_LR1_COMPATIBLE;
}
}
if(no_reduces> 1){
if(T_not_meta==true){
if(t_cnt[LR1_EOLR]> 0)return NOT_LR1_COMPATIBLE;
}
}


S_VECTORS_ITER_type l= State_to_eval.state_s_vector_.begin();
S_VECTORS_ITER_type le= State_to_eval.state_s_vector_.end();
for(;l!=le;++l){
Voc_ENO t= l->first;
if(t==-T_Enum::T_T_eosubrule_)continue;
if(t==-T_Enum::T_T_null_call_thread_eosubrule_)continue;
if(t==-T_Enum::T_T_called_thread_eosubrule_)continue;
if(t==T_Enum::T_refered_rule_)continue;
S_VECTOR_ELEMS_ITER_type m= l->second.begin();
state_element*se= *m;
CAbs_lr1_sym*sym= AST::content(*se->sr_element_);
T_ENO tid= sym->enumerated_id__;
switch(tid){
case T_Enum::T_refered_T_:{
/*109:*/
//line 1889 "/usr/local/yacco2/compiler/o2/o2_defs.w"

refered_T* rt = (refered_T*)sym;

/*:109*/
//line 1473 "/usr/local/yacco2/compiler/o2/o2_defs.w"

T_in_stbl*tintbl= rt->t_in_stbl();
T_ENO teno= tintbl->t_def()->enum_id();
if(teno<=END_OF_LR1_DEFS){
if(teno!=LR1_EOG){
continue;
}
}
++t_cnt[teno];
if(t_cnt[teno]> 1)return NOT_LR1_COMPATIBLE;
if(teno> END_OF_LR1_DEFS){
if(t_cnt[LR1_EOLR]> 0)return NOT_LR1_COMPATIBLE;
}
}
}
}
return LR1_COMPATIBLE;
}

/*:92*//*93:*/
//line 1547 "/usr/local/yacco2/compiler/o2/o2_defs.w"

int
state::
are_2_states_compatible_yes_merge(state&To_merge_into_state,state&State_for_merging){
state*cs_To_merge_into= To_merge_into_state.closure_state_birthing_it_;
state*cs_for_merging= State_for_merging.closure_state_birthing_it_;

/*94:*/
//line 1586 "/usr/local/yacco2/compiler/o2/o2_defs.w"

RULE_NOS_SET_type rules_to_add;
S_VECTORS_ITER_type sfmi= To_merge_into_state.state_s_vector_.begin();
S_VECTORS_ITER_type sfmie= To_merge_into_state.state_s_vector_.end();
S_VECTORS_ITER_type msfmi= State_for_merging.state_s_vector_.begin();
for(;sfmi!=sfmie;++sfmi,++msfmi){
S_VECTOR_ELEMS_ITER_type rri= sfmi->second.begin();
S_VECTOR_ELEMS_ITER_type mrri= msfmi->second.begin();
S_VECTOR_ELEMS_ITER_type rrie= sfmi->second.end();
for(;rri!=rrie;++rri,++mrri){
state_element*re= *rri;
state_element*mre= *mrri;
if(re->closure_state_==re->self_state_)continue;
RULE_ENO ruleno= re->find_state_element_s_rule_no();
S_FOLLOW_SETS_ITER_type j= re->closure_state_->state_s_follow_set_map_.find(ruleno);
follow_element*fe= j->second;
RULE_NOS_SET_ITER_type rni= rules_to_add.find(ruleno);
if(rni==rules_to_add.end()){
fe->add_merge_closure_info(*mre->closure_state_);
rules_to_add.insert(ruleno);
}
}
}
/*:94*/
//line 1554 "/usr/local/yacco2/compiler/o2/o2_defs.w"

bool compatible(false);
if(cs_To_merge_into->state_s_conflict_state_list_.empty()==true)goto merged;
lr1_test:
{
S_CONFLICT_STATES_ITER_type k= cs_To_merge_into->state_s_conflict_state_list_.begin();
S_CONFLICT_STATES_ITER_type ke= cs_To_merge_into->state_s_conflict_state_list_.end();
for(;k!=ke;++k){
state*s= *k;

compatible= s->is_state_lr1_compatible(*s);

if(compatible==NOT_LR1_COMPATIBLE)goto unwind_merge;
}
}
merged:
{
/*95:*/
//line 1610 "/usr/local/yacco2/compiler/o2/o2_defs.w"

S_VECTORS_ITER_type ri= State_for_merging.state_s_vector_.begin();
S_VECTORS_ITER_type rie= State_for_merging.state_s_vector_.end();
S_VECTORS_ITER_type si= To_merge_into_state.state_s_vector_.begin();
for(;ri!=rie;++ri,++si){
S_VECTOR_ELEMS_ITER_type rri= ri->second.begin();
S_VECTOR_ELEMS_ITER_type rrie= ri->second.end();
S_VECTOR_ELEMS_ITER_type ssi= si->second.begin();
for(;rri!=rrie;++rri,++ssi){
state_element*re= *rri;
state_element*se= *ssi;
if(re->previous_state_element_==0)continue;
state_element*prev_re= re->previous_state_element_;
prev_re->goto_state_= se->self_state_;
prev_re->reduced_state_= se->reduced_state_;
prev_re->next_state_element_= se;

for(prev_re= prev_re->previous_state_element_;
prev_re!=0;prev_re= prev_re->previous_state_element_){
prev_re->reduced_state_= se->reduced_state_;
}
}
}
/*96:*/
//line 1642 "/usr/local/yacco2/compiler/o2/o2_defs.w"

if(cs_for_merging->cs_vector_combo_gening_it_.for_closure_state_
!=cs_To_merge_into->cs_vector_combo_gening_it_.for_closure_state_){
S_CONFLICT_STATES_ITER_type k= cs_To_merge_into->state_s_conflict_state_list_.begin();
S_CONFLICT_STATES_ITER_type ke= cs_To_merge_into->state_s_conflict_state_list_.end();
for(;k!=ke;++k){
state*s= *k;
cs_for_merging->state_s_conflict_state_list_.push_back(s);
}
}

/*:96*/
//line 1633 "/usr/local/yacco2/compiler/o2/o2_defs.w"


/*:95*/
//line 1571 "/usr/local/yacco2/compiler/o2/o2_defs.w"

return MERGED;
}

unwind_merge:{

unwind:;
/*97:*/
//line 1654 "/usr/local/yacco2/compiler/o2/o2_defs.w"

RULE_NOS_SET_type rules_to_add;
S_VECTORS_ITER_type sfmi= To_merge_into_state.state_s_vector_.begin();
S_VECTORS_ITER_type sfmie= To_merge_into_state.state_s_vector_.end();
for(;sfmi!=sfmie;++sfmi){
S_VECTOR_ELEMS_ITER_type rri= sfmi->second.begin();
S_VECTOR_ELEMS_ITER_type rrie= sfmi->second.end();
for(;rri!=rrie;++rri){
state_element*re= *rri;
if(re->closure_state_==re->self_state_)continue;
RULE_ENO ruleno= re->find_state_element_s_rule_no();
S_FOLLOW_SETS_ITER_type j= re->closure_state_->state_s_follow_set_map_.find(ruleno);
follow_element*fe= j->second;
RULE_NOS_SET_ITER_type rni= rules_to_add.find(ruleno);
if(rni==rules_to_add.end()){
fe->remove_merge_closure_info();
rules_to_add.insert(ruleno);
}
}
}

/*:97*/
//line 1578 "/usr/local/yacco2/compiler/o2/o2_defs.w"

return NOT_MERGED;
}
return NOT_MERGED;
}

/*:93*//*98:*/
//line 1678 "/usr/local/yacco2/compiler/o2/o2_defs.w"

int state::find_2_states_compatible_and_merge(state&State_for_merging){
Voc_ENO eno= State_for_merging.vectored_into_by_elem_;
LR1_STATES_ITER_type i= LR1_COMMON_STATES.find(eno);
if(i==LR1_COMMON_STATES.end()){
return NOT_MERGED;
}
STATES_ITER_type j= i->second.begin();
STATES_ITER_type je= i->second.end();
for(;j!=je;++j){
state*s= *j;
bool equivalent= are_states_equivalent(State_for_merging,*s);
if(equivalent==false)continue;
int compatible= are_2_states_compatible_yes_merge(*s,State_for_merging);
if(compatible==LR1_COMPATIBLE)return MERGED;
if(compatible==ABORT_GENING_STATES)return ABORT_GENING_STATES;
}
return NOT_MERGED;
}

/*:98*//*99:*/
//line 1700 "/usr/local/yacco2/compiler/o2/o2_defs.w"

bool state::are_gened_states_lr1_compatible(){
S_CONFLICT_STATES_ITER_type i= state_s_conflict_state_list_.begin();
S_CONFLICT_STATES_ITER_type ie= state_s_conflict_state_list_.end();
if(i==ie)return LR1_COMPATIBLE;
for(;i!=ie;++i){
state*s= *i;
if(is_state_lr1_compatible(*s)==NOT_LR1_COMPATIBLE)return NOT_LR1_COMPATIBLE;
}
return LR1_COMPATIBLE;
}

/*:99*//*100:*/
//line 1733 "/usr/local/yacco2/compiler/o2/o2_defs.w"

bool state::is_str_rt_bnded(AST*Str){
AST*rstr_t= AST::brother(*Str);
if(rstr_t==0)return false;
CAbs_lr1_sym*sym= AST::content(*rstr_t);
Voc_ENO id= sym->enumerated_id__;
if(id==T_Enum::T_T_eosubrule_){
CAbs_lr1_sym*rsym= AST::content(*Str);
if(rsym->enumerated_id__==T_Enum::T_refered_rule_){
return true;
}
}
return is_str_epsilonable(rstr_t);
}
/*:100*//*101:*/
//line 1756 "/usr/local/yacco2/compiler/o2/o2_defs.w"

bool state::is_str_epsilonable(AST*Str){
AST*str_t= Str;
for(;str_t!=0;str_t= AST::brother(*str_t)){
CAbs_lr1_sym*sym= AST::content(*str_t);
Voc_ENO id= sym->enumerated_id__;
/*102:*/
//line 1773 "/usr/local/yacco2/compiler/o2/o2_defs.w"

switch(id){
case T_Enum::T_refered_rule_:{
/*108:*/
//line 1885 "/usr/local/yacco2/compiler/o2/o2_defs.w"

refered_rule* rr = (refered_rule*)sym;

/*:108*/
//line 1776 "/usr/local/yacco2/compiler/o2/o2_defs.w"

rule_def*rd= rr->its_rule_def();
if(rd->epsilon()!=true)return false;
break;
}
case T_Enum::T_T_eosubrule_:{
return true;
}
case T_Enum::T_refered_T_:{
return false;
}
}

/*:102*/
//line 1762 "/usr/local/yacco2/compiler/o2/o2_defs.w"

}
return true;
}

/*:101*//*104:*/
//line 1791 "/usr/local/yacco2/compiler/o2/o2_defs.w"

void state::add_rule_to_follow_list(RULE_ENO Refered_rule){
FOLLOW_RULES_ITER_type i= follow_rule_list_.find(Refered_rule);
if(i==follow_rule_list_.end()){
follow_rule_list_.insert(Refered_rule);
}
}

/*:104*//*105:*/
//line 1806 "/usr/local/yacco2/compiler/o2/o2_defs.w"

void state::create_follow_sets_of_state(){
if(follow_rule_list_.empty()==true)return;
RULE_ENO eno(-1);
FOLLOW_RULES_ITER_type i= follow_rule_list_.begin();
FOLLOW_RULES_ITER_type ie= follow_rule_list_.end();
for(;i!=ie;++i){
follow_element*fe= new follow_element(this);
eno= *i;
fe->rule_no_= eno;
state_s_follow_set_map_[eno]= fe;
}

i= follow_rule_list_.begin();
for(;i!=ie;++i){
eno= *i;
S_VECTORS_ITER_type j= state_s_vector_.find(eno);
S_FOLLOW_SETS_ITER_type fsi= state_s_follow_set_map_.find(eno);
follow_element*fe= fsi->second;

S_VECTOR_ELEMS_ITER_type k= j->second.begin();
S_VECTOR_ELEMS_ITER_type ke= j->second.end();
for(;k!=ke;++k){
state_element*se= *k;
/*107:*/
//line 1882 "/usr/local/yacco2/compiler/o2/o2_defs.w"

refered_rule* rr = (refered_rule*)AST::content(*se->sr_element_);
/*:107*/
//line 1830 "/usr/local/yacco2/compiler/o2/o2_defs.w"

AST*follow_str_t= AST::brother(*se->sr_element_);
deal_with_follow_str_sym:;
fe->rule_def_t_= rr->its_rule_def()->rule_s_tree();
fe->add_follow_set_contributor(follow_str_t);
CAbs_lr1_sym*sym= AST::content(*follow_str_t);
Voc_ENO id= sym->enumerated_id__;
/*106:*/
//line 1842 "/usr/local/yacco2/compiler/o2/o2_defs.w"

switch(id){
case T_Enum::T_refered_rule_:{
/*108:*/
//line 1885 "/usr/local/yacco2/compiler/o2/o2_defs.w"

refered_rule* rr = (refered_rule*)sym;

/*:108*/
//line 1845 "/usr/local/yacco2/compiler/o2/o2_defs.w"

rule_def*rd= rr->its_rule_def();
if(rd->first_set()->empty()!=true){
FIRST_SET_ITER_type a= rd->first_set()->begin();
FIRST_SET_ITER_type ae= rd->first_set()->end();
for(;a!=ae;++a){
T_in_stbl*t= *a;
if(fe->follow_set_.find(t)==fe->follow_set_.end()){
fe->follow_set_.insert(t);
}
}
}
if(rd->epsilon()==true){
follow_str_t= AST::brother(*follow_str_t);
goto deal_with_follow_str_sym;
}
break;
}
case T_Enum::T_T_eosubrule_:{
/*110:*/
//line 1893 "/usr/local/yacco2/compiler/o2/o2_defs.w"

T_eosubrule* eos = (T_eosubrule*)sym;
/*:110*/
//line 1864 "/usr/local/yacco2/compiler/o2/o2_defs.w"

fe->add_follow_set_transition(*se,*eos);
break;
}
case T_Enum::T_T_null_call_thread_eosubrule_:{
break;
}
case T_Enum::T_T_called_thread_eosubrule_:{
break;
}
case T_Enum::T_refered_T_:{
/*109:*/
//line 1889 "/usr/local/yacco2/compiler/o2/o2_defs.w"

refered_T* rt = (refered_T*)sym;

/*:109*/
//line 1875 "/usr/local/yacco2/compiler/o2/o2_defs.w"

fe->follow_set_.insert(rt->t_in_stbl());
break;
}
}

/*:106*/
//line 1837 "/usr/local/yacco2/compiler/o2/o2_defs.w"

}
}
}
/*:105*//*113:*/
//line 1912 "/usr/local/yacco2/compiler/o2/o2_defs.w"

void state::crt_start_rule_s_follow_set(AST&Start_rule){
CAbs_lr1_sym*sym= AST::content(Start_rule);
rule_def* rd = (rule_def*)sym;;
RULE_ENO rno= rd->enum_id();
follow_element*fe= new follow_element(this);
fe->rule_no_= rno;
state_s_follow_set_map_[rno]= fe;
fe->rule_def_t_= rd->rule_s_tree();
if(O2_PP_PHASE==0){
fe->follow_set_.insert(STBL_T_ITEMS[LR1_EOLR]);
}else{
T_parallel_parser_phrase*pp_ph= O2_PP_PHASE;
T_parallel_la_boundary*la= pp_ph->la_bndry();
LA_SET_ITER_type i= la->la_first_set()->begin();
LA_SET_ITER_type ie= la->la_first_set()->end();
for(;i!=ie;++i){
T_in_stbl*t= *i;
FOLLOW_SETS_ITER_type j= fe->follow_set_.find(t);
if(j==fe->follow_set_.end()){
fe->follow_set_.insert(t);
}
}
}

}

/*:113*//*115:*/
//line 1941 "/usr/local/yacco2/compiler/o2/o2_defs.w"

const char*state::entry_symbol_literal(){
if(vectored_into_by_elem_sym_==0)return" No symbol";
/*116:*/
//line 1949 "/usr/local/yacco2/compiler/o2/o2_defs.w"

Voc_ENO id= vectored_into_by_elem_sym_->enumerated_id__;
CAbs_lr1_sym*sym= vectored_into_by_elem_sym_;
switch(id){
case T_Enum::T_rule_def_:{
rule_def* rd = (rule_def*)sym;
return rd->rule_name()->c_str();
}
case T_Enum::T_T_eosubrule_:{
return"eos";
break;
}
case T_Enum::T_T_null_call_thread_eosubrule_:{
return"null-eos";
break;
}
case T_Enum::T_T_called_thread_eosubrule_:{
return"called-thd-eos";
break;
}
case T_Enum::T_T_terminal_def_:{
T_terminal_def* td = (T_terminal_def*)sym;
return td->t_name()->c_str();
}
default:{
return"null-eos";
break;
}
}

/*:116*/
//line 1944 "/usr/local/yacco2/compiler/o2/o2_defs.w"

}

/*:115*/
//line 2217 "/usr/local/yacco2/compiler/o2/o2_defs.w"

//line 1 "/usr/local/yacco2/compiler/o2/bugs.w"








/*:141*/