/*450:*/ //#line 235 "/usr/local/yacco2/library/tree.w" /*565:*/ //#line 24 "/usr/local/yacco2/library/macros.w" /*:565*/ //#line 236 "/usr/local/yacco2/library/tree.w" /*26:*/ //#line 404 "/usr/local/yacco2/library/intro.w" #include "yacco2.h" /*:26*/ //#line 237 "/usr/local/yacco2/library/tree.w" /*451:*/ //#line 241 "/usr/local/yacco2/library/tree.w" /*:451*//*452:*/ //#line 244 "/usr/local/yacco2/library/tree.w" yacco2::ast_base_stack:: ast_base_stack(Type_AST_functor*Action,yacco2::int_set_type*Filter,bool Accept_opt) :idx_(No_Token_start_pos) ,stk_(std::vector ()) ,action_(Action) ,cur_stk_rec_(0) ,filter_(Filter) ,accept_opt_(Accept_opt){} yacco2::ast_base_stack:: ast_base_stack() :idx_(No_Token_start_pos) ,stk_(std::vector ()) ,action_(0) ,cur_stk_rec_(0) ,filter_(0) ,accept_opt_(YES){} yacco2::ast_stack:: ast_stack(Type_AST_functor*Action,yacco2::int_set_type*Filter,bool Accept_opt) :base_stk_(Action,Filter,Accept_opt){} void yacco2::ast_base_stack:: pop(){ if(stk_.empty()==YES)return; --idx_; stk_.pop_back(); if(stk_.empty()==YES){ idx_= No_Token_start_pos; cur_stk_rec_= 0; return; } cur_stk_rec_= &stk_[idx_]; } void yacco2::ast_base_stack:: push(AST&Node,ast_base_stack::n_action Action){ ++idx_; stk_.push_back(yacco2::ast_base_stack::s_rec()); cur_stk_rec_= &stk_[idx_]; cur_stk_rec_->node_= &Node; cur_stk_rec_->act_= Action; } yacco2::INT yacco2::ast_base_stack:: cur_stk_index(){ return idx_; } yacco2::ast_base_stack::s_rec* yacco2::ast_base_stack:: cur_stk_rec(){ return cur_stk_rec_; } yacco2::ast_base_stack::s_rec* yacco2::ast_base_stack:: stk_rec(yacco2::INT I){ if(I> idx_)return 0; return&stk_[I]; } /*:452*//*454:*/ //#line 313 "/usr/local/yacco2/library/tree.w" yacco2::ast_postfix:: ast_postfix(AST&Forest,Type_AST_functor*Action ,yacco2::int_set_type*Filter,bool Accept_opt) :yacco2::ast_stack(Action,Filter,Accept_opt){ base_stk_.push(Forest,ast_base_stack::init); } /*:454*//*455:*/ //#line 325 "/usr/local/yacco2/library/tree.w" void yacco2::ast_postfix:: exec(){ /*435:*/ //#line 80 "/usr/local/yacco2/library/tree.w" advance(); int_set_iter_type i; CAbs_lr1_sym*sym; tree_traverse:{ if(base_stk_.cur_stk_rec_==0)return; if(base_stk_.cur_stk_rec_->act_!=ast_base_stack::visit){ /*437:*/ //#line 113 "/usr/local/yacco2/library/tree.w" goto next_t; /*:437*/ //#line 87 "/usr/local/yacco2/library/tree.w" } sym= AST::content(*base_stk_.cur_stk_rec_->node_); if(base_stk_.filter_==0)/*438:*/ //#line 116 "/usr/local/yacco2/library/tree.w" goto accept_t; /*:438*/ //#line 90 "/usr/local/yacco2/library/tree.w" filter_node: /*442:*/ //#line 143 "/usr/local/yacco2/library/tree.w" i= base_stk_.filter_->find(sym->enumerated_id__); /*:442*/ //#line 92 "/usr/local/yacco2/library/tree.w" /*436:*/ //#line 107 "/usr/local/yacco2/library/tree.w" if(base_stk_.accept_opt_==true) goto accept_filter; else goto reject_filter; /*:436*/ //#line 93 "/usr/local/yacco2/library/tree.w" reject_filter: /*441:*/ //#line 137 "/usr/local/yacco2/library/tree.w" if(i!=base_stk_.filter_->end())/*437:*/ //#line 113 "/usr/local/yacco2/library/tree.w" goto next_t; /*:437*/ //#line 138 "/usr/local/yacco2/library/tree.w" /*438:*/ //#line 116 "/usr/local/yacco2/library/tree.w" goto accept_t; /*:438*/ //#line 139 "/usr/local/yacco2/library/tree.w" /*:441*/ //#line 95 "/usr/local/yacco2/library/tree.w" accept_filter: /*440:*/ //#line 131 "/usr/local/yacco2/library/tree.w" if(i==base_stk_.filter_->end())/*437:*/ //#line 113 "/usr/local/yacco2/library/tree.w" goto next_t; /*:437*/ //#line 132 "/usr/local/yacco2/library/tree.w" /*438:*/ //#line 116 "/usr/local/yacco2/library/tree.w" goto accept_t; /*:438*/ //#line 133 "/usr/local/yacco2/library/tree.w" /*:440*/ //#line 97 "/usr/local/yacco2/library/tree.w" next_t: advance(); goto tree_traverse; } accept_t: /*439:*/ //#line 119 "/usr/local/yacco2/library/tree.w" yacco2::functor_result_type rr= base_stk_.action_->operator()(&base_stk_); switch(rr){ case yacco2::bypass_node:goto next_t; case yacco2::accept_node:return; case yacco2::stop_walking:{ base_stk_.cur_stk_rec_= 0; return; } } /*:439*/ //#line 103 "/usr/local/yacco2/library/tree.w" return; /*:435*/ //#line 329 "/usr/local/yacco2/library/tree.w" } /*:455*//*456:*/ //#line 334 "/usr/local/yacco2/library/tree.w" void yacco2::ast_postfix:: advance(){ if(base_stk_.cur_stk_rec_==0)return; switch(base_stk_.cur_stk_rec_->act_){ case ast_base_stack::init:{ AST*down= AST::get_1st_son(*base_stk_.cur_stk_rec_->node_); if(down==0){ base_stk_.cur_stk_rec_->act_= ast_base_stack::visit; return; } base_stk_.cur_stk_rec_->act_= ast_base_stack::left; base_stk_.push(*down,ast_base_stack::init); return; } case ast_base_stack::left:{ base_stk_.cur_stk_rec_->act_= ast_base_stack::visit; return; } case ast_base_stack::visit:{ AST*rt= AST::brother(*base_stk_.cur_stk_rec_->node_); if(rt==0){ base_stk_.cur_stk_rec_->act_= ast_base_stack::eoc; return; } base_stk_.pop(); base_stk_.push(*rt,ast_base_stack::init); return; } case ast_base_stack::right:{ base_stk_.cur_stk_rec_->act_= ast_base_stack::eoc; return; } case ast_base_stack::eoc:{ base_stk_.pop(); return; } } } /*:456*//*457:*/ //#line 377 "/usr/local/yacco2/library/tree.w" yacco2::ast_prefix:: ast_prefix(AST&Forest,Type_AST_functor*Action ,yacco2::int_set_type*Filter,bool Accept_opt) :yacco2::ast_stack(Action,Filter,Accept_opt){ base_stk_.push(Forest,ast_base_stack::init); } /*:457*//*458:*/ //#line 386 "/usr/local/yacco2/library/tree.w" void yacco2::ast_prefix:: exec(){ /*435:*/ //#line 80 "/usr/local/yacco2/library/tree.w" advance(); int_set_iter_type i; CAbs_lr1_sym*sym; tree_traverse:{ if(base_stk_.cur_stk_rec_==0)return; if(base_stk_.cur_stk_rec_->act_!=ast_base_stack::visit){ /*437:*/ //#line 113 "/usr/local/yacco2/library/tree.w" goto next_t; /*:437*/ //#line 87 "/usr/local/yacco2/library/tree.w" } sym= AST::content(*base_stk_.cur_stk_rec_->node_); if(base_stk_.filter_==0)/*438:*/ //#line 116 "/usr/local/yacco2/library/tree.w" goto accept_t; /*:438*/ //#line 90 "/usr/local/yacco2/library/tree.w" filter_node: /*442:*/ //#line 143 "/usr/local/yacco2/library/tree.w" i= base_stk_.filter_->find(sym->enumerated_id__); /*:442*/ //#line 92 "/usr/local/yacco2/library/tree.w" /*436:*/ //#line 107 "/usr/local/yacco2/library/tree.w" if(base_stk_.accept_opt_==true) goto accept_filter; else goto reject_filter; /*:436*/ //#line 93 "/usr/local/yacco2/library/tree.w" reject_filter: /*441:*/ //#line 137 "/usr/local/yacco2/library/tree.w" if(i!=base_stk_.filter_->end())/*437:*/ //#line 113 "/usr/local/yacco2/library/tree.w" goto next_t; /*:437*/ //#line 138 "/usr/local/yacco2/library/tree.w" /*438:*/ //#line 116 "/usr/local/yacco2/library/tree.w" goto accept_t; /*:438*/ //#line 139 "/usr/local/yacco2/library/tree.w" /*:441*/ //#line 95 "/usr/local/yacco2/library/tree.w" accept_filter: /*440:*/ //#line 131 "/usr/local/yacco2/library/tree.w" if(i==base_stk_.filter_->end())/*437:*/ //#line 113 "/usr/local/yacco2/library/tree.w" goto next_t; /*:437*/ //#line 132 "/usr/local/yacco2/library/tree.w" /*438:*/ //#line 116 "/usr/local/yacco2/library/tree.w" goto accept_t; /*:438*/ //#line 133 "/usr/local/yacco2/library/tree.w" /*:440*/ //#line 97 "/usr/local/yacco2/library/tree.w" next_t: advance(); goto tree_traverse; } accept_t: /*439:*/ //#line 119 "/usr/local/yacco2/library/tree.w" yacco2::functor_result_type rr= base_stk_.action_->operator()(&base_stk_); switch(rr){ case yacco2::bypass_node:goto next_t; case yacco2::accept_node:return; case yacco2::stop_walking:{ base_stk_.cur_stk_rec_= 0; return; } } /*:439*/ //#line 103 "/usr/local/yacco2/library/tree.w" return; /*:435*/ //#line 390 "/usr/local/yacco2/library/tree.w" } /*:458*//*459:*/ //#line 394 "/usr/local/yacco2/library/tree.w" void yacco2::ast_prefix:: advance(){ if(base_stk_.cur_stk_rec_==0)return; switch(base_stk_.cur_stk_rec_->act_){ case ast_base_stack::init:{ base_stk_.cur_stk_rec_->act_= ast_base_stack::visit; return; } case ast_base_stack::left:{ AST*rt= AST::brother(*base_stk_.cur_stk_rec_->node_); if(rt!=0){ base_stk_.pop(); base_stk_.push(*rt,ast_base_stack::init); return; } base_stk_.cur_stk_rec_->act_= ast_base_stack::eoc; return; } case ast_base_stack::visit:{ AST*lt= AST::get_1st_son(*base_stk_.cur_stk_rec_->node_); if(lt!=0){ base_stk_.cur_stk_rec_->act_= ast_base_stack::left; base_stk_.push(*lt,ast_base_stack::init); return; } AST*rt= AST::brother(*base_stk_.cur_stk_rec_->node_); if(rt!=0){ base_stk_.pop(); base_stk_.push(*rt,ast_base_stack::init); return; } base_stk_.cur_stk_rec_->act_= ast_base_stack::eoc; return; } case ast_base_stack::right:{ base_stk_.cur_stk_rec_->act_= ast_base_stack::eoc; return; } case ast_base_stack::eoc:{ base_stk_.pop(); return; } } } /*:459*//*460:*/ //#line 443 "/usr/local/yacco2/library/tree.w" yacco2::ast_postfix_1forest:: ast_postfix_1forest(AST&Forest,Type_AST_functor*Action ,yacco2::int_set_type*Filter,bool Accept_opt) :yacco2::ast_stack(Action,Filter,Accept_opt){ base_stk_.push(Forest,ast_base_stack::init); } /*:460*//*461:*/ //#line 452 "/usr/local/yacco2/library/tree.w" void yacco2::ast_postfix_1forest:: exec(){ /*435:*/ //#line 80 "/usr/local/yacco2/library/tree.w" advance(); int_set_iter_type i; CAbs_lr1_sym*sym; tree_traverse:{ if(base_stk_.cur_stk_rec_==0)return; if(base_stk_.cur_stk_rec_->act_!=ast_base_stack::visit){ /*437:*/ //#line 113 "/usr/local/yacco2/library/tree.w" goto next_t; /*:437*/ //#line 87 "/usr/local/yacco2/library/tree.w" } sym= AST::content(*base_stk_.cur_stk_rec_->node_); if(base_stk_.filter_==0)/*438:*/ //#line 116 "/usr/local/yacco2/library/tree.w" goto accept_t; /*:438*/ //#line 90 "/usr/local/yacco2/library/tree.w" filter_node: /*442:*/ //#line 143 "/usr/local/yacco2/library/tree.w" i= base_stk_.filter_->find(sym->enumerated_id__); /*:442*/ //#line 92 "/usr/local/yacco2/library/tree.w" /*436:*/ //#line 107 "/usr/local/yacco2/library/tree.w" if(base_stk_.accept_opt_==true) goto accept_filter; else goto reject_filter; /*:436*/ //#line 93 "/usr/local/yacco2/library/tree.w" reject_filter: /*441:*/ //#line 137 "/usr/local/yacco2/library/tree.w" if(i!=base_stk_.filter_->end())/*437:*/ //#line 113 "/usr/local/yacco2/library/tree.w" goto next_t; /*:437*/ //#line 138 "/usr/local/yacco2/library/tree.w" /*438:*/ //#line 116 "/usr/local/yacco2/library/tree.w" goto accept_t; /*:438*/ //#line 139 "/usr/local/yacco2/library/tree.w" /*:441*/ //#line 95 "/usr/local/yacco2/library/tree.w" accept_filter: /*440:*/ //#line 131 "/usr/local/yacco2/library/tree.w" if(i==base_stk_.filter_->end())/*437:*/ //#line 113 "/usr/local/yacco2/library/tree.w" goto next_t; /*:437*/ //#line 132 "/usr/local/yacco2/library/tree.w" /*438:*/ //#line 116 "/usr/local/yacco2/library/tree.w" goto accept_t; /*:438*/ //#line 133 "/usr/local/yacco2/library/tree.w" /*:440*/ //#line 97 "/usr/local/yacco2/library/tree.w" next_t: advance(); goto tree_traverse; } accept_t: /*439:*/ //#line 119 "/usr/local/yacco2/library/tree.w" yacco2::functor_result_type rr= base_stk_.action_->operator()(&base_stk_); switch(rr){ case yacco2::bypass_node:goto next_t; case yacco2::accept_node:return; case yacco2::stop_walking:{ base_stk_.cur_stk_rec_= 0; return; } } /*:439*/ //#line 103 "/usr/local/yacco2/library/tree.w" return; /*:435*/ //#line 456 "/usr/local/yacco2/library/tree.w" } /*:461*//*462:*/ //#line 460 "/usr/local/yacco2/library/tree.w" void yacco2::ast_postfix_1forest:: advance(){ if(base_stk_.cur_stk_rec_==0)return; switch(base_stk_.cur_stk_rec_->act_){ case ast_base_stack::init:{ AST*down= AST::get_1st_son(*base_stk_.cur_stk_rec_->node_); if(down==0){ base_stk_.cur_stk_rec_->act_= ast_base_stack::visit; return; } base_stk_.cur_stk_rec_->act_= ast_base_stack::left; base_stk_.push(*down,ast_base_stack::init); return; } case ast_base_stack::left:{ base_stk_.cur_stk_rec_->act_= ast_base_stack::visit; return; } case ast_base_stack::visit:{ AST*rt(0); if(base_stk_.idx_!=0) rt= AST::brother(*base_stk_.cur_stk_rec_->node_); if(rt==0){ base_stk_.cur_stk_rec_->act_= ast_base_stack::eoc; return; } base_stk_.pop(); base_stk_.push(*rt,ast_base_stack::init); return; } case ast_base_stack::right:{ base_stk_.cur_stk_rec_->act_= ast_base_stack::eoc; return; } case ast_base_stack::eoc:{ base_stk_.pop(); return; } } } /*:462*//*463:*/ //#line 505 "/usr/local/yacco2/library/tree.w" yacco2::ast_prefix_1forest:: ast_prefix_1forest(AST&Forest,Type_AST_functor*Action ,yacco2::int_set_type*Filter,bool Accept_opt) :yacco2::ast_stack(Action,Filter,Accept_opt){ base_stk_.push(Forest,ast_base_stack::init); } /*:463*//*464:*/ //#line 514 "/usr/local/yacco2/library/tree.w" void yacco2::ast_prefix_1forest:: exec(){ /*435:*/ //#line 80 "/usr/local/yacco2/library/tree.w" advance(); int_set_iter_type i; CAbs_lr1_sym*sym; tree_traverse:{ if(base_stk_.cur_stk_rec_==0)return; if(base_stk_.cur_stk_rec_->act_!=ast_base_stack::visit){ /*437:*/ //#line 113 "/usr/local/yacco2/library/tree.w" goto next_t; /*:437*/ //#line 87 "/usr/local/yacco2/library/tree.w" } sym= AST::content(*base_stk_.cur_stk_rec_->node_); if(base_stk_.filter_==0)/*438:*/ //#line 116 "/usr/local/yacco2/library/tree.w" goto accept_t; /*:438*/ //#line 90 "/usr/local/yacco2/library/tree.w" filter_node: /*442:*/ //#line 143 "/usr/local/yacco2/library/tree.w" i= base_stk_.filter_->find(sym->enumerated_id__); /*:442*/ //#line 92 "/usr/local/yacco2/library/tree.w" /*436:*/ //#line 107 "/usr/local/yacco2/library/tree.w" if(base_stk_.accept_opt_==true) goto accept_filter; else goto reject_filter; /*:436*/ //#line 93 "/usr/local/yacco2/library/tree.w" reject_filter: /*441:*/ //#line 137 "/usr/local/yacco2/library/tree.w" if(i!=base_stk_.filter_->end())/*437:*/ //#line 113 "/usr/local/yacco2/library/tree.w" goto next_t; /*:437*/ //#line 138 "/usr/local/yacco2/library/tree.w" /*438:*/ //#line 116 "/usr/local/yacco2/library/tree.w" goto accept_t; /*:438*/ //#line 139 "/usr/local/yacco2/library/tree.w" /*:441*/ //#line 95 "/usr/local/yacco2/library/tree.w" accept_filter: /*440:*/ //#line 131 "/usr/local/yacco2/library/tree.w" if(i==base_stk_.filter_->end())/*437:*/ //#line 113 "/usr/local/yacco2/library/tree.w" goto next_t; /*:437*/ //#line 132 "/usr/local/yacco2/library/tree.w" /*438:*/ //#line 116 "/usr/local/yacco2/library/tree.w" goto accept_t; /*:438*/ //#line 133 "/usr/local/yacco2/library/tree.w" /*:440*/ //#line 97 "/usr/local/yacco2/library/tree.w" next_t: advance(); goto tree_traverse; } accept_t: /*439:*/ //#line 119 "/usr/local/yacco2/library/tree.w" yacco2::functor_result_type rr= base_stk_.action_->operator()(&base_stk_); switch(rr){ case yacco2::bypass_node:goto next_t; case yacco2::accept_node:return; case yacco2::stop_walking:{ base_stk_.cur_stk_rec_= 0; return; } } /*:439*/ //#line 103 "/usr/local/yacco2/library/tree.w" return; /*:435*/ //#line 518 "/usr/local/yacco2/library/tree.w" } /*:464*//*465:*/ //#line 522 "/usr/local/yacco2/library/tree.w" void yacco2::ast_prefix_1forest:: advance(){ if(base_stk_.cur_stk_rec_==0)return; switch(base_stk_.cur_stk_rec_->act_){ case ast_base_stack::init:{ base_stk_.cur_stk_rec_->act_= ast_base_stack::visit; return; } case ast_base_stack::left:{ AST*rt(0); if(base_stk_.idx_!=0) rt= AST::brother(*base_stk_.cur_stk_rec_->node_); if(rt!=0){ base_stk_.pop(); base_stk_.push(*rt,ast_base_stack::init); return; } base_stk_.cur_stk_rec_->act_= ast_base_stack::eoc; return; } case ast_base_stack::visit:{ AST*lt= AST::get_1st_son(*base_stk_.cur_stk_rec_->node_); if(lt!=0){ base_stk_.cur_stk_rec_->act_= ast_base_stack::left; base_stk_.push(*lt,ast_base_stack::init); return; } AST*rt(0); if(base_stk_.idx_!=0) rt= AST::brother(*base_stk_.cur_stk_rec_->node_); if(rt!=0){ base_stk_.pop(); base_stk_.push(*rt,ast_base_stack::init); return; } base_stk_.cur_stk_rec_->act_= ast_base_stack::eoc; return; } case ast_base_stack::right:{ base_stk_.cur_stk_rec_->act_= ast_base_stack::eoc; return; } case ast_base_stack::eoc:{ base_stk_.pop(); return; } } } /*:465*//*466:*/ //#line 575 "/usr/local/yacco2/library/tree.w" yacco2::ast_breadth_only:: ast_breadth_only(AST&Forest,Type_AST_functor*Action ,yacco2::int_set_type*Filter,bool Accept_opt) :yacco2::ast_stack(Action,Filter,Accept_opt){ base_stk_.push(Forest,ast_base_stack::init); } /*:466*//*467:*/ //#line 584 "/usr/local/yacco2/library/tree.w" void yacco2::ast_breadth_only:: exec(){ /*435:*/ //#line 80 "/usr/local/yacco2/library/tree.w" advance(); int_set_iter_type i; CAbs_lr1_sym*sym; tree_traverse:{ if(base_stk_.cur_stk_rec_==0)return; if(base_stk_.cur_stk_rec_->act_!=ast_base_stack::visit){ /*437:*/ //#line 113 "/usr/local/yacco2/library/tree.w" goto next_t; /*:437*/ //#line 87 "/usr/local/yacco2/library/tree.w" } sym= AST::content(*base_stk_.cur_stk_rec_->node_); if(base_stk_.filter_==0)/*438:*/ //#line 116 "/usr/local/yacco2/library/tree.w" goto accept_t; /*:438*/ //#line 90 "/usr/local/yacco2/library/tree.w" filter_node: /*442:*/ //#line 143 "/usr/local/yacco2/library/tree.w" i= base_stk_.filter_->find(sym->enumerated_id__); /*:442*/ //#line 92 "/usr/local/yacco2/library/tree.w" /*436:*/ //#line 107 "/usr/local/yacco2/library/tree.w" if(base_stk_.accept_opt_==true) goto accept_filter; else goto reject_filter; /*:436*/ //#line 93 "/usr/local/yacco2/library/tree.w" reject_filter: /*441:*/ //#line 137 "/usr/local/yacco2/library/tree.w" if(i!=base_stk_.filter_->end())/*437:*/ //#line 113 "/usr/local/yacco2/library/tree.w" goto next_t; /*:437*/ //#line 138 "/usr/local/yacco2/library/tree.w" /*438:*/ //#line 116 "/usr/local/yacco2/library/tree.w" goto accept_t; /*:438*/ //#line 139 "/usr/local/yacco2/library/tree.w" /*:441*/ //#line 95 "/usr/local/yacco2/library/tree.w" accept_filter: /*440:*/ //#line 131 "/usr/local/yacco2/library/tree.w" if(i==base_stk_.filter_->end())/*437:*/ //#line 113 "/usr/local/yacco2/library/tree.w" goto next_t; /*:437*/ //#line 132 "/usr/local/yacco2/library/tree.w" /*438:*/ //#line 116 "/usr/local/yacco2/library/tree.w" goto accept_t; /*:438*/ //#line 133 "/usr/local/yacco2/library/tree.w" /*:440*/ //#line 97 "/usr/local/yacco2/library/tree.w" next_t: advance(); goto tree_traverse; } accept_t: /*439:*/ //#line 119 "/usr/local/yacco2/library/tree.w" yacco2::functor_result_type rr= base_stk_.action_->operator()(&base_stk_); switch(rr){ case yacco2::bypass_node:goto next_t; case yacco2::accept_node:return; case yacco2::stop_walking:{ base_stk_.cur_stk_rec_= 0; return; } } /*:439*/ //#line 103 "/usr/local/yacco2/library/tree.w" return; /*:435*/ //#line 588 "/usr/local/yacco2/library/tree.w" } /*:467*//*468:*/ //#line 592 "/usr/local/yacco2/library/tree.w" void yacco2::ast_breadth_only:: advance(){ if(base_stk_.cur_stk_rec_==0)return; switch(base_stk_.cur_stk_rec_->act_){ case ast_base_stack::init:{ base_stk_.cur_stk_rec_->act_= ast_base_stack::visit; return; } case ast_base_stack::left:{ AST*rt= AST::brother(*base_stk_.cur_stk_rec_->node_); if(rt!=0){ base_stk_.pop(); base_stk_.push(*rt,ast_base_stack::init); return; } base_stk_.cur_stk_rec_->act_= ast_base_stack::eoc; return; } case ast_base_stack::visit:{ AST*rt= AST::brother(*base_stk_.cur_stk_rec_->node_); if(rt!=0){ base_stk_.pop(); base_stk_.push(*rt,ast_base_stack::init); return; } base_stk_.cur_stk_rec_->act_= ast_base_stack::eoc; return; } case ast_base_stack::right:{ base_stk_.cur_stk_rec_->act_= ast_base_stack::eoc; return; } case ast_base_stack::eoc:{ base_stk_.pop(); return; } } } /*:468*//*469:*/ //#line 635 "/usr/local/yacco2/library/tree.w" yacco2::ast_prefix_wbreadth_only:: ast_prefix_wbreadth_only(AST&Forest,Type_AST_functor*Action ,yacco2::int_set_type*Filter,bool Accept_opt) :yacco2::ast_stack(Action,Filter,Accept_opt){ base_stk_.push(Forest,ast_base_stack::init); } /*:469*//*470:*/ //#line 644 "/usr/local/yacco2/library/tree.w" void yacco2::ast_prefix_wbreadth_only:: exec(){ /*435:*/ //#line 80 "/usr/local/yacco2/library/tree.w" advance(); int_set_iter_type i; CAbs_lr1_sym*sym; tree_traverse:{ if(base_stk_.cur_stk_rec_==0)return; if(base_stk_.cur_stk_rec_->act_!=ast_base_stack::visit){ /*437:*/ //#line 113 "/usr/local/yacco2/library/tree.w" goto next_t; /*:437*/ //#line 87 "/usr/local/yacco2/library/tree.w" } sym= AST::content(*base_stk_.cur_stk_rec_->node_); if(base_stk_.filter_==0)/*438:*/ //#line 116 "/usr/local/yacco2/library/tree.w" goto accept_t; /*:438*/ //#line 90 "/usr/local/yacco2/library/tree.w" filter_node: /*442:*/ //#line 143 "/usr/local/yacco2/library/tree.w" i= base_stk_.filter_->find(sym->enumerated_id__); /*:442*/ //#line 92 "/usr/local/yacco2/library/tree.w" /*436:*/ //#line 107 "/usr/local/yacco2/library/tree.w" if(base_stk_.accept_opt_==true) goto accept_filter; else goto reject_filter; /*:436*/ //#line 93 "/usr/local/yacco2/library/tree.w" reject_filter: /*441:*/ //#line 137 "/usr/local/yacco2/library/tree.w" if(i!=base_stk_.filter_->end())/*437:*/ //#line 113 "/usr/local/yacco2/library/tree.w" goto next_t; /*:437*/ //#line 138 "/usr/local/yacco2/library/tree.w" /*438:*/ //#line 116 "/usr/local/yacco2/library/tree.w" goto accept_t; /*:438*/ //#line 139 "/usr/local/yacco2/library/tree.w" /*:441*/ //#line 95 "/usr/local/yacco2/library/tree.w" accept_filter: /*440:*/ //#line 131 "/usr/local/yacco2/library/tree.w" if(i==base_stk_.filter_->end())/*437:*/ //#line 113 "/usr/local/yacco2/library/tree.w" goto next_t; /*:437*/ //#line 132 "/usr/local/yacco2/library/tree.w" /*438:*/ //#line 116 "/usr/local/yacco2/library/tree.w" goto accept_t; /*:438*/ //#line 133 "/usr/local/yacco2/library/tree.w" /*:440*/ //#line 97 "/usr/local/yacco2/library/tree.w" next_t: advance(); goto tree_traverse; } accept_t: /*439:*/ //#line 119 "/usr/local/yacco2/library/tree.w" yacco2::functor_result_type rr= base_stk_.action_->operator()(&base_stk_); switch(rr){ case yacco2::bypass_node:goto next_t; case yacco2::accept_node:return; case yacco2::stop_walking:{ base_stk_.cur_stk_rec_= 0; return; } } /*:439*/ //#line 103 "/usr/local/yacco2/library/tree.w" return; /*:435*/ //#line 648 "/usr/local/yacco2/library/tree.w" } /*:470*//*471:*/ //#line 652 "/usr/local/yacco2/library/tree.w" void yacco2::ast_prefix_wbreadth_only:: advance(){ if(base_stk_.cur_stk_rec_==0)return; switch(base_stk_.cur_stk_rec_->act_){ case ast_base_stack::init:{ base_stk_.cur_stk_rec_->act_= ast_base_stack::visit; return; } case ast_base_stack::left:{ if(base_stk_.idx_==0){ base_stk_.cur_stk_rec_->act_= ast_base_stack::eoc; return; } AST*rt= AST::brother(*base_stk_.cur_stk_rec_->node_); if(rt!=0){ base_stk_.pop(); base_stk_.push(*rt,ast_base_stack::init); return; } base_stk_.cur_stk_rec_->act_= ast_base_stack::eoc; return; } case ast_base_stack::visit:{ if(base_stk_.idx_==0){ AST*lt= AST::get_1st_son(*base_stk_.cur_stk_rec_->node_); if(lt==0){ base_stk_.cur_stk_rec_->act_= ast_base_stack::eoc; return; } base_stk_.cur_stk_rec_->act_= ast_base_stack::left; base_stk_.push(*lt,ast_base_stack::init); return; } AST*rt= AST::brother(*base_stk_.cur_stk_rec_->node_); if(rt!=0){ base_stk_.pop(); base_stk_.push(*rt,ast_base_stack::init); return; } base_stk_.cur_stk_rec_->act_= ast_base_stack::eoc; return; } case ast_base_stack::right:{ base_stk_.cur_stk_rec_->act_= ast_base_stack::eoc; return; } case ast_base_stack::eoc:{ base_stk_.pop(); return; } } } /*:471*//*472:*/ //#line 707 "/usr/local/yacco2/library/tree.w" yacco2::ast_moonwalk_looking_for_ancestors::ast_moonwalk_looking_for_ancestors (AST&Moonchild,USINT Goal,Type_AST_ancestor_list&Ancestors_list,Type_AST_functor*Functor ,yacco2::int_set_type*Filter,bool Accept_opt) :moonchild_(&Moonchild) ,goal_(Goal) ,ancestor_list_(&Ancestors_list) ,functor_(Functor) ,filter_(Filter) ,filter_type_(Accept_opt) ,filter_provided_(NO) { if(Filter!=0)filter_provided_= YES; } /*:472*//*473:*/ //#line 724 "/usr/local/yacco2/library/tree.w" yacco2::functor_result_type yacco2::ast_moonwalk_looking_for_ancestors::let_s_functor(AST*Parent) { functor_result_type functor_result; yacco2::ast_base_stack abs; abs.push(*Parent,ast_base_stack::init); return functor_->operator()(&abs); } /*:473*//*474:*/ //#line 738 "/usr/local/yacco2/library/tree.w" bool yacco2::ast_moonwalk_looking_for_ancestors::deal_with_functor(AST*Parent) { if(functor_!=0){ functor_result_type functor_result= let_s_functor(Parent); switch(functor_result){ case accept_node:{ ancestor_list_->push_back(Parent); return YES; } case bypass_node:{ return YES; } case stop_walking:{ return NO; } } }else{ ancestor_list_->push_back(Parent); return YES; } return YES; } /*:474*//*475:*/ //#line 765 "/usr/local/yacco2/library/tree.w" void yacco2::ast_moonwalk_looking_for_ancestors::let_s_moonwalk() { functor_result_type functor_result; AST*cnode= moonchild_; AST*parent(0); while(cnode!=0){ parent= AST::get_parent(*cnode); bool continue_waldo= deal_with_parent(parent); if(continue_waldo==NO)return; cnode= parent; } } /*:475*//*476:*/ //#line 782 "/usr/local/yacco2/library/tree.w" bool yacco2::ast_moonwalk_looking_for_ancestors::deal_with_parent(AST*Parent) { if(Parent==0){ return NO; } CAbs_lr1_sym*tsym= AST::content(*Parent); USINT id= tsym->enumerated_id(); if(id==goal_){ ancestor_list_->push_back(Parent); return NO; } /*477:*/ //#line 812 "/usr/local/yacco2/library/tree.w" if(filter_provided_==NO)goto no_filter_so_accept_all_Tes; else goto filtered_Tes; /*:477*/ //#line 795 "/usr/local/yacco2/library/tree.w" no_filter_so_accept_all_Tes:{ return deal_with_functor(Parent); } filtered_Tes:{ int_set_iter_type i= filter_->find(id); if(i==filter_->end()){ if(filter_type_==ACCEPT_FILTER)return YES; return deal_with_functor(Parent); } if(filter_type_==BYPASS_FILTER)return YES; return deal_with_functor(Parent); } } /*:476*//*479:*/ //#line 819 "/usr/local/yacco2/library/tree.w" yacco2::AST*yacco2::AST:: restructure_2trees_into_1tree(AST&S1,AST&S2){ AST*s2lt= AST::get_1st_son(S2); AST::zero_1st_son(S2); AST::crt_tree_of_2sons(S2,S1,*s2lt); return&S2; } /*:479*//*480:*/ //#line 828 "/usr/local/yacco2/library/tree.w" void yacco2::AST:: crt_tree_of_1son(yacco2::AST&Parent,yacco2::AST&S1){ yacco2::AST::join_pts(Parent,S1); } void yacco2::AST:: crt_tree_of_2sons(yacco2::AST&Parent,yacco2::AST&S1,yacco2::AST&S2){ yacco2::AST::join_pts(Parent,S1); yacco2::AST::join_sts(S1,S2); } void yacco2::AST:: crt_tree_of_3sons(yacco2::AST&Parent,yacco2::AST&S1,yacco2::AST&S2,yacco2::AST&S3){ yacco2::AST::join_pts(Parent,S1); yacco2::AST::join_sts(S1,S2); yacco2::AST::join_sts(S2,S3); } void yacco2::AST:: crt_tree_of_4sons(yacco2::AST&Parent,yacco2::AST&S1,yacco2::AST&S2,yacco2::AST&S3 ,yacco2::AST&S4){ yacco2::AST::join_pts(Parent,S1); yacco2::AST::join_sts(S1,S2); yacco2::AST::join_sts(S2,S3); yacco2::AST::join_sts(S3,S4); } void yacco2::AST:: crt_tree_of_5sons(yacco2::AST&Parent,AST&S1,yacco2::AST&S2,yacco2::AST&S3, yacco2::AST&S4,yacco2::AST&S5){ yacco2::AST::join_pts(Parent,S1); yacco2::AST::join_sts(S1,S2); yacco2::AST::join_sts(S2,S3); yacco2::AST::join_sts(S3,S4); yacco2::AST::join_sts(S4,S5); } void yacco2::AST:: crt_tree_of_6sons(yacco2::AST&Parent,yacco2::AST&S1,yacco2::AST&S2,yacco2::AST&S3 ,yacco2::AST&S4,yacco2::AST&S5,yacco2::AST&S6){ yacco2::AST::join_pts(Parent,S1); yacco2::AST::join_sts(S1,S2); yacco2::AST::join_sts(S2,S3); yacco2::AST::join_sts(S3,S4); yacco2::AST::join_sts(S4,S5); yacco2::AST::join_sts(S5,S6); } void yacco2::AST:: crt_tree_of_7sons(yacco2::AST&Parent,yacco2::AST&S1,yacco2::AST&S2,yacco2::AST&S3 ,yacco2::AST&S4,yacco2::AST&S5,yacco2::AST&S6,yacco2::AST&S7){ yacco2::AST::join_pts(Parent,S1); yacco2::AST::join_sts(S1,S2); yacco2::AST::join_sts(S2,S3); yacco2::AST::join_sts(S3,S4); yacco2::AST::join_sts(S4,S5); yacco2::AST::join_sts(S5,S6); yacco2::AST::join_sts(S6,S7); } void yacco2::AST:: crt_tree_of_8sons(yacco2::AST&Parent,yacco2::AST&S1,yacco2::AST&S2,yacco2::AST&S3 ,yacco2::AST&S4,yacco2::AST&S5,yacco2::AST&S6,yacco2::AST&S7,yacco2::AST&S8){ yacco2::AST::join_pts(Parent,S1); yacco2::AST::join_sts(S1,S2); yacco2::AST::join_sts(S2,S3); yacco2::AST::join_sts(S3,S4); yacco2::AST::join_sts(S4,S5); yacco2::AST::join_sts(S5,S6); yacco2::AST::join_sts(S6,S7); yacco2::AST::join_sts(S7,S8); } void yacco2::AST:: crt_tree_of_9sons(yacco2::AST&Parent,yacco2::AST&S1,yacco2::AST&S2,yacco2::AST&S3 ,yacco2::AST&S4,yacco2::AST&S5,yacco2::AST&S6 ,yacco2::AST&S7,yacco2::AST&S8,yacco2::AST&S9){ AST::join_pts(Parent,S1); AST::join_sts(S1,S2); AST::join_sts(S2,S3); AST::join_sts(S3,S4); AST::join_sts(S4,S5); AST::join_sts(S5,S6); AST::join_sts(S6,S7); AST::join_sts(S7,S8); AST::join_sts(S8,S9); } /*:480*//*481:*/ //#line 915 "/usr/local/yacco2/library/tree.w" yacco2::CAbs_lr1_sym*yacco2::AST:: content(yacco2::AST&Node){ return Node.obj_; } /*:481*//*482:*/ //#line 922 "/usr/local/yacco2/library/tree.w" void yacco2::AST:: zero_1st_son(yacco2::AST&Node){ Node.lt_= 0; } /*:482*//*483:*/ //#line 929 "/usr/local/yacco2/library/tree.w" void yacco2::AST:: zero_2nd_son(yacco2::AST&Node){ yacco2::AST*lt= Node.lt_; if(lt==0){ yacco2::KCHARP msg= "zero_2nd_son 2nd son's 1st son Node ptr is zero"; Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } lt->rt_= 0; } /*:483*//*484:*/ //#line 943 "/usr/local/yacco2/library/tree.w" void yacco2::AST:: zero_brother(yacco2::AST&Node){ Node.rt_= 0; } /*:484*//*485:*/ //#line 949 "/usr/local/yacco2/library/tree.w" void yacco2::AST:: zero_content(yacco2::AST&Node){ Node.obj_= 0; } /*:485*//*486:*/ //#line 955 "/usr/local/yacco2/library/tree.w" void yacco2::AST:: set_content(yacco2::AST&Node,yacco2::CAbs_lr1_sym&Sym){ Node.obj_= &Sym; } /*:486*//*487:*/ //#line 961 "/usr/local/yacco2/library/tree.w" void yacco2::AST:: zero_previous(yacco2::AST&Node){ Node.pr_= 0; } /*:487*//*488:*/ //#line 967 "/usr/local/yacco2/library/tree.w" void yacco2::AST:: set_content_wdelete(yacco2::AST&Node,yacco2::CAbs_lr1_sym&Sym){ Node.obj_= &Sym; Node.wdelete_= true; } /*:488*//*489:*/ //#line 974 "/usr/local/yacco2/library/tree.w" void yacco2::AST:: set_previous(yacco2::AST&Node,yacco2::AST&Previous_node){ Node.pr_= &Previous_node; } /*:489*//*490:*/ //#line 980 "/usr/local/yacco2/library/tree.w" bool yacco2::AST:: wdelete(yacco2::AST&Node){ return Node.wdelete_; } /*:490*//*491:*/ //#line 986 "/usr/local/yacco2/library/tree.w" void yacco2::AST:: wdelete(yacco2::AST&Node,bool Wdelete){ Node.wdelete_= Wdelete; } /*:491*//*492:*/ //#line 993 "/usr/local/yacco2/library/tree.w" yacco2::AST*yacco2::AST:: brother(yacco2::AST&Node){ return Node.rt_; } /*:492*//*493:*/ //#line 1005 "/usr/local/yacco2/library/tree.w" yacco2::AST*yacco2::AST:: previous(yacco2::AST&Node){ return Node.pr_; } /*:493*//*494:*/ //#line 1012 "/usr/local/yacco2/library/tree.w" yacco2::AST:: AST():lt_(0),rt_(0),pr_(0),obj_(0),wdelete_(false){ } yacco2::AST:: AST(yacco2::CAbs_lr1_sym&Obj):lt_(0),rt_(0),pr_(0),obj_(&Obj),wdelete_(false){ } yacco2::AST::~AST(){ if(wdelete_==true){ delete obj_; } } /*:494*//*495:*/ //#line 1027 "/usr/local/yacco2/library/tree.w" void yacco2::AST:: join_pts(yacco2::AST&Parent,yacco2::AST&Child){ if(Parent.lt_!=0){ yacco2::KCHARP msg= "join_pts Parent lt ptr not zero"; Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } if(&Parent==&Child){ yacco2::KCHARP msg= "join_pts Parent and child nodes are the same"; Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } Parent.lt_= &Child; Child.pr_= &Parent; } /*:495*//*496:*/ //#line 1049 "/usr/local/yacco2/library/tree.w" void yacco2::AST:: join_sts(yacco2::AST&Elder_sibling,yacco2::AST&Younger_sibling){ if(Elder_sibling.rt_!=0){ yacco2::KCHARP msg= "join_sts Elder_sibling rt ptr not zero"; Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } if(&Elder_sibling==&Younger_sibling){ yacco2::KCHARP msg= "join_sts Left and Right nodes are the same"; Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } Elder_sibling.rt_= &Younger_sibling; Younger_sibling.pr_= &Elder_sibling; } /*:496*//*497:*/ //#line 1072 "/usr/local/yacco2/library/tree.w" void yacco2::AST:: ast_delete(yacco2::AST&Node,bool Due_to_abort){ if(YACCO2_T__!=0){ /*389:*/ //#line 3053 "/usr/local/yacco2/library/parser.w" LOCK_MUTEX(yacco2::TRACE_MU); if(yacco2::YACCO2_MU_TRACING__){ yacco2::lrclog<<"YACCO2_MU_TRACING__::Acquired trace mu"<id__<<__FILE__<<__LINE__<affected_by_abort()==true){ if(YACCO2_T__!=0){ /*389:*/ //#line 3053 "/usr/local/yacco2/library/parser.w" LOCK_MUTEX(yacco2::TRACE_MU); if(yacco2::YACCO2_MU_TRACING__){ yacco2::lrclog<<"YACCO2_MU_TRACING__::Acquired trace mu"<id__<<__FILE__<<__LINE__<enumerated_id__==Enum)return&Node; if(Node.lt_!=0){ yacco2::AST*rtn= find_depth(*Node.lt_,Enum); if(rtn!=0)return rtn; } if(Node.rt_!=0){ yacco2::AST*rtn= find_depth(*Node.rt_,Enum); if(rtn!=0)return rtn; } return 0; } /*:498*//*499:*/ //#line 1185 "/usr/local/yacco2/library/tree.w" yacco2::AST*yacco2::AST:: find_breadth(yacco2::AST&Node,yacco2::INT Enum){ if(&Node==Node.lt_){ yacco2::KCHARP msg= "find_breadth Left recursion to self Node"; Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } if(&Node==Node.rt_){ yacco2::KCHARP msg= "find_breadth Right recursion to self Node"; Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } if(Node.obj_==0){ yacco2::KCHARP msg= "find_breadth Tree's object is zero"; Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } yacco2::CAbs_lr1_sym*sym= Node.obj_; if(sym->enumerated_id__==Enum)return&Node; if(Node.rt_!=0){ yacco2::AST*rtn= find_breadth(*Node.rt_,Enum); if(rtn!=0)return rtn; } return 0; } /*:499*//*501:*/ //#line 1223 "/usr/local/yacco2/library/tree.w" void yacco2::AST:: relink(yacco2::AST&Previous,yacco2::AST&Old_to,yacco2::AST&New_to){ if(&Previous==&Old_to){ yacco2::KCHARP msg= "relink Previous ptr == Old ptr"; Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } if(&Previous==&New_to){ yacco2::KCHARP msg= "relink Previous ptr == New ptr"; Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } if(&Old_to==&New_to){ yacco2::KCHARP msg= "relink Old ptr == New ptr"; Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } if(Previous.rt_==&Old_to){ Old_to.pr_= 0; Previous.rt_= &New_to; New_to.pr_= &Previous; return; } Old_to.pr_= 0; Previous.lt_= &New_to; New_to.pr_= &Previous; } /*:501*//*502:*/ //#line 1263 "/usr/local/yacco2/library/tree.w" void yacco2::AST:: relink_between(yacco2::AST&Previous,yacco2::AST&Old_to,yacco2::AST&New_to){ if(&Previous==&Old_to){ yacco2::KCHARP msg= "relink_between Previous ptr == Old ptr"; Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } if(&Previous==&New_to){ yacco2::KCHARP msg= "relink_between Previous ptr == New ptr"; Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } if(&Old_to==&New_to){ yacco2::KCHARP msg= "relink_between Old ptr == New ptr"; Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } if(Previous.rt_==&Old_to){ Old_to.pr_= &New_to; Previous.rt_= &New_to; New_to.pr_= &Previous; New_to.rt_= &Old_to; return; } if(Previous.lt_==&Old_to){ Old_to.pr_= &New_to; Previous.lt_= &New_to; New_to.pr_= &Previous; New_to.rt_= &Old_to; return; } yacco2::KCHARP msg= "ast_relink_between Previous node does not have lt or rt of Old"; Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } /*:502*//*503:*/ //#line 1311 "/usr/local/yacco2/library/tree.w" void yacco2::AST:: relink_after(yacco2::AST&Previous,yacco2::AST&To){ if(&Previous==&To){ yacco2::KCHARP msg= "relink_after Previous ptr == To ptr"; Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } if(Previous.rt_==0){ Previous.rt_= &To; To.pr_= &Previous; return; } AST*rt= Previous.rt_; if(rt->pr_==&Previous){ rt->pr_= &To; Previous.rt_= &To; To.pr_= &Previous; To.rt_= rt; return; } yacco2::KCHARP msg= "relink_after Previous Node does not have lt or rt of Old"; Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } /*:503*//*504:*/ //#line 1344 "/usr/local/yacco2/library/tree.w" void yacco2::AST:: relink_before(yacco2::AST&Before,yacco2::AST&New_to){ if(&Before==&New_to){ yacco2::KCHARP msg= "relink_before Before ptr == New ptr"; Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } if(Before.pr_==0){ Before.pr_= &New_to; New_to.rt_= &Before; return; } yacco2::AST*pr= Before.pr_; if(pr->lt_==&Before){ pr->lt_= &New_to; New_to.pr_= pr; New_to.rt_= &Before; Before.pr_= &New_to; return; } if(pr->rt_==&Before){ pr->rt_= &New_to; New_to.pr_= pr; New_to.rt_= &Before; Before.pr_= &New_to; return; } yacco2::KCHARP msg= "relink_before Before node does not have lt or rt of Old"; Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } /*:504*//*505:*/ //#line 1384 "/usr/local/yacco2/library/tree.w" void yacco2::AST:: replace_node(yacco2::AST&Old,yacco2::AST&By){ if(&Old==&By){ yacco2::KCHARP msg= "replace_node Old ptr == By ptr"; Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } yacco2::AST*prev= Old.pr_; yacco2::AST*rt= Old.rt_; if(prev->rt_==&Old){ prev->rt_= &By; By.pr_= prev; By.rt_= rt; if(rt!=0)rt->pr_= &By; Old.rt_= 0; Old.pr_= 0; return; } if(prev->lt_==&Old){ prev->lt_= &By; By.pr_= prev; By.rt_= rt; if(rt!=0)rt->pr_= &By; Old.rt_= 0; Old.pr_= 0; return; } By.rt_= Old.rt_; Old.rt_= 0; } /*:505*//*507:*/ //#line 1424 "/usr/local/yacco2/library/tree.w" void yacco2::AST:: add_son_to_tree(yacco2::AST&Parent,yacco2::AST&Son){ AST*p_lt= Parent.lt_; if(p_lt==0){ Parent.lt_= &Son; Son.pr_= &Parent; return; } Parent.lt_= &Son; Son.pr_= &Parent; Son.rt_= p_lt; p_lt->pr_= &Son; } /*:507*//*508:*/ //#line 1440 "/usr/local/yacco2/library/tree.w" yacco2::AST*yacco2::AST::add_child_at_end(yacco2::AST&Tree,yacco2::AST&Child){ yacco2::AST*cur_youngest_child= AST::get_child_at_end(Tree); if(cur_youngest_child==0){ AST::join_pts(Tree,Child); }else{ AST::join_sts(*cur_youngest_child,Child); } return&Child; } /*:508*//*509:*/ //#line 1452 "/usr/local/yacco2/library/tree.w" yacco2::AST* yacco2::AST::get_spec_child(yacco2::AST&Tree,yacco2::INT Cnt){ if(Cnt<=0){ yacco2::KCHARP msg= "get_spec_child Node Cnt is <= 0"; Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } yacco2::INT pos(0); yacco2::AST*ct= Tree.lt_; for(;ct!=0;ct= ct->rt_){ ++pos; if(pos==Cnt)return ct; } return 0; } /*:509*//*510:*/ //#line 1472 "/usr/local/yacco2/library/tree.w" yacco2::AST*yacco2::AST:: get_1st_son(yacco2::AST&Node){ return get_spec_child(Node,1); } yacco2::AST*yacco2::AST:: get_2nd_son(yacco2::AST&Node){ return get_spec_child(Node,2); } yacco2::AST*yacco2::AST:: get_3rd_son(yacco2::AST&Node){ return get_spec_child(Node,3); } yacco2::AST*yacco2::AST:: get_4th_son(yacco2::AST&Node){ return get_spec_child(Node,4); } yacco2::AST*yacco2::AST:: get_5th_son(yacco2::AST&Node){ return get_spec_child(Node,5); } yacco2::AST*yacco2::AST::get_6th_son(yacco2::AST&Node){ return get_spec_child(Node,6); } yacco2::AST*yacco2::AST::get_7th_son(yacco2::AST&Node){ return get_spec_child(Node,7); } yacco2::AST*yacco2::AST::get_8th_son(yacco2::AST&Node){ return get_spec_child(Node,8); } yacco2::AST*yacco2::AST::get_9th_son(yacco2::AST&Node){ return get_spec_child(Node,9); } /*:510*//*511:*/ //#line 1514 "/usr/local/yacco2/library/tree.w" yacco2::AST*yacco2::AST::get_child_at_end(yacco2::AST&Tree){ yacco2::AST*ct= Tree.lt_; yacco2::AST*pct(0); for(;ct!=0;ct= ct->rt_){ pct= ct; } return pct; } /*:511*//*512:*/ //#line 1527 "/usr/local/yacco2/library/tree.w" yacco2::AST*yacco2::AST::get_youngest_sibling(yacco2::AST&Tree){ yacco2::AST*start= &Tree; yacco2::AST*younger_sibling= start; for(;younger_sibling!=0;){ if(younger_sibling->rt_==0)break; younger_sibling= younger_sibling->rt_; } if(start==younger_sibling)return 0; return younger_sibling; } /*:512*//*513:*/ //#line 1541 "/usr/local/yacco2/library/tree.w" yacco2::AST*yacco2::AST::get_younger_sibling(yacco2::AST&Child,yacco2::INT Pos){ if(Pos<=0){ yacco2::KCHARP msg= "get_younger_sibling Pos <= 0"; Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } int cnt(0); yacco2::AST*younger_sibling= Child.rt_; for(;younger_sibling!=0;younger_sibling= younger_sibling->rt_){ ++cnt; if(cnt==Pos)return younger_sibling; } return 0; } /*:513*//*514:*/ //#line 1562 "/usr/local/yacco2/library/tree.w" yacco2::AST*yacco2::AST::get_older_sibling(yacco2::AST&Child,yacco2::INT Pos){ if(Pos>=0){ yacco2::KCHARP msg= "get_older_sibling Pos >= 0"; Yacco2_faulty_precondition(msg,__FILE__,__LINE__); exit(1); } int cnt(0); AST*older_sibling= Child.pr_; for(;older_sibling!=0;older_sibling= older_sibling->pr_){ --cnt; if(cnt==Pos)return older_sibling; } return 0; } /*:514*//*515:*/ //#line 1580 "/usr/local/yacco2/library/tree.w" yacco2::AST*yacco2::AST::get_parent(yacco2::AST&Tree){ yacco2::AST*cnode= &Tree; yacco2::AST*older_sibling= cnode->pr_; for(;older_sibling!=0;cnode= older_sibling,older_sibling= cnode->pr_){ if(older_sibling->rt_!=cnode)return older_sibling; } return 0; } /*:515*//*516:*/ //#line 1591 "/usr/local/yacco2/library/tree.w" yacco2::AST*yacco2::AST::common_ancestor (yacco2::Type_AST_ancestor_list&ListA,yacco2::Type_AST_ancestor_list&ListB){ Type_AST_ancestor_list*a; Type_AST_ancestor_list*b; if(ListA.size()begin(); Type_AST_ancestor_list::iterator aie= a->end(); Type_AST_ancestor_list::iterator bi; Type_AST_ancestor_list::iterator bie; for(;ai!=aie;++ai){ bi= b->begin(); bie= b->end(); for(;bi!=bie;++bi){ AST*A= *ai; AST*B= *bi; if(A==B) return A; } } return 0; } /*:516*//*517:*/ //#line 1622 "/usr/local/yacco2/library/tree.w" yacco2::AST* yacco2::AST::divorce_node_from_tree(yacco2::AST&Node){ yacco2::AST*bpr= Node.pr_; yacco2::AST*brt= Node.rt_; /*524:*/ //#line 1690 "/usr/local/yacco2/library/tree.w" Node.pr_= 0; Node.rt_= 0; /*:524*/ //#line 1627 "/usr/local/yacco2/library/tree.w" /*518:*/ //#line 1644 "/usr/local/yacco2/library/tree.w" if(bpr==0)goto forest; if(bpr->rt_==&Node)goto amongst_brothers; if(bpr->lt_==&Node)goto parental_guidance; /*:518*/ //#line 1628 "/usr/local/yacco2/library/tree.w" forest: /*522:*/ //#line 1675 "/usr/local/yacco2/library/tree.w" if(brt==0)return 0; brt->pr_= 0; return brt; /*:522*/ //#line 1631 "/usr/local/yacco2/library/tree.w" amongst_brothers: /*523:*/ //#line 1684 "/usr/local/yacco2/library/tree.w" bpr->rt_= brt; if(brt!=0)brt->pr_= bpr; return brt; /*:523*/ //#line 1633 "/usr/local/yacco2/library/tree.w" parental_guidance: /*519:*/ //#line 1654 "/usr/local/yacco2/library/tree.w" /*520:*/ //#line 1659 "/usr/local/yacco2/library/tree.w" if(brt==0){ bpr->lt_= 0; return 0; } /*:520*/ //#line 1655 "/usr/local/yacco2/library/tree.w" /*521:*/ //#line 1666 "/usr/local/yacco2/library/tree.w" bpr->lt_= brt; brt->pr_= bpr; return brt; /*:521*/ //#line 1656 "/usr/local/yacco2/library/tree.w" /*:519*/ //#line 1635 "/usr/local/yacco2/library/tree.w" } /*:517*//*525:*/ //#line 1705 "/usr/local/yacco2/library/tree.w" yacco2::AST* yacco2::AST::clone_tree (yacco2::AST&Node_to_copy,yacco2::AST*Calling_node ,yacco2::ast_base_stack::n_action Relation){ yacco2::AST*new_t= new yacco2::AST(*yacco2::AST::content(Node_to_copy)); switch(Relation){ case ast_base_stack::init:break; case ast_base_stack::left:{ if(Calling_node!=0){ AST::join_pts(*Calling_node,*new_t); } break; } case ast_base_stack::right:{ if(Calling_node!=0){ AST::join_sts(*Calling_node,*new_t); } break; } } if(Node_to_copy.lt_!=0) AST::clone_tree(*Node_to_copy.lt_,new_t,ast_base_stack::left); if(Node_to_copy.rt_!=0) AST::clone_tree(*Node_to_copy.rt_,new_t,ast_base_stack::right); return new_t; } /*:525*//*534:*/ //#line 1844 "/usr/local/yacco2/library/tree.w" yacco2::functor_result_type yacco2::remove_unwanted_ast_functor::operator()(yacco2::ast_base_stack*Stk_env){ stk_env_= Stk_env; srec_= stk_env_->cur_stk_rec_; idx_= stk_env_->idx_; cnode_= srec_->node_; yacco2::CAbs_lr1_sym*sobj= AST::content(*cnode_); if(sobj==0)return accept_node; if(sobj->tok_co_ords__.external_file_id__<=1)return accept_node; idx_= stk_env_->idx_; if(stk_env_->idx_==0){ return accept_node; } return bypass_node; } void yacco2::remove_unwanted_ast_functor::possible_delete(){ yacco2::INT pidx= idx_-1; if(pidx<0)return; ast_base_stack::s_rec*psrec= stk_env_->stk_rec(pidx); yacco2::AST*psnode= psrec->node_; yacco2::AST*srt= AST::brother(*cnode_); switch(psrec->act_){ case ast_base_stack::left:{ if(srt!=0){ yacco2::AST::relink(*psnode,*cnode_,*srt); srec_->node_= srt; srec_->act_= ast_base_stack::init; return; } yacco2::AST::zero_1st_son(*psnode); srec_->act_= ast_base_stack::eoc; return; } case ast_base_stack::right:{ if(srt!=0){ yacco2::AST::relink(*psnode,*cnode_,*srt); srec_->node_= srt; srec_->act_= ast_base_stack::init; return; } yacco2::AST::zero_brother(*psnode); srec_->act_= ast_base_stack::eoc; return; } default:{ return; } } } yacco2::remove_unwanted_ast_functor::~remove_unwanted_ast_functor(){ } /*:534*//*535:*/ //#line 1903 "/usr/local/yacco2/library/tree.w" yacco2::functor_result_type yacco2::insert_back_recycled_items_functor::operator()(yacco2::ast_base_stack*Stk_env){ stk_env_= Stk_env; srec_= stk_env_->cur_stk_rec_; idx_= stk_env_->idx_; cnode_= srec_->node_; yacco2::CAbs_lr1_sym*top_node_sym= AST::content(*cnode_); yacco2::CAbs_lr1_sym*node_sym= AST::content(*insert_node_); if(node_sym->tok_co_ords__.rc_pos__<=top_node_sym->tok_co_ords__.rc_pos__) return accept_node; return bypass_node; } void yacco2::insert_back_recycled_items_functor::insert_node (yacco2::AST&Inode){insert_node_= &Inode;} yacco2::AST*yacco2::insert_back_recycled_items_functor::new_root(){return new_root_;} void yacco2::insert_back_recycled_items_functor::insert_before(){ if(stk_env_->idx_> 0)goto overlay; root_change: new_root_= insert_node_; overlay: srec_->node_= insert_node_; srec_->act_= ast_base_stack::right; AST::join_sts(*insert_node_,*cnode_); stk_env_->push(*cnode_,ast_base_stack::visit); adj_prev_caller: if(stk_env_->idx_==0)return; yacco2::INT pi= idx_-1; yacco2::ast_base_stack::s_rec*pcur_rec= stk_env_->stk_rec(pi); yacco2::AST*pnode= pcur_rec->node_; switch(pcur_rec->act_){ case yacco2::ast_base_stack::left:{ yacco2::AST::zero_1st_son(*pnode); yacco2::AST::join_pts(*pnode,*insert_node_); return; } case yacco2::ast_base_stack::right:{ yacco2::AST::zero_brother(*pnode); yacco2::AST::join_sts(*pnode,*insert_node_); return; } } return; } /*:535*//*536:*/ //#line 1956 "/usr/local/yacco2/library/tree.w" yacco2::functor_result_type yacco2::tok_can_ast_functor::operator()(ast_base_stack*Stk_env){ return accept_node; } /*:536*//*537:*/ //#line 1963 "/usr/local/yacco2/library/tree.w" yacco2::functor_result_type yacco2::tok_can_ast_no_stop_functor::operator()(ast_base_stack*Stk_env){ return stop_walking; } /*:537*//*538:*/ //#line 1970 "/usr/local/yacco2/library/tree.w" yacco2::functor_result_type yacco2::tok_can_ast_bypass_functor::operator()(ast_base_stack*Stk_env){ yacco2::ast_base_stack::s_rec*srec= Stk_env->cur_stk_rec_; yacco2::AST*cnode= srec->node_; yacco2::CAbs_lr1_sym*sym= AST::content(*cnode); if(sym->tok_co_ords__.external_file_id__> 1) return bypass_node; return bypass_node; } /*:538*//*539:*/ //#line 1982 "/usr/local/yacco2/library/tree.w" yacco2::functor_result_type yacco2::prt_ast_functor::operator()(yacco2::ast_base_stack*Stk_env){ stk_env_= Stk_env; srec_= stk_env_->cur_stk_rec_; idx_= stk_env_->idx_; yacco2::INT pidx= idx_-1; cnode_= srec_->node_; if(pidx<=0)goto prt_prefix; { ast_base_stack::s_rec*psrec= stk_env_->stk_rec(pidx); if(psrec->act_==ast_base_stack::left){ how_[0]= 'l'; }else{ how_[0]= 'r'; } how_[1]= 't'; how_[2]= (char)0; } prt_prefix: /*389:*/ //#line 3053 "/usr/local/yacco2/library/parser.w" LOCK_MUTEX(yacco2::TRACE_MU); if(yacco2::YACCO2_MU_TRACING__){ yacco2::lrclog<<"YACCO2_MU_TRACING__::Acquired trace mu"<stk_rec(x)->act_==ast_base_stack::left)++no_lt; for(yacco2::INT x= 0;x<=no_lt;++x)(*ofile_)<<" "; (*ofile_)<<++cnt_<<"::"<<' '; /*390:*/ //#line 3060 "/usr/local/yacco2/library/parser.w" if(yacco2::YACCO2_MU_TRACING__){ yacco2::lrclog<<"YACCO2_MU_TRACING__::Releasing trace mu"<cur_stk_rec_; idx_= stk_env_->idx_; yacco2::INT pidx= idx_-1; cnode_= srec_->node_; call_prt_func: (*a_funct_)(cnode_); return accept_node; } yacco2::fire_a_func_ast_functor::fire_a_func_ast_functor(PF Func):a_funct_(Func){} /*:540*//*541:*/ //#line 2044 "/usr/local/yacco2/library/tree.w" yacco2::functor_result_type yacco2::str_ast_functor::operator()(yacco2::ast_base_stack*Stk_env){ stk_env_= Stk_env; srec_= stk_env_->cur_stk_rec_; idx_= stk_env_->idx_; yacco2::INT pidx= idx_-1; cnode_= srec_->node_; if(pidx<=0)goto prt_prefix; { ast_base_stack::s_rec*psrec= stk_env_->stk_rec(pidx); if(psrec->act_==ast_base_stack::left){ how_[0]= 'l'; }else{ how_[0]= 'r'; } how_[1]= 't'; how_[2]= (char)0; } prt_prefix: call_prt_func: (*prt_funct_)(cnode_,this); return accept_node; } yacco2::str_ast_functor::str_ast_functor(PF Func):prt_funct_(Func){source_str_.clear();} //#line 1 "/usr/local/yacco2/library/constraints.w" /*:541*/ //#line 238 "/usr/local/yacco2/library/tree.w" /*:450*/