/* File: c_comments.cpp Date and Time: Fri Jan 30 18:55:05 2015 */ #include "c_comments.h" using namespace NS_yacco2_T_enum;// enumerate using namespace NS_yacco2_err_symbols;// error symbols using namespace NS_yacco2_k_symbols;// lrk using namespace NS_yacco2_terminals;// terminals using namespace NS_yacco2_characters;// rc using namespace yacco2;// yacco2 library using namespace NS_c_comments;// grammar's ns // first set terminals fsm_rules_reuse_table_type::fsm_rules_reuse_table_type(){ no_rules_entries_ = 3; per_rule_s_table_[0] = new Per_rule_s_reuse_table(); per_rule_s_table_[1] = new Per_rule_s_reuse_table(); per_rule_s_table_[2] = new Per_rule_s_reuse_table(); } Cc_comments:: Cc_comments() :yacco2::CAbs_fsm ("c_comments.lex" ,"1.0" ,"17 Juin 2003" ,false ,"C++ type comments lexer." ,"Fri Jan 30 18:55:05 2015 " ,S1_Cc_comments){ ddd_idx_ = 0; ddd_[ddd_idx_] = 0; } Cc_comments::~Cc_comments(){ for(int x = 0;x < 3;++x){ ///delete fsm_rules_reuse_table.per_rule_s_table_[x]; } } bool Cc_comments::failed(){ return false; } void Cc_comments::op(){ ddd_idx_ = 0; ddd_[ddd_idx_] = 0; } int Cc_comments::rhs_to_rules_mapping_[5] = { -1 ,0 // subrule 1 for rule 1 ,0 // subrule 2 for rule 1 ,1 // subrule 3 for rule 2 ,2 // subrule 4 for rule 3 }; void Cc_comments::copy_str_into_buffer(std::string* Str){ const char* y = Str->c_str(); int x(0); for(;y[x]!=0;++x,++ddd_idx_)ddd_[ddd_idx_] = y[x]; ddd_[ddd_idx_] = 0; } void Cc_comments::copy_kstr_into_buffer(const char* Str){ const char* y = Str; int x(0); for(;y[x]!=0;++x,++ddd_idx_)ddd_[ddd_idx_] = y[x]; ddd_[ddd_idx_] = 0; } Rc_comments::Rc_comments(yacco2::Parser* P) :CAbs_lr1_sym ("Rc_comments",0,Cc_comments::R_Rc_comments_,P,false,false){ } void Rc_comments::op(){ sstrace_rulesss Cc_comments* fsm = (Cc_comments*) rule_info__.parser__->fsm_tbl__; T_comment* com = new T_comment((const char*)&fsm->ddd_); com->set_rc(*rule_info__.parser__->start_token__,__FILE__,__LINE__); RSVP(com); } Rslash_asterisk::Rslash_asterisk(yacco2::Parser* P) :CAbs_lr1_sym ("Rslash_asterisk",0,Cc_comments::R_Rslash_asterisk_,P,false,false){ } void Rslash_asterisk::sr1(){ Cc_comments* fsm = (Cc_comments*) rule_info__.parser__->fsm_tbl__; fsm->copy_kstr_into_buffer("/");// due to lex scanner fsm->copy_kstr_into_buffer("*"); loop: switch (rule_info__.parser__->current_token()->enumerated_id__){ case T_Enum::T_raw_lf_: goto other; case T_Enum::T_raw_cr_: goto cr; case T_Enum::T_LR1_eog_: goto overrun; case T_Enum::T_raw_asteric_: goto aster; default: goto other; } cr:{// cr lf? fsm->copy_kstr_into_buffer(rule_info__.parser__->current_token()->id__); rule_info__.parser__->get_next_token(); if(rule_info__.parser__->current_token()->enumerated_id__ != T_Enum::T_raw_lf_) goto loop;// not cr lf fsm->copy_kstr_into_buffer(rule_info__.parser__->current_token()->id__); rule_info__.parser__->get_next_token(); goto loop; }; aster:{ // end of k? fsm->copy_kstr_into_buffer(rule_info__.parser__->current_token()->id__); rule_info__.parser__->get_next_token(); if(rule_info__.parser__->current_token()->enumerated_id__ != T_Enum::T_raw_slash_) goto loop;// false eok fsm->copy_kstr_into_buffer(rule_info__.parser__->current_token()->id__); rule_info__.parser__->get_next_token(); return; } overrun:{ CAbs_lr1_sym* sym = new Err_comment_overrun; sym->set_rc(*rule_info__.parser__->start_token__,__FILE__,__LINE__); RSVP(sym); rule_info__.parser__->set_stop_parse(true); return; } other:{ fsm->copy_kstr_into_buffer(rule_info__.parser__->current_token()->id__); rule_info__.parser__->get_next_token(); goto loop; } } R2slash::R2slash(yacco2::Parser* P) :CAbs_lr1_sym ("R2slash",0,Cc_comments::R_R2slash_,P,false,false){ } void R2slash::sr1(){ Cc_comments* fsm = (Cc_comments*) rule_info__.parser__->fsm_tbl__; fsm->copy_kstr_into_buffer("/"); fsm->copy_kstr_into_buffer("/"); for(;;){ switch (rule_info__.parser__->current_token()->enumerated_id__){ case T_Enum::T_raw_lf_: { return; } case T_Enum::T_raw_cr_:{ return; } case T_Enum::T_LR1_eog_: return; } fsm->copy_kstr_into_buffer(rule_info__.parser__->current_token()->id__); rule_info__.parser__->get_next_token(); } }