Merge pull request #5 from msojocs/wxs

Wxs
This commit is contained in:
msojocs 2023-07-29 16:36:13 +08:00 committed by GitHub
commit bd6a8758c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 2998 additions and 357 deletions

View File

@ -30,6 +30,7 @@ add_executable(wcc
src/night/ns_stream.cpp src/night/ns_stream.cpp
src/night/ns_token.cpp src/night/ns_token.cpp
src/night/ns_god/ns_god.cpp src/night/ns_god/ns_god.cpp
src/night/str/str.cpp
src/wxml/expr_lib/base.cpp src/wxml/expr_lib/base.cpp
src/wxml/expr_lib/bnf.cpp src/wxml/expr_lib/bnf.cpp
src/wxml/expr_lib/common.cpp src/wxml/expr_lib/common.cpp

View File

@ -36,27 +36,27 @@ namespace night
extern std::string NS_TYPE_FOR; extern std::string NS_TYPE_FOR;
extern std::string NS_TYPE_IF; extern std::string NS_TYPE_IF;
extern std::string NS_TYPE_K_V; extern std::string NS_TYPE_K_V;
extern std::string NS_TYPE_OP;
extern std::string std_v_n; extern std::string std_v_n;
extern std::string std_v_v_n; extern std::string std_v_v_n;
extern std::string nsv_;
extern std::string nst_;
extern std::string NS_BUILTIN_SPACE;
extern std::string NS_BUILTIN_PUNC;
extern std::string NS_BUILTIN_OP;
extern std::string NS_BUILTIN_ALL_OP;
extern std::string NS_BUILTIN_TYPE;
extern std::string NS_BUILTIN_KW;
extern std::string NS_BUILTIN_OP_SELF;
int compile_ns(std::string const&,std::string const&,std::string const&,uint,std::string&,bool); int compile_ns(std::string const&,std::string const&,std::string const&,uint,std::string&,bool);
void compile_ns_with_sourcemap(std::string const&,std::string const&,std::string const&,std::string const&,uint,std::string&,std::string&); void compile_ns_with_sourcemap(std::string const&,std::string const&,std::string const&,std::string const&,uint,std::string&,std::string&);
void readfile(char const*, std::string &); void readfile(char const*, std::string &);
void writefile(char const*, std::string &); void writefile(char const*, std::string &);
class NSGod
{
private:
/* data */
public:
NSGod(/* args */);
~NSGod();
void gen_girl(std::string);
void gen_son(std::string);
void hamlet(void);
};
class ns_node class ns_node
{ {
private: private:
@ -64,48 +64,143 @@ namespace night
public: public:
std::string offset_0; std::string offset_0;
std::string offset_24; std::string offset_24;
int offset_48 = 0;
int offset_52 = 0;
int offset_56 = 0;
std::string offset_60; std::string offset_60;
std::string offset_84;
std::string offset_108; std::string offset_108;
std::string offset_132;
std::string offset_156; std::string offset_156;
night::ns_node * offset_180; night::ns_node * offset_180 = nullptr;
night::ns_node * offset_184; night::ns_node * offset_184 = nullptr;
night::ns_node * offset_192; night::ns_node * offset_188 = nullptr;
std::vector<night::ns_node *> offset_196; night::ns_node * offset_192 = nullptr;
std::vector<night::ns_node *> offset_228; std::vector<night::ns_node *>* offset_196 = nullptr;
bool offset_200 = false;
night::ns_node * offset_204 = nullptr;
night::ns_node * offset_208 = nullptr;
night::ns_node * offset_212 = nullptr;
night::ns_node * offset_216 = nullptr;
night::ns_node * offset_220 = nullptr;
/**
* vector
*/
std::vector<std::vector<night::ns_node *>*>* offset_224 = nullptr;
std::vector<night::ns_node *>* offset_228 = nullptr;
std::vector<night::ns_node *>* offset_232 = nullptr;
std::vector<std::vector<night::ns_node *>*>* offset_236 = nullptr;
std::vector<night::ns_node *>* offset_240 = nullptr;
std::vector<night::ns_node *>* offset_244 = nullptr;
ns_node(/* args */); ns_node(/* args */);
~ns_node(); ~ns_node();
std::string debug_no_space(void); std::string debug_no_space(void);
}; };
// class GodsSon
// {
// private:
// /* data */
// public:
// std::string offset_0;
// };
class NSGod
{
private:
/* data */
public:
struct GodsSon {
std::string offset_0;
union Offset24
{
/* data */
std::vector<night::ns_node *>* vec = nullptr;
std::vector<std::vector<night::ns_node *>*>* vecVec;
night::ns_node * node;
};
Offset24 offset_24;
// std::vector<night::ns_node *>* offset_24;
};
std::vector<night::NSGod::GodsSon *> offset_0;
NSGod(/* args */);
~NSGod();
GodsSon::Offset24 gen_girl(std::string a2);
night::ns_node* gen_son(std::string);
void hamlet(void);
};
struct PeekData
{
char data;
int offset_4;
int offset_8;
};
class NSStream
{
private:
/* data */
public:
std::string offset_0;
std::string offset_24 = "";
int offset_48 = 0;
int offset_52 = 0; // 当前行数
int offset_56 = 0; // 当前行第几个字符位置
NSStream(/* args */);
NSStream(std::string const&,std::string const&,uint);
~NSStream();
NSStream(NSStream const&);
NSStream& operator=(NSStream const&);
bool eof(void);
bool eof_2(void);
void err(std::string const&,int,int,bool);
PeekData next(void);
PeekData peek(void);
PeekData peek_2(void);
};
class NSToken class NSToken
{ {
private: private:
/* data */ /* data */
public: public:
NSGod* offset_0 = nullptr;
NSStream * offset_4 = nullptr;
night::ns_node* offset_8 = nullptr;
std::vector<night::ns_node *> offset_12;
std::map<std::string, unsigned int> offset_24;
NSToken(/* args */); NSToken(/* args */);
~NSToken(); ~NSToken();
bool eof(void); bool eof(void);
void err(std::string const&,int,int,bool); void err(std::string const&, int, int, bool);
void get_tokens_for_sourcemap(std::map<std::string, uint> &, std::map<uint,std::string> &); void get_tokens_for_sourcemap(std::map<std::string, uint> &, std::map<uint,std::string> &);
void next(void); night::ns_node* next(void);
void pass(void); void pass(void);
void peek(void); night::ns_node* peek(void);
void push(night::ns_node *); void push(night::ns_node *);
void read_comment_method_1(void); void read_comment_method_1(void);
void read_comment_method_2(void); void read_comment_method_2(void);
void read_next(void); night::ns_node * read_next(void);
void read_number(std::string const&); night::ns_node * read_number(std::string const&);
void read_string(char,std::string const&); night::ns_node * read_string(char, std::string const&);
void read_var(std::string const&); night::ns_node * read_var(std::string const&);
std::string read_while(bool (*)(char,void *),void *); std::string read_while(bool (*)(char,void *),void *);
void rw_cb_number(char,void *); static bool rw_cb_number(char,void *);
void skip_comment(std::string &); void skip_comment(std::string &);
void tk_is_comment2(char,void *); static bool tk_is_comment2(char,void *);
void tk_is_not_line_break(char,void *); static bool tk_is_not_line_break(char,void *);
void tk_is_valid_op_str(char,void *); static bool tk_is_valid_op_str(char,void *);
void tk_is_var(char,void *); static bool tk_is_var(char,void *);
void tk_is_var_start(char,void *); static bool tk_is_var_start(char,void *);
void tk_is_whitespace(char,void *); static bool tk_is_whitespace(char,void *);
}; };
class NSASTParse class NSASTParse
@ -113,64 +208,65 @@ namespace night
private: private:
/* data */ /* data */
std::string offset_0; std::string offset_0;
night::NSGod * offset_24; night::NSGod * offset_24 = nullptr;
night::NSToken * offset_28; night::NSToken * offset_28 = nullptr;
int offset_36; int offset_32 = 0;
int offset_40; int offset_36 = 0;
int offset_40 = 0;
std::string offset_44; std::string offset_44;
int offset_52; std::string offset_60;
public: public:
NSASTParse(/* args */); NSASTParse(/* args */);
NSASTParse(std::string, night::NSToken *, night::NSGod *); NSASTParse(std::string, night::NSToken *, night::NSGod *);
~NSASTParse(); ~NSASTParse();
void ast_call(night::ns_node *); night::ns_node * ast_call(night::ns_node *);
void ast_code_block(void); night::ns_node * ast_code_block(void);
void ast_dispatch(bool); night::ns_node * ast_dispatch(bool);
void ast_do_while(void); night::ns_node * ast_do_while(void);
void ast_expression(void); night::ns_node * ast_expression(void);
void ast_expression_no_binary(void); night::ns_node * ast_expression_no_binary(void);
void ast_expression_no_comma(void); night::ns_node * ast_expression_no_comma(void);
void ast_for(void); night::ns_node * ast_for(void);
void ast_function(void); night::ns_node * ast_function(void);
void ast_if(void); night::ns_node * ast_if(void);
void ast_new_array(void); night::ns_node * ast_new_array(void);
void ast_obj_block(void); night::ns_node * ast_obj_block(void);
void ast_obj_dot(night::ns_node *); night::ns_node * ast_obj_dot(night::ns_node *);
void ast_obj_op(night::ns_node *); night::ns_node * ast_obj_op(night::ns_node *);
void ast_obj_op_self(night::ns_node *); night::ns_node * ast_obj_op_self(night::ns_node *);
void ast_op_self(void); night::ns_node * ast_op_self(void);
void ast_require(void); night::ns_node * ast_require(void);
void ast_switch(void); night::ns_node * ast_switch(void);
void ast_ternary_expression(void); night::ns_node * ast_ternary_expression(void);
void ast_trans_kw(void); night::ns_node * ast_trans_kw(void);
void ast_var(void); night::ns_node * ast_var(void);
void ast_varname(void); night::ns_node * ast_varname(void);
void ast_while(void); night::ns_node * ast_while(void);
void end_line(void); bool end_line(void);
void ignore_buildin_kw(std::string const&); void ignore_buildin_kw(std::string const&);
void ignore_op(std::string const&); void ignore_op(std::string const&);
void ignore_punc(std::string const&); void ignore_punc(std::string const&);
void ignore_punc_pass_sem(std::string const&); void ignore_punc_pass_sem(std::string const&);
void is_buildin_keywords(std::string const&); bool is_buildin_keywords(std::string const&);
void is_exp(night::ns_node *); bool is_exp(night::ns_node *);
void is_obj_op_self(bool); bool is_obj_op_self(bool);
void is_op(std::string const&); bool is_op(std::string const&);
/** /**
* op操作符 comma逗号 * op操作符 comma逗号
*/ */
void is_op_or_comma(std::string const&); bool is_op_or_comma(std::string const&);
void is_op_self(bool); bool is_op_self(bool);
/** /**
* punctuation * punctuation
*/ */
void is_punctuation(std::string const&); night::ns_node * is_punctuation(std::string const&);
void is_save_for_division(night::ns_node *); bool is_save_for_division(night::ns_node *);
void make_binary_or_just_value(night::ns_node *,bool); night::ns_node * make_binary_or_just_value(night::ns_node *,bool);
void make_call_or_just_expression(night::ns_node *); night::ns_node * make_call_or_just_expression(night::ns_node *);
void make_list_by_parser( std::vector<night::ns_node *>* make_list_by_parser(
std::string const&, std::string const&,
std::string const&, std::string const&,
std::string const&, std::string const&,
@ -179,16 +275,28 @@ namespace night
int, int,
std::string std::string
); );
void top_down(void); night::ns_node* top_down(void);
}; };
class ns_sourcemap class ns_sourcemap
{ {
private: private:
/* data */ /* data */
/*
64byte
*/
public: public:
std::string offset_0; std::string offset_0;
int offset_24;
int offset_28;
std::string offset_32;
int offset_56;
int offset_60;
ns_sourcemap(/* args */); ns_sourcemap(/* args */);
ns_sourcemap(ns_sourcemap &&);
ns_sourcemap(ns_sourcemap const&);
ns_sourcemap& operator=(ns_sourcemap const&);
ns_sourcemap& operator=(ns_sourcemap &&);
~ns_sourcemap(); ~ns_sourcemap();
}; };
@ -196,10 +304,10 @@ namespace night
{ {
private: private:
/* data */ /* data */
night::NSASTParse * offset_24;
std::vector<std::string> * offset_28;
public: public:
std::string offset_0; std::string offset_0;
night::NSASTParse * offset_24 = nullptr;
std::vector<std::string> * offset_28 = nullptr;
std::vector<night::ns_sourcemap> offset_36; std::vector<night::ns_sourcemap> offset_36;
int offset_48; int offset_48;
NSCompileJs(/* args */); NSCompileJs(/* args */);
@ -216,7 +324,7 @@ namespace night
std::string compile_obj_dot(night::ns_node *); std::string compile_obj_dot(night::ns_node *);
std::string compile_obj_property(night::ns_node *); std::string compile_obj_property(night::ns_node *);
std::string compile_obj_self_op(night::ns_node *); std::string compile_obj_self_op(night::ns_node *);
void compile_once(std::string &, std::vector<std::string> *, bool); std::string compile_once(std::string &, std::vector<std::string> *, bool);
std::string compile_op_self(night::ns_node *); std::string compile_op_self(night::ns_node *);
std::string compile_prog(night::ns_node *); std::string compile_prog(night::ns_node *);
std::string compile_prog_no_sem(night::ns_node *); std::string compile_prog_no_sem(night::ns_node *);
@ -226,30 +334,10 @@ namespace night
std::string compile_while(night::ns_node *); std::string compile_while(night::ns_node *);
}; };
class NSStream
{
private:
/* data */
std::string offset_24;
int offset_48 = 0;
int offset_52 = 0; // 当前行数
int offset_56 = 0; // 当前行第几个字符位置
public:
NSStream(/* args */);
NSStream(std::string const&,std::string const&,uint);
~NSStream();
void eof(void);
void eof_2(void);
void err(std::string const&,int,int,bool);
void next(void);
void peek(void);
void peek_2(void);
};
namespace str namespace str
{ {
void get_token(std::string const&, int); std::string get_token(std::string const&, int);
void path_combine( int path_combine(
std::string const&, std::string const&,
std::string const&, std::string const&,
std::string& std::string&

View File

@ -2,39 +2,51 @@
namespace night namespace night
{ {
std::string NS_TYPE_BOOL; std::string NS_TYPE_BOOL = "bool";
std::string NS_TYPE_VAR; std::string NS_TYPE_VAR = "var";
std::string NS_TYPE_NUM; std::string NS_TYPE_NUM = "num";
std::string NS_TYPE_B_TYPE; std::string NS_TYPE_B_TYPE = "builtin_type";
std::string NS_TYPE_OP_SELF; std::string NS_TYPE_OP_SELF = "op_self";
std::string NS_TYPE_BINARY; std::string NS_TYPE_BINARY = "binary";
std::string NS_TYPE_ASSIGN; std::string NS_TYPE_ASSIGN = "assign";
std::string NS_TYPE_TERNARY; std::string NS_TYPE_TERNARY = "ternary";
std::string NS_TYPE_OBJ_DOT; std::string NS_TYPE_OBJ_DOT = "obj_dot";
std::string NS_TYPE_OBJ_PROPERTY; std::string NS_TYPE_OBJ_PROPERTY = "obj_property";
std::string NS_TYPE_OBJ_SELF_OP; std::string NS_TYPE_OBJ_SELF_OP = "obj_self_op";
std::string NS_TYPE_OBJ_BLOCK; std::string NS_TYPE_OBJ_BLOCK = "obj_block";
std::string NS_TYPE_BRACKET; std::string NS_TYPE_ARRAY = "array";
std::string NS_TYPE_CALL; std::string NS_TYPE_BRACKET = "bracket";
std::string NS_TYPE_KW; std::string NS_TYPE_CALL = "call";
std::string NS_TYPE_SKIP; std::string NS_TYPE_KW = "kw";
std::string NS_TYPE_STR; std::string NS_TYPE_SKIP = "skip";
std::string NS_TYPE_PUNC; std::string NS_TYPE_STR = "str";
std::string NS_TYPE_FUNC; std::string NS_TYPE_PUNC = "punc";
std::string NS_TYPE_PROG; std::string NS_TYPE_FUNC = "function";
std::string NS_TYPE_PROG_NO_SEM; std::string NS_TYPE_PROG = "prog";
std::string NS_TYPE_PROG_NO_SEM_REQUIRE; std::string NS_TYPE_PROG_NO_SEM = "prog_no_sem";
std::string NS_TYPE_ARRAY; std::string NS_TYPE_PROG_NO_SEM_REQUIRE = "prog_no_sem_require";
std::string NS_TYPE_SWITCH; std::string NS_TYPE_SWITCH = "switch";
std::string NS_TYPE_DO_WHILE; std::string NS_TYPE_DO_WHILE = "do_while";
std::string NS_TYPE_WHILE; std::string NS_TYPE_WHILE = "while";
std::string NS_TYPE_FOR; std::string NS_TYPE_FOR = "for";
std::string NS_TYPE_IF; std::string NS_TYPE_IF = "if";
std::string NS_TYPE_K_V; std::string NS_TYPE_K_V = "k-v";
std::string NS_TYPE_OP = "op";
std::string NS_BUILTIN_OP = "+-*/%=&^|<>~!?";
std::string NS_BUILTIN_OP_SELF = "~!";
std::string NS_BUILTIN_ALL_OP = " = ? + - * / % ++ -- + - ~ ! << >> >>> & ^ | < > <= >= == != === !== *= /= %= += -= <<= >>= >>>= &= ^= |= && || ";
std::string NS_BUILTIN_PUNC = ".,;(){}[]:";
std::string NS_BUILTIN_SPACE = " \t\r\n";
std::string NS_BUILTIN_TYPE = " Number Math Date ";
// keywords
std::string NS_BUILTIN_KW = " delete void typeof null undefined NaN Infinity var if else true false require this function arguments return for while do break continue switch case default ";
std::string std_v_n = ""; std::string std_v_n = "new std::vector<ns_node*>";
std::string std_v_v_n = ""; std::string std_v_v_n = "new std::vector<std::vector<ns_node*>*>";
std::string nsv_ = "nv_";
std::string nst_ = "nt_";
int compile_ns( int compile_ns(
std::string const& a1, std::string const& a1,
@ -48,9 +60,37 @@ namespace night
night::NSStream v38(a1, a3, a4); night::NSStream v38(a1, a3, a4);
night::NSToken v27; night::NSToken v27;
night::NSGod v17; night::NSGod v17;
v27.offset_0 = &v17;
v27.offset_4 = &v38;
night::NSASTParse v39(a1, &v27, &v17); night::NSASTParse v39(a1, &v27, &v17);
NSCompileJs cjs;
std::string v19;
std::vector<std::string> v18;
cjs.offset_24 = &v39;
cjs.offset_48 = 1;
std::string v21 = cjs.compile_once(v19, &v18, a6);
v17.hamlet(); v17.hamlet();
if (v21.length())
{
a5.assign(v21);
return 121;
}
else
{
std::string v24 = ";return " + night::nsv_;
v24.append("module.").append(night::nsv_);
v24.append("exports;");
std::string v25 = "function " + a2;
v25.append("(){");
a5 = v25;
std::string v23 = "var " + night::nsv_;
v23.append("module={").append(night::nsv_);
v23.append("exports:{}};");
a5.append(v23);
std::string v26 = v19 + v24;
a5.append(v26);
a5.append("}");
}
return 0; return 0;
} }

File diff suppressed because it is too large Load Diff

View File

@ -17,86 +17,439 @@ namespace night
} }
std::string NSCompileJs::compile_binary(night::ns_node *a3) std::string NSCompileJs::compile_binary(night::ns_node *a3)
{ {
this->compile(a3->offset_180); std::string ret = this->compile(a3->offset_180);
std::string v10 = " " + a3->offset_156; std::string v10 = " " + a3->offset_156;
std::string v3 = v10.append(" "); std::string v3 = v10.append(" ");
// this->offset_48 = this->offset_48 += v3.length();
this->compile(a3->offset_184);
// v10 = v7 + v8; std::string v7 = this->compile(a3->offset_184);
std::string v4 = ""; std::string v4 = "";
// v4 = v10.append(v9); v4 = ret + v3 + v7;
return v4; return v4;
} }
std::string NSCompileJs::compile_call(night::ns_node *a3) std::string NSCompileJs::compile_call(night::ns_node *a3)
{ {
return ""; std::string str;
str = this->compile(a3->offset_220);
if ("return" == a3->offset_220->offset_60)
{
auto v3 = a3->offset_224;
for (int i = 0; ; i++)
{
if (i >= v3->size())
break;
auto v4 = v3->at(i);
if (v4->begin() != v4->end())
{
if (
v4->size() != 1
|| (v4->at(0)->offset_0 != night::NS_TYPE_SKIP)
)
{
str += "(";
this->offset_48++;
for (int v19 = 0; v19 < v4->size(); v19++)
{
auto v9 = v4->at(v19);
str += this->compile(v9);
if (v19 + 1 != v4->size())
{
str += ",";
this->offset_48++;
}
}
str += ")";
this->offset_48++;
}
}
}
}
else
{
for (int i = 0; i < a3->offset_224->size(); i++)
{
str += "(";
this->offset_48++;
auto v12 = a3->offset_224->at(i);
for (int j = 0; j < v12->size(); j++)
{
str += this->compile(v12->at(j));
if (j + 1 != v12->size())
{
str += ",";
this->offset_48++;
}
}
str += ")";
this->offset_48++;
}
}
return str;
} }
std::string NSCompileJs::compile_do_while(night::ns_node *a3) std::string NSCompileJs::compile_do_while(night::ns_node *a3)
{ {
return ""; std::string result = "";
result += "do";
this->offset_48 += 2;
result += this->compile(a3->offset_216);
result += "while(";
this->offset_48 += 6;
result += this->compile(a3->offset_204);
result += ");";
this->offset_48 += 2;
return result;
} }
std::string NSCompileJs::compile_for(night::ns_node *a3) std::string NSCompileJs::compile_for(night::ns_node *a3)
{ {
return ""; std::string result = "";
result += "for(";
this->offset_48 += 4;
auto v3 = a3->offset_228;
if (v3->size() != 3)
{
throw "error : sys error for compile_for";
}
result += this->compile(v3->at(0));
result += ";";
this->offset_48++;
result += this->compile(v3->at(1));
result += ";";
this->offset_48++;
result += this->compile(v3->at(2));
result += ")";
this->offset_48++;
result += this->compile(a3->offset_216);
return result;
} }
std::string NSCompileJs::compile_function(night::ns_node *a3) std::string NSCompileJs::compile_function(night::ns_node *a3)
{ {
return ""; // compile_function - 0
std::string result = "";
if (a3->offset_132.length())
{
result += "function ";
this->offset_48 += 9;
night::ns_sourcemap v43;
v43.offset_0.assign(a3->offset_24);
v43.offset_24 = a3->offset_48;
v43.offset_28 = a3->offset_52;
v43.offset_32.assign(a3->offset_132);
v43.offset_56 = a3->offset_48;
v43.offset_60 = this->offset_48;
this->offset_36.push_back(v43);
result += a3->offset_132;
this->offset_48 += a3->offset_132.length();
}
else
{
result += "(function ";
this->offset_48 += 10;
}
// compile_function - 5
result += "(";
this->offset_48++;
auto v4 = a3->offset_244;
bool v29 = false;
for (int i = 0; i < v4->size(); i++)
{
auto v5 = v4->at(i);
if (night::NS_TYPE_VAR == v5->offset_0)
{
result += v5->offset_60;
this->offset_48 += v5->offset_60.length();
}
else
{
result += v5->offset_180->offset_60;
v29 = true;
this->offset_48 += v5->offset_180->offset_60.length();
}
if (i + 1 != v4->size())
{
result += ",";
this->offset_48++;
}
}
// compile_function - 10
result += ")";
this->offset_48++;
if (v29)
{
result += ")";
this->offset_48++;
auto v10 = a3->offset_244;
for (int i = 0; i < v10->size(); i++)
{
auto cur = v10->at(i);
if (night::NS_TYPE_ASSIGN == cur->offset_0)
{
std::string v41 = cur->offset_180->offset_60;
v41.append("=undefined===");
v41.append(v41);
v41.append("?");
result += v41;
this->offset_48 += v41.length();
result += this->compile(cur->offset_184);
std::string v43 = ":" + cur->offset_180->offset_60;
v43.append(";");
result += v43;
this->offset_48 += v43.length();
}
}
}
// compile_function - 15
std::string v37 = this->compile(a3->offset_216);
std::string v38;
if (v29)
{
std::string v38;
if (v37.find("arguments") != -1)
{
std::string v41 = "arguments." + night::nsv_;
v41.append("length=arguments.length;");
v38 = v41;
result += v38;
this->offset_48 += v38.length();
}
result += v37.substr(1);
this->offset_48--;
for (int i = 0; i < this->offset_36.size(); i++)
{
auto v18 = this->offset_36[i];
auto v27 = v38.length() + v18.offset_60 - 1;
v18.offset_60 = v27;
}
goto LABEL_31;
}
// compile_function - 20
if (v37.find("arguments") != -1)
{
std::string v41 = "{arguments." + night::nsv_;
v41.append("length=arguments.length;");
v38 = v41;
result += v38;
this->offset_48 += v38.length();
result += v37.substr(1);
this->offset_48--;
for (int i = 0; i < this->offset_36.size(); i++)
{
auto v18 = this->offset_36[i];
auto v27 = v38.length() + v18.offset_60 - 1;
v18.offset_60 = v27;
}
goto LABEL_31;
}
// compile_function - 25
result += v37;
LABEL_31:
if (!a3->offset_132.length())
{
result += ")";
this->offset_48++;
}
return result;
} }
std::string NSCompileJs::compile_if(night::ns_node *a3) std::string NSCompileJs::compile_if(night::ns_node *a3)
{ {
return ""; std::string result = "";
} result += "if ";
std::string NSCompileJs::compile_k_v(night::ns_node *) this->offset_48 += 3;
result += this->compile(a3->offset_204);
result += this->compile(a3->offset_208);
result += a3->offset_108;
this->offset_48 += a3->offset_108.length();
if (a3->offset_212)
{ {
return ""; std::string v5 = " else ";
result += v5;
this->offset_48 += v5.length();
result += this->compile(a3->offset_212);
} }
std::string NSCompileJs::compile_obj_dot(night::ns_node *) return result;
}
std::string NSCompileJs::compile_k_v(night::ns_node * a3)
{ {
return ""; std::string result = "";
result += this->compile(a3->offset_188) + ":";
this->offset_48++;
result += this->compile(a3->offset_192) + ",";
this->offset_48++;
return result;
}
std::string NSCompileJs::compile_obj_dot(night::ns_node * a3)
{
std::string result = "";
result += this->compile(a3->offset_192);
for (int i = 0; i < a3->offset_196->size(); i++)
{
result += ".";
this->offset_48++;
auto v3 = a3->offset_196->at(i);
result += this->compile(v3);
}
return result;
} }
std::string NSCompileJs::compile_obj_property(night::ns_node *) std::string NSCompileJs::compile_obj_property(night::ns_node *)
{ {
return ""; // TODO...
throw "not implement";
} }
std::string NSCompileJs::compile_obj_self_op(night::ns_node *) std::string NSCompileJs::compile_obj_self_op(night::ns_node *a3)
{ {
return ""; std::string result = "";
if (a3->offset_200)
{
result += a3->offset_156;
this->offset_48 += a3->offset_156.length();
result += this->compile(a3->offset_192);
}
else
{
std::string v7 = this->compile(a3->offset_192);
v7.append(a3->offset_156);
result += v7;
this->offset_48 += a3->offset_156.length();
}
return result;
} }
std::string NSCompileJs::compile_op_self(night::ns_node *a3) std::string NSCompileJs::compile_op_self(night::ns_node *a3)
{ {
this->compile(a3->offset_192); std::string result = "";
for (auto i = a3->offset_196.begin(); i != a3->offset_196.end(); i++) result += a3->offset_156;
this->offset_48 += a3->offset_156.length();
result += this->compile(a3->offset_192);
return result;
}
std::string NSCompileJs::compile_switch(night::ns_node *a3)
{ {
this->compile(*i); std::string result = "";
result += "switch(";
this->offset_48 += 7;
result += this->compile(a3->offset_204);
result += "){";
this->offset_48 += 2;
auto v232 = a3->offset_232;
for (int i = 0; i < v232->size(); i++)
{
result += "case ";
this->offset_48 += 5;
result += this->compile(v232->at(i));
result.append(":");
this->offset_48++;
auto v6 = a3->offset_236->at(i);
for (int j = 0; j < v6->size(); j++)
{
auto v8 = v6->at(j);
result += this->compile(v8);
result += ";";
this->offset_48++;
}
} }
return ""; // 240
} for (int i = 0; i < a3->offset_240->size(); i++)
std::string NSCompileJs::compile_switch(night::ns_node *)
{ {
return ""; if (!i)
{
result += "default:";
this->offset_48 += 8;
}
auto v10 = a3->offset_240->at(i);
result += this->compile(v10);
result.append(";");
this->offset_48++;
}
result += "}";
this->offset_48++;
return result;
} }
std::string NSCompileJs::compile_ternary(night::ns_node *a3) std::string NSCompileJs::compile_ternary(night::ns_node *a3)
{ {
std::string result = "";
std::string v6 = this->compile(a3->offset_180); std::string v6 = this->compile(a3->offset_180);
v6.append(":"); v6.append(":");
// += v7 result += v6;
this->offset_48++; this->offset_48++;
this->compile(a3->offset_184); result += this->compile(a3->offset_184);
// += v7 return result;
return "";
} }
std::string NSCompileJs::compile_var(night::ns_node *) std::string NSCompileJs::compile_var(night::ns_node *a3)
{ {
return ""; std::string result = "";
if (a3->offset_56)
{
result = "var ";
} }
std::string NSCompileJs::compile_while(night::ns_node *) this->offset_48 += result.length();
std::string v11 = a3->offset_60.substr(0, 3);
bool v6 = false;
if (
v11 != night::nsv_
&& "return" != a3->offset_60
&& "delete" != a3->offset_60
)
{ {
return ""; v6 = "void" != a3->offset_60;
}
if (v6)
{
throw "error : sys error for compile_var `" + a3->offset_60 + "`";
}
night::ns_sourcemap _v11;
_v11.offset_0 = a3->offset_24;
_v11.offset_24 = a3->offset_48;
_v11.offset_28 = a3->offset_52;
_v11.offset_32 = a3->offset_60;
_v11.offset_56 = a3->offset_48;
_v11.offset_60 = a3->offset_48;
this->offset_36.push_back(_v11);
this->offset_48 += a3->offset_60.length();
result += a3->offset_60;
return result;
}
std::string NSCompileJs::compile_while(night::ns_node * a3)
{
std::string result = "";
std::string v5 = "while(";
result += v5;
this->offset_48 += v5.length();
result += this->compile(a3->offset_204);
result += ")";
this->offset_48++;
result += this->compile(a3->offset_216);
return result;
} }
std::string NSCompileJs::compile_prog(night::ns_node *a3) std::string NSCompileJs::compile_prog(night::ns_node *a3)
{ {
std::string result = "";
std::string v9 = a3->offset_108; std::string v9 = a3->offset_108;
if (v9.size() == 0) if (v9.size() == 0)
{ {
@ -104,38 +457,39 @@ namespace night
} }
auto v4 = a3->offset_228; auto v4 = a3->offset_228;
int v6 = 0; int v6 = 0;
for (auto i = v4.begin(); i != v4.end(); i++) for (auto i = v4->begin(); i != v4->end(); i++)
{ {
this->compile(*i); result += this->compile(*i);
v6++; v6++;
if (v6 != v4.size()) if (v6 != v4->size())
{ {
// += result += v9;
this->offset_48 += v9.size(); this->offset_48 += v9.size();
} }
} }
return ""; return result;
} }
std::string NSCompileJs::compile_prog_no_sem(night::ns_node *a3) std::string NSCompileJs::compile_prog_no_sem(night::ns_node *a3)
{ {
std::string result = "";
if (night::NS_TYPE_OBJ_BLOCK == a3->offset_0) if (night::NS_TYPE_OBJ_BLOCK == a3->offset_0)
{ {
// += result += "(";
this->offset_48++; this->offset_48++;
} }
for (auto i = a3->offset_228.begin(); i != a3->offset_228.end(); i++) for (auto i = a3->offset_228->begin(); i != a3->offset_228->end(); i++)
{ {
this->compile(*i); result += this->compile(*i);
// +=
} }
if (night::NS_TYPE_OBJ_BLOCK == a3->offset_0) if (night::NS_TYPE_OBJ_BLOCK == a3->offset_0)
{ {
// += result += ")";
this->offset_48++; this->offset_48++;
} }
return ""; return result;
} }
std::string NSCompileJs::compile(night::ns_node * a3) std::string NSCompileJs::compile(night::ns_node * a3)
@ -151,13 +505,25 @@ namespace night
{ {
if (v9 == night::NS_TYPE_BOOL) if (v9 == night::NS_TYPE_BOOL)
{ {
// TODO... night::ns_sourcemap v13;
return ""; v13.offset_0.assign(a3->offset_24);
v13.offset_32.assign(a3->offset_60);
v13.offset_24 = a3->offset_48;
v13.offset_28 = a3->offset_52;
v13.offset_56 = a3->offset_48;
v13.offset_60 = a3->offset_48;
this->offset_36.push_back(v13);
std::string v10 = a3->offset_60;
this->offset_48 += v10.length();
return v10;
} }
if (v9 == night::NS_TYPE_STR) if (v9 == night::NS_TYPE_STR)
{ {
// TODO... std::string v13 = a3->offset_108 + a3->offset_60;
return ""; v13.append(a3->offset_108);
this->offset_48 += v13.length();
return v13;
} }
if (v9 != night::NS_TYPE_B_TYPE && v9 != night::NS_TYPE_PUNC) if (v9 != night::NS_TYPE_B_TYPE && v9 != night::NS_TYPE_PUNC)
{ {
@ -267,19 +633,19 @@ namespace night
return ""; return "";
} }
void NSCompileJs::compile_once(std::string &a3, std::vector<std::string> *a4, bool a5) std::string NSCompileJs::compile_once(std::string &a3, std::vector<std::string> *a4, bool a5)
{ {
this->offset_28 = a4; this->offset_28 = a4;
a3 = ""; a3 = "";
this->offset_24->top_down(); night::ns_node* v5 = this->offset_24->top_down();
night::ns_node v5;
if (a5) if (a5)
{ {
std::string ret = v5.debug_no_space(); std::string ret = v5->debug_no_space();
printf("ast :%s\n", ret.data()); printf("ast :%s\n", ret.data());
} }
std::string v9 = this->compile(&v5); std::string v9 = this->compile(v5);
a3 = v9; a3.assign(v9);
return this->offset_0;
} }
} }

View File

@ -10,25 +10,74 @@ namespace night
{ {
} }
void NSGod::gen_girl(std::string a2) // std::vector<std::vector<night::ns_node *>*>*
night::NSGod::GodsSon::Offset24 NSGod::gen_girl(std::string a2)
{ {
night::NSGod::GodsSon* node = new night::NSGod::GodsSon();
node->offset_0.assign(a2);
if (night::std_v_n == a2) if (night::std_v_n == a2)
{ {
node->offset_24.vec = new std::vector<night::ns_node *>();
} }
if (night::std_v_v_n == a2) if (night::std_v_v_n == a2)
{ {
node->offset_24.vecVec = new std::vector<std::vector<night::ns_node *>*>();
} }
this->offset_0.push_back(node);
// return node->offset_24_vec; // 审查内存是一层vector
return node->offset_24;
} }
void NSGod::gen_son(std::string) night::ns_node* NSGod::gen_son(std::string a2)
{ {
night::NSGod::GodsSon *v6 = new night::NSGod::GodsSon();
v6->offset_0.assign(a2);
night::ns_node *v4 = new night::ns_node();
v4->offset_0.assign(a2);
v6->offset_24.node = v4;
this->offset_0.push_back(v6);
return v4;
} }
void NSGod::hamlet(void) void NSGod::hamlet(void)
{ {
for (int i = 0; i < this->offset_0.size(); i++)
{
auto v3 = this->offset_0[i];
if (v3->offset_0 == night::std_v_n)
{
auto v4 = v3->offset_24.vec;
if (v4)
{
delete v4;
v3->offset_24.vec = nullptr;
}
if (v3->offset_24.node)
{
delete v3->offset_24.node;
v3->offset_24.node = nullptr;
}
}
if (v3->offset_0 == night::std_v_v_n)
{
auto v4 = v3->offset_24.vec;
if (v4)
{
delete v4;
v3->offset_24.vec = nullptr;
}
if (v3->offset_24.node)
{
delete v3->offset_24.node;
v3->offset_24.node = nullptr;
}
}
delete v3;
}
} }
} // namespace night } // namespace night

View File

@ -13,7 +13,7 @@ namespace night
std::string ns_node::debug_no_space() std::string ns_node::debug_no_space()
{ {
return ""; throw "not implement";
} }
} }

View File

@ -7,6 +7,48 @@ namespace night
{ {
} }
ns_sourcemap::ns_sourcemap(ns_sourcemap && src):
offset_0(src.offset_0),
offset_24(src.offset_24),
offset_28(src.offset_28),
offset_32(src.offset_32),
offset_56(src.offset_56),
offset_60(src.offset_60)
{
}
ns_sourcemap::ns_sourcemap(ns_sourcemap const& src):
offset_0(src.offset_0),
offset_24(src.offset_24),
offset_28(src.offset_28),
offset_32(src.offset_32),
offset_56(src.offset_56),
offset_60(src.offset_60)
{
}
ns_sourcemap& ns_sourcemap::operator=(ns_sourcemap const& src)
{
this->offset_0 = src.offset_0;
this->offset_24 = src.offset_24;
this->offset_28 = src.offset_28;
this->offset_32 = src.offset_32;
this->offset_56 = src.offset_56;
this->offset_60 = src.offset_60;
return *this;
}
ns_sourcemap& ns_sourcemap::operator=(ns_sourcemap && src)
{
this->offset_0 = src.offset_0;
this->offset_24 = src.offset_24;
this->offset_28 = src.offset_28;
this->offset_32 = src.offset_32;
this->offset_56 = src.offset_56;
this->offset_60 = src.offset_60;
return *this;
}
ns_sourcemap::~ns_sourcemap() ns_sourcemap::~ns_sourcemap()
{ {
} }

View File

@ -6,40 +6,129 @@ namespace night
NSStream::NSStream(/* args */) NSStream::NSStream(/* args */)
{ {
} }
NSStream::NSStream(std::string const&,std::string const&,uint) NSStream::NSStream(std::string const& a2, std::string const& a3, uint a4)
{ {
this->offset_0.assign(a2);
this->offset_24.assign(a3);
this->offset_52 = a4;
this->offset_56 = 1;
} }
NSStream::~NSStream() NSStream::~NSStream()
{ {
} }
void NSStream::peek(void) PeekData NSStream::peek(void)
{ {
PeekData ret;
if (this->offset_48 < this->offset_24.length()) if (this->offset_48 < this->offset_24.length())
{ {
char v3 = this->offset_24.at(this->offset_48); char v3 = this->offset_24.at(this->offset_48);
ret.data = v3;
ret.offset_4 = this->offset_52;
ret.offset_8 = this->offset_56;
} }
else else
{ {
ret.data = 0;
ret.offset_4 = 0;
ret.offset_8 = 0;
}
return ret;
}
} bool NSStream::eof(void)
}
void NSStream::peek_2(void)
{ {
return this->peek().data == 0;
}
PeekData NSStream::peek_2(void)
{
PeekData ret;
if (this->offset_48 + 1 < this->offset_24.length()) if (this->offset_48 + 1 < this->offset_24.length())
{ {
char v3 = this->offset_24.at(this->offset_48 + 1); char v3 = this->offset_24.at(this->offset_48 + 1);
int v4 = this->offset_52;
int v5 = this->offset_56 + 1;
if (v3 == '\n') if (v3 == '\n')
{ {
this->offset_52++; v4++;
this->offset_56 = 1; v5 = 1;
} }
ret.data = v3;
ret.offset_4 = v4;
ret.offset_8 = v5;
} }
else else
{ {
ret.data = 0;
ret.offset_4 = 0;
ret.offset_8 = 0;
} }
return ret;
}
bool NSStream::eof_2(void)
{
return this->peek_2().data == 0;
}
PeekData NSStream::next(void)
{
PeekData ret;
if (this->offset_48 < this->offset_24.length())
{
char v7 = this->offset_24.at(this->offset_48);
this->offset_48++;
int v5 = this->offset_52;
int v6 = this->offset_56;
if (v7 == 10) // \n
{
this->offset_56 = 1;
this->offset_52++;
}
else
{
this->offset_56++;
}
ret.data = v7;
ret.offset_4 = v5;
ret.offset_8 = v6;
}
else
{
ret.data = 0;
ret.offset_4 = 0;
ret.offset_8 = 0;
}
return ret;
}
void NSStream::err(std::string const& a2, int a3, int a4, bool a5)
{
std::string v10;
std::string v13 = this->offset_0;
v13.append(":");
v10 += v13;
std::string v12;
if (a5)
{
v12 = std::to_string(a3);
v12.append(":");
v10 += v12;
v12 = std::to_string(a4);
}
else
{
v12 = std::to_string(this->offset_52 + a3);
v12.append(":");
v10 += v12;
v12 = std::to_string(this->offset_56 + a4);
}
v12.append(":");
v10 += v12;
v10 += a2;
throw v10;
} }
} }

View File

@ -1,4 +1,5 @@
#include "../include/night.h" #include "../include/night.h"
#include "../include/wxml.h"
namespace night namespace night
{ {
@ -9,12 +10,374 @@ namespace night
NSToken::~NSToken() NSToken::~NSToken()
{ {
} }
void NSToken::peek(void)
night::ns_node* NSToken::peek(void)
{ {
auto result = this->offset_8;
if (!result)
{
result = this->read_next();
this->offset_8 = result;
}
return result;
}
night::ns_node* NSToken::read_next(void)
{
night::ns_node* v7 = nullptr;
if (this->offset_12.begin() == this->offset_12.end())
{
auto v14 = this->read_while(night::NSToken::tk_is_whitespace, 0);
bool isEnd = this->offset_4->eof();
if (!isEnd)
{
this->skip_comment(v14);
}
if ( isEnd
|| (this->offset_4->eof())
)
{
v7 = 0;
}
else
{
auto v13 = this->offset_4->peek();
if (v13.data == '"' || v13.data == '\'')
{
v7 = this->read_string(v13.data, v14);
}
else if ((uint8_t)(v13.data - '0') > 9)
{
if (!night::NSToken::tk_is_var_start(v13.data, 0))
{
int pos = night::NS_BUILTIN_PUNC.find(v13.data, 0);
if (pos == -1)
{
int pos2 = night::NS_BUILTIN_OP.find(v13.data, 0);
if (pos2 == -1)
{
std::string msg = "Unexpected token `";
msg.append(std::string(1, v13.data));
msg.append("`");
this->offset_4->err(msg, 0, 0, false);
}
std::string v15;
auto v17 = this->read_while(night::NSToken::tk_is_valid_op_str, (void *)&v15);
v7 = this->offset_0->gen_son(night::NS_TYPE_OP);
v7->offset_60.assign(v17);
v7->offset_84.assign(v14);
}
else
{
v7 = this->offset_0->gen_son(night::NS_TYPE_PUNC);
auto v19 = this->offset_4->next();
std::string v15(1, v19.data);
v7->offset_60 = v15;
v7->offset_84 = v14;
}
// goto LABEL_19;
}
else
{
v7 = this->read_var(v14);
}
}
else
{
v7 = this->read_number(v14);
}
} }
void NSToken::read_next(void) return v7;
{ }
auto ret = this->offset_12.back();
this->offset_12.pop_back();
return ret;
}
night::ns_node* NSToken::next(void)
{
auto result = this->offset_8;
this->offset_8 = nullptr;
if (!result)
{
return this->read_next();
}
return result;
}
bool NSToken::eof(void)
{
return this->peek() == 0;
}
void NSToken::push(night::ns_node* a2)
{
if (this->offset_8)
{
this->offset_12.push_back(this->offset_8);
this->offset_8 = nullptr;
}
if (a2)
{
this->offset_12.push_back(a2);
}
}
void NSToken::read_comment_method_1()
{
this->read_while(night::NSToken::tk_is_not_line_break, 0);
}
void NSToken::read_comment_method_2()
{
this->read_while(night::NSToken::tk_is_comment2, this->offset_4);
this->offset_4->next();
}
void NSToken::skip_comment(std::string &a2)
{
while (true)
{
if (this->offset_4->eof())
{
break;
}
auto v5 = this->offset_4->peek();
if (v5.data != '/')
{
break;
}
if (this->offset_4->eof_2())
{
break;
}
v5 = this->offset_4->peek_2();
if (v5.data == '/')
{
v5 = this->offset_4->next();
v5 = this->offset_4->next();
this->read_comment_method_1();
}
else
{
v5 = this->offset_4->peek_2();
if (v5.data != '*')
return;
v5 = this->offset_4->next();
v5 = this->offset_4->next();
this->read_comment_method_2();
}
a2 = this->read_while(night::NSToken::tk_is_whitespace, 0);
}
}
night::ns_node * NSToken::read_string(char a2, std::string const& a3)
{
auto v12 = this->offset_4->next();
std::string v10 = "";
char v4;
for (int i = 0; ; i = v4)
{
v4 = this->offset_4->eof();
if (v4)
{
break;
}
auto v9 = this->offset_4->next();
if ( v9.data == '\n')
{
if (!i)
{
this->offset_4->err("Unexpected `\\n`", 0, 0, false);
}
v10.push_back('\n');
}
else
{
if (!i)
{
if (v9.data == '\\')
{
v4 = 1;
v10.push_back('\\');
continue;
}
if (v9.data == a2)
{
break;
}
}
v10.push_back(v9.data);
}
}
auto son = this->offset_0->gen_son(night::NS_TYPE_STR);
son->offset_60 = WXML::Rewrite::ToStringCode(v10);
son->offset_108.replace(0, son->offset_108.length(), 1, a2);
son->offset_84.assign(a3);
return son;
}
night::ns_node * NSToken::read_number(std::string const& a2)
{
int v8;
auto v9 = this->read_while(night::NSToken::rw_cb_number, &v8);
auto v13 = this->offset_4->peek();
if (night::NSToken::tk_is_var_start(v13.data, nullptr))
{
std::string msg = "Unexpected token `";
msg.append(std::string(1, v13.data));
msg.append("`");
this->offset_4->err(msg, 0, 0, false);
}
auto son = this->offset_0->gen_son(night::NS_TYPE_NUM);
son->offset_60 = v9;
son->offset_84 = a2;
return son;
}
std::string NSToken::read_while(bool (*a3)(char,void *), void *a4)
{
std::string result = "";
while (!this->offset_4->eof())
{
auto v6 = this->offset_4->peek();
if (!a3(v6.data, a4))
{
break;
}
v6 = this->offset_4->next();
result.push_back(v6.data);
}
return result;
}
night::ns_node *NSToken::read_var(std::string const & a2)
{
auto v12 = this->offset_4->peek();
auto v13 = this->read_while(night::NSToken::tk_is_var, 0);
std::string v16 = " " + v13 + " ";
int pos = night::NS_BUILTIN_TYPE.find(v16, 0);
night::ns_node *son = nullptr;
if (pos == -1)
{
int v6 = night::NS_BUILTIN_KW.find(v16, 0);
auto v4 = night::NS_TYPE_KW;
if (v6 == -1)
{
v4 = night::NS_TYPE_VAR;
}
son = this->offset_0->gen_son(v4);
if (v6 == -1)
{
v16 = night::nsv_ + v13;
}
else
{
v16 = v13;
}
son->offset_60 = v16;
son->offset_24.assign(v13);
son->offset_84 = a2;
son->offset_48 = v12.offset_4;
son->offset_52 = v12.offset_8;
if (!this->offset_24[v13])
{
this->offset_24[v13] = this->offset_24.size();
}
}
else
{
son = this->offset_0->gen_son(night::NS_TYPE_B_TYPE);
son->offset_60 = v13;
son->offset_84 = a2;
}
return son;
}
void NSToken::err(std::string const& a2, int a3, int a4, bool a5)
{
this->offset_4->err(a2, a3, a4, a5);
}
bool NSToken::rw_cb_number(char ch, void *t)
{
int *a2 = (int *)t;
if(ch != '.')
{
return ch - '0' <= 9u;
}
bool result = false;
if (!*a2)
{
*a2 = 1;
return true;
}
return result;
}
bool NSToken::tk_is_whitespace(char ch, void *)
{
auto v1 = night::NS_BUILTIN_SPACE.find(ch, 0);
return v1 != -1;
}
bool NSToken::tk_is_not_line_break(char ch, void *)
{
return ch != 10;
}
bool NSToken::tk_is_valid_op_str(char ch, void *t)
{
std::string * a2 = (std::string *)t;
std::string v6;
v6.assign(*a2);
v6.replace(v6.length(), 0, 1, ch);
bool result = false;
if (
night::NS_BUILTIN_OP.find(ch, 0) == -1
|| (
night::NS_BUILTIN_ALL_OP.find(v6, 0) == -1
)
)
{
result = false;
}
else
{
a2->assign(v6);
result = true;
}
return result;
}
bool NSToken::tk_is_comment2(char ch, void * t)
{
night::NSStream *a2 = (night::NSStream *)t;
auto v3 = a2->peek();
if (v3.data != '*')
{
return 1;
}
v3 = a2->peek_2();
if (v3.data != '/')
{
return 1;
}
a2->next();
return 0;
}
bool NSToken::tk_is_var(char ch, void * t)
{
bool result = night::NSToken::tk_is_var_start(ch, t);
if (!result)
{
uint8_t v4 = ch - '0';
return (ch == '_') | (v4 <= 9u);
}
return result;
}
bool NSToken::tk_is_var_start(char ch, void * t)
{
uint8_t v1 = (ch & 0xFFFFFFDF) - 'A';
return (v1 <= 0x19u) | (ch == '_');
} }
} }

View File

@ -1,16 +1,53 @@
#include "../../include/night.h" #include "../../include/night.h"
#include "../../include/wxa.h"
#include "../../include/wxml.h"
namespace night namespace night
{ {
namespace str namespace str
{ {
void get_token(std::string const&, int) std::string get_token(std::string const& a2, int a3)
{ {
std::string result;
char v3;
while (a3 < a2.length())
{
v3 = a2[a3];
if ((v3 & 0xdf) - 65 > 0x19u && v3 != '_' && v3 - '0' > 9u)
{
break;
}
++a3;
result.push_back(v3);
}
return result;
} }
void path_combine(std::string const&, std::string const&, std::string&)
{
/**
* todo...
*/
int path_combine(std::string const& a1, std::string const& a2, std::string& a3)
{
std::string v11;
MMBizWxaAppComm::PathCombine(a1, a2, v11);
int code = 0;
if (v11.length() > 3)
{
std::string v14 = v11.substr(v11.length() - 3);
code = v14 == ".wxs";
if (code)
{
code = 2;
}
else
{
std::string v3 = WXML::Rewrite::ToStringCode(v11);
a3 = v3;
}
}
return code;
} }
} // namespace str } // namespace str
} // namespace night } // namespace night

View File

@ -832,10 +832,6 @@ namespace WXML{
std::string data = "<fak"; std::string data = "<fak";
data = data.append(sub); data = data.append(sub);
data = data.append("/>"); data = data.append("/>");
/*
....<fak module=
"refresh"/>.....
*/
// DealWxsTag - 5 // DealWxsTag - 5
for (int i = 1; i < a2.offset_8; i++) for (int i = 1; i < a2.offset_8; i++)
{ {
@ -1053,7 +1049,7 @@ namespace WXML{
a2.insert({a3, a2.size()}); a2.insert({a3, a2.size()});
} }
auto v5 = a2[a3]; auto v5 = a2[a3];
sprintf(&result[0], "np_%d", v5); result = "np_" + std::to_string(v5);
return result; return result;
} }
} // namespace Compiler } // namespace Compiler

File diff suppressed because it is too large Load Diff