/* File: angled_string.cpp Date and Time: Fri Jan 30 18:55:04 2015 */ #include "angled_string.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_angled_string;// grammar's ns // first set terminals fsm_rules_reuse_table_type::fsm_rules_reuse_table_type(){ no_rules_entries_ = 2; per_rule_s_table_[0] = new Per_rule_s_reuse_table(); per_rule_s_table_[1] = new Per_rule_s_reuse_table(); } Cangled_string:: Cangled_string() :yacco2::CAbs_fsm ("angled_string.lex" ,"1.0" ,"17 Juin 2003" ,false ,"Angled string lexer: < ... > with c type escape sequences." ,"Fri Jan 30 18:55:04 2015 " ,S1_Cangled_string){ ddd_idx_ = 0; ddd_[ddd_idx_] = 0; } Cangled_string::~Cangled_string(){ for(int x = 0;x < 2;++x){ ///delete fsm_rules_reuse_table.per_rule_s_table_[x]; } } bool Cangled_string::failed(){ return false; } void Cangled_string::op(){ ddd_idx_ = 0; ddd_[ddd_idx_] = 0; } int Cangled_string::rhs_to_rules_mapping_[3] = { -1 ,0 // subrule 1 for rule 1 ,1 // subrule 2 for rule 2 }; void Cangled_string::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 Cangled_string::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; } Rangled_string::Rangled_string(yacco2::Parser* P) :CAbs_lr1_sym ("Rangled_string",0,Cangled_string::R_Rangled_string_,P,false,false){ } void Rangled_string::sr1(){ Cangled_string* fsm = (Cangled_string*) rule_info__.parser__->fsm_tbl__; CAbs_lr1_sym* sym = new T_angled_string((const char*)&fsm->ddd_); sym->set_rc(*rule_info__.parser__->start_token__,__FILE__,__LINE__); RSVP(sym); } Ropen_angle::Ropen_angle(yacco2::Parser* P) :CAbs_lr1_sym ("Ropen_angle",0,Cangled_string::R_Ropen_angle_,P,false,false){ } void Ropen_angle::sr1(){ Cangled_string* fsm = (Cangled_string*) rule_info__.parser__->fsm_tbl__; loop: switch (rule_info__.parser__->current_token()->enumerated_id__){ case T_Enum::T_raw_lf_: goto overrun; case T_Enum::T_raw_cr_: goto overrun; case T_Enum::T_LR1_eog_: goto overrun; case T_Enum::T_raw_gt_than_: goto closestr; case T_Enum::T_raw_back_slash_: goto escseq; default: goto other; } closestr:{ // end of string rule_info__.parser__->get_next_token(); return;// end of angled string } overrun:{ CAbs_lr1_sym* sym = new Err_bad_eos; sym->set_rc(*rule_info__.parser__->start_token__,__FILE__,__LINE__); RSVP(sym); rule_info__.parser__->set_stop_parse(true); return; } escseq:{ // what type of escape using namespace NS_esc_seq; Parser::parse_result result = rule_info__.parser__->start_manually_parallel_parsing(ITH_esc_seq.thd_id__); if(result == Parser::erred){ // in this case, it will not happen: here for education rule_info__.parser__->set_abort_parse(true); return; } // process returned token Caccept_parse& accept_parm = *rule_info__.parser__->arbitrated_token__; CAbs_lr1_sym* rtn_tok = accept_parm.accept_token__; int id = rtn_tok->enumerated_id__; accept_parm.accept_token__ = 0; if(id != T_Enum::T_T_esc_seq_) { RSVP(rtn_tok); return; } T_esc_seq* finc = (T_esc_seq*)(rtn_tok); fsm->copy_str_into_buffer(finc->esc_data()); rule_info__.parser__->override_current_token(*accept_parm.la_token__ ,accept_parm.la_token_pos__); delete finc; goto loop; }; other:{ fsm->copy_kstr_into_buffer(rule_info__.parser__->current_token()->id__); rule_info__.parser__->get_next_token(); goto loop; } }