diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a4591b..f47b130 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ add_executable(wcc src/night/ns_stream.cpp src/night/ns_token.cpp src/night/ns_god/ns_god.cpp + src/night/str/str.cpp src/wxml/expr_lib/base.cpp src/wxml/expr_lib/bnf.cpp src/wxml/expr_lib/common.cpp diff --git a/src/include/night.h b/src/include/night.h index fcce372..0d0a699 100644 --- a/src/include/night.h +++ b/src/include/night.h @@ -263,7 +263,7 @@ namespace night namespace str { void get_token(std::string const&, int); - void path_combine( + bool path_combine( std::string const&, std::string const&, std::string& diff --git a/src/night/ns_ast_parse.cpp b/src/night/ns_ast_parse.cpp index 69acc1b..77be304 100644 --- a/src/night/ns_ast_parse.cpp +++ b/src/night/ns_ast_parse.cpp @@ -590,9 +590,9 @@ namespace night auto v16 = this->ast_expression(); v6->push_back(v16); auto v7 = this->offset_28; - // v7->offset_4; - // auto v5 = v1.offset_56; - // auto v4 = v1.offset_52; + auto v1 = v7->offset_4; + auto v5 = v1.offset_56; + auto v4 = v1.offset_52; if ( night::NS_TYPE_BOOL == v16->offset_0 || night::NS_TYPE_VAR == v16->offset_0 || night::NS_TYPE_STR == v16->offset_0 || night::NS_TYPE_NUM == v16->offset_0 || night::NS_TYPE_B_TYPE == v16->offset_0 || night::NS_TYPE_KW == v16->offset_0 || night::NS_TYPE_OP_SELF == v16->offset_0 || night::NS_TYPE_BINARY == v16->offset_0 || night::NS_TYPE_ASSIGN == v16->offset_0 || night::NS_TYPE_TERNARY == v16->offset_0 || night::NS_TYPE_OBJ_DOT == v16->offset_0 || night::NS_TYPE_OBJ_PROPERTY == v16->offset_0 || night::NS_TYPE_OBJ_SELF_OP == v16->offset_0 || night::NS_TYPE_ARRAY == v16->offset_0 || night::NS_TYPE_BRACKET == v16->offset_0 || night::NS_TYPE_CALL == v16->offset_0) { @@ -601,7 +601,7 @@ namespace night { if (";" != v2->offset_60 && v2->offset_84.find(10, 0) == -1) { - // this->offset_28->err("Expected LineFeed", , , true); + this->offset_28->err("Expected LineFeed", v4, v5, true); } } } @@ -631,11 +631,92 @@ namespace night v22->offset_60 = "(\000)\000{"; v17->push_back(v22); this->offset_28->next(); + auto v2 = this->offset_28->offset_4; + int v8 = v2.offset_52; + int v9 = v2.offset_56; auto v3 = this->offset_28->next(); + + if (!v3 || night::NS_TYPE_STR != v3->offset_0) + { + this->offset_28->err("Expected string", v8, v9, true); + } + std::string v24; + if (night::str::path_combine(this->offset_0, v3->offset_60, v24)) + { + this->offset_28->err("Expected wxs file", v8, v9, true); + } + std::string v26 = "p_" + v24; + v3->offset_60 = v26; + v17->push_back(v3); + + v22 = this->offset_24->gen_son(night::NS_TYPE_PUNC); + v22->offset_60 = ")\000{"; + v17->push_back(v22); + + this->offset_28->next(); + auto v13 = this->offset_24; + v22 = v13->gen_son(night::NS_TYPE_PUNC); + v22->offset_60 = "(\000)\000{"; + v17->push_back(v22); + + auto v14 = this->offset_24; + v22 = v14->gen_son(night::NS_TYPE_PUNC); + v22->offset_60 = ")\000{"; + v17->push_back(v22); + + auto v15 = this->offset_24; + v22 = v15->gen_son(night::NS_TYPE_PROG_NO_SEM_REQUIRE); + v22->offset_228 = v17; + v22->offset_108 = "\0"; + + auto v5 = this->offset_28->peek(); + if (!v5) + return v22; + auto v18 = v5->offset_60; + if (v18 != "[") + { + if (v18 == ".") + { + auto v6 = this->ast_obj_dot(v22); + return make_call_or_just_expression(v6); + } + return v22; + } + auto v6 = this->ast_obj_op(v22); + return this->make_call_or_just_expression(v6); } - void NSASTParse::ignore_punc(std::string const&) + void NSASTParse::ignore_punc(std::string const& a2) { - + if (!this->is_punctuation(a2)) + { + auto node = this->offset_28->peek(); + std::string v11 = " "; + int code; + if (node) + { + std::string v6 = node->offset_60; + std::string v13 = v6.substr(0, 3); + if ( + node->offset_60.length() > 3 + && v13 == night::nsv_ + ) + { + v11 = v6.substr(3); + } + else + { + v11.assign(v6); + } + code = v11.length(); + } + else + { + code = 0; + } + std::string v13 = "Unexpected identifier `" + v11 + "`"; + this->offset_28->err(v13, 0, code, false); + } + this->offset_28->next(); } } \ No newline at end of file diff --git a/src/night/str/str.cpp b/src/night/str/str.cpp index 33ff79f..79b2fed 100644 --- a/src/night/str/str.cpp +++ b/src/night/str/str.cpp @@ -8,7 +8,7 @@ namespace night { } - void path_combine(std::string const&, std::string const&, std::string&) + bool path_combine(std::string const&, std::string const&, std::string&) { } diff --git a/test/wcc.disassembly.cpp b/test/wcc.disassembly.cpp index 0430e73..ce97d19 100644 --- a/test/wcc.disassembly.cpp +++ b/test/wcc.disassembly.cpp @@ -18617,6 +18617,7 @@ unsigned __int8 **__fastcall night::NSASTParse::ast_require(int *a1) std::string::basic_string((char *)v26, (int)&night::NS_TYPE_PUNC); v22 = (unsigned __int8 **)night::NSGod::gen_son(v10, (int)v26); std::string::_M_dispose((void **)v26); + // "(\000)\000{" std::string::operator=((unsigned int *)v22 + 15, (char *)asc_5527F4); std::vector::push_back(v17, (char **)&v22); night::NSToken::next(a1[7]); @@ -18627,6 +18628,7 @@ unsigned __int8 **__fastcall night::NSASTParse::ast_require(int *a1) v3 = (char *)night::NSToken::next(v1); v11 = v3; v23 = (unsigned __int8 **)v3; + if ( !v3 || (unsigned __int8)std::operator!=((int)&night::NS_TYPE_STR, (int)v3) ) { lpuexcpta = (struct _Unwind_Exception *)a1[7]; @@ -18634,7 +18636,7 @@ unsigned __int8 **__fastcall night::NSASTParse::ast_require(int *a1) night::NSToken::err((int)lpuexcpta, (int)v26, v8, v9, 1); } v24[1] = 0; - v24[0] = (int)&v25; + v24[0] = (int)&v25; // std::string v25 = 0; if ( night::str::path_combine(a1, (_DWORD *)v11 + 15, (int)v24) ) { @@ -18645,14 +18647,17 @@ unsigned __int8 **__fastcall night::NSASTParse::ast_require(int *a1) std::operator+((int)v26, "p_", (int)v24); std::string::operator=(v23 + 15, (int)v26); std::string::_M_dispose((void **)v26); + // v23 -> v3 std::vector::push_back(v17, (char **)&v23); std::string::_M_dispose((void **)v24); + v12 = (void *)a1[6]; std::string::basic_string((char *)v26, (int)&night::NS_TYPE_PUNC); v22 = (unsigned __int8 **)night::NSGod::gen_son(v12, (int)v26); std::string::_M_dispose((void **)v26); std::string::operator=((unsigned int *)v22 + 15, (char *)&asc_5527F4[2]); std::vector::push_back(v17, (char **)&v22); + night::NSToken::next(a1[7]); v13 = (void *)a1[6]; std::string::basic_string((char *)v26, (int)&night::NS_TYPE_PUNC); @@ -18660,12 +18665,14 @@ unsigned __int8 **__fastcall night::NSASTParse::ast_require(int *a1) std::string::_M_dispose((void **)v26); std::string::operator=((unsigned int *)v22 + 15, (char *)asc_5527F4); std::vector::push_back(v17, (char **)&v22); + v14 = (void *)a1[6]; std::string::basic_string((char *)v26, (int)&night::NS_TYPE_PUNC); v22 = (unsigned __int8 **)night::NSGod::gen_son(v14, (int)v26); std::string::_M_dispose((void **)v26); std::string::operator=((unsigned int *)v22 + 15, (char *)&asc_5527F4[2]); std::vector::push_back(v17, (char **)&v22); + v15 = (void *)a1[6]; std::string::basic_string((char *)v26, (int)&night::NS_TYPE_PROG_NO_SEM_REQUIRE); v22 = (unsigned __int8 **)night::NSGod::gen_son(v15, (int)v26); @@ -18673,6 +18680,7 @@ unsigned __int8 **__fastcall night::NSASTParse::ast_require(int *a1) v4 = v22; v22[57] = (unsigned __int8 *)v17; std::string::operator=((unsigned int *)v4 + 27, (char *)&byte_551F04); + v5 = night::NSToken::peek(a1[7]); if ( !v5 ) return v22;