diff options
| author | Li Jin <dragon-fly@qq.com> | 2022-05-06 14:29:10 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2022-05-06 14:29:10 +0800 |
| commit | d20be11da9fef9309faf7f83078ed963a3b1e627 (patch) | |
| tree | d597685d7634a664e03479d465c6b02e707a8b44 /src | |
| parent | 70d8bc6d5396799c71ee97a7f98791779c8f1a37 (diff) | |
| download | yuescript-d20be11da9fef9309faf7f83078ed963a3b1e627.tar.gz yuescript-d20be11da9fef9309faf7f83078ed963a3b1e627.tar.bz2 yuescript-d20be11da9fef9309faf7f83078ed963a3b1e627.zip | |
add to_ast function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuescript/ast.hpp | 3 | ||||
| -rwxr-xr-x | src/yuescript/yue_ast.h | 276 | ||||
| -rwxr-xr-x | src/yuescript/yue_compiler.cpp | 2 | ||||
| -rw-r--r-- | src/yuescript/yuescript.cpp | 81 |
4 files changed, 224 insertions, 138 deletions
diff --git a/src/yuescript/ast.hpp b/src/yuescript/ast.hpp index 6f89b52..4860fc9 100644 --- a/src/yuescript/ast.hpp +++ b/src/yuescript/ast.hpp | |||
| @@ -16,6 +16,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | |||
| 16 | #include <list> | 16 | #include <list> |
| 17 | #include <stdexcept> | 17 | #include <stdexcept> |
| 18 | #include <type_traits> | 18 | #include <type_traits> |
| 19 | #include <string_view> | ||
| 19 | 20 | ||
| 20 | #include "yuescript/parser.hpp" | 21 | #include "yuescript/parser.hpp" |
| 21 | 22 | ||
| @@ -96,6 +97,8 @@ public: | |||
| 96 | 97 | ||
| 97 | virtual int getId() const = 0; | 98 | virtual int getId() const = 0; |
| 98 | 99 | ||
| 100 | virtual const std::string_view getName() const = 0; | ||
| 101 | |||
| 99 | template<class T> | 102 | template<class T> |
| 100 | inline ast_ptr<false, T> new_ptr() const { | 103 | inline ast_ptr<false, T> new_ptr() const { |
| 101 | auto item = new T; | 104 | auto item = new T; |
diff --git a/src/yuescript/yue_ast.h b/src/yuescript/yue_ast.h index 06896b8..d255236 100755 --- a/src/yuescript/yue_ast.h +++ b/src/yuescript/yue_ast.h | |||
| @@ -11,6 +11,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI | |||
| 11 | #include "yuescript/ast.hpp" | 11 | #include "yuescript/ast.hpp" |
| 12 | 12 | ||
| 13 | namespace parserlib { | 13 | namespace parserlib { |
| 14 | using namespace std::string_view_literals; | ||
| 14 | 15 | ||
| 15 | #define AST_LEAF(type) \ | 16 | #define AST_LEAF(type) \ |
| 16 | COUNTER_INC; \ | 17 | COUNTER_INC; \ |
| @@ -31,71 +32,72 @@ public: \ | |||
| 31 | add_members({__VA_ARGS__}); \ | 32 | add_members({__VA_ARGS__}); \ |
| 32 | } | 33 | } |
| 33 | 34 | ||
| 34 | #define AST_END(type) \ | 35 | #define AST_END(type, name) \ |
| 36 | virtual const std::string_view getName() const override { return name; } \ | ||
| 35 | }; \ | 37 | }; \ |
| 36 | template<> constexpr int id<type##_t>() { return COUNTER_READ; } | 38 | template<> constexpr int id<type##_t>() { return COUNTER_READ; } |
| 37 | 39 | ||
| 38 | AST_LEAF(Num) | 40 | AST_LEAF(Num) |
| 39 | AST_END(Num) | 41 | AST_END(Num, "num"sv) |
| 40 | 42 | ||
| 41 | AST_LEAF(Name) | 43 | AST_LEAF(Name) |
| 42 | AST_END(Name) | 44 | AST_END(Name, "name"sv) |
| 43 | 45 | ||
| 44 | AST_NODE(Variable) | 46 | AST_NODE(Variable) |
| 45 | ast_ptr<true, Name_t> name; | 47 | ast_ptr<true, Name_t> name; |
| 46 | AST_MEMBER(Variable, &name) | 48 | AST_MEMBER(Variable, &name) |
| 47 | AST_END(Variable) | 49 | AST_END(Variable, "variable"sv) |
| 48 | 50 | ||
| 49 | AST_NODE(LabelName) | 51 | AST_NODE(LabelName) |
| 50 | ast_ptr<true, Name_t> name; | 52 | ast_ptr<true, Name_t> name; |
| 51 | AST_MEMBER(LabelName, &name) | 53 | AST_MEMBER(LabelName, &name) |
| 52 | AST_END(LabelName) | 54 | AST_END(LabelName, "label_name"sv) |
| 53 | 55 | ||
| 54 | AST_NODE(LuaKeyword) | 56 | AST_NODE(LuaKeyword) |
| 55 | ast_ptr<true, Name_t> name; | 57 | ast_ptr<true, Name_t> name; |
| 56 | AST_MEMBER(LuaKeyword, &name) | 58 | AST_MEMBER(LuaKeyword, &name) |
| 57 | AST_END(LuaKeyword) | 59 | AST_END(LuaKeyword, "lua_keyword"sv) |
| 58 | 60 | ||
| 59 | AST_LEAF(self) | 61 | AST_LEAF(self) |
| 60 | AST_END(self) | 62 | AST_END(self, "self"sv) |
| 61 | 63 | ||
| 62 | AST_NODE(self_name) | 64 | AST_NODE(self_name) |
| 63 | ast_ptr<true, Name_t> name; | 65 | ast_ptr<true, Name_t> name; |
| 64 | AST_MEMBER(self_name, &name) | 66 | AST_MEMBER(self_name, &name) |
| 65 | AST_END(self_name) | 67 | AST_END(self_name, "self_name"sv) |
| 66 | 68 | ||
| 67 | AST_LEAF(self_class) | 69 | AST_LEAF(self_class) |
| 68 | AST_END(self_class) | 70 | AST_END(self_class, "self_name"sv) |
| 69 | 71 | ||
| 70 | AST_NODE(self_class_name) | 72 | AST_NODE(self_class_name) |
| 71 | ast_ptr<true, Name_t> name; | 73 | ast_ptr<true, Name_t> name; |
| 72 | AST_MEMBER(self_class_name, &name) | 74 | AST_MEMBER(self_class_name, &name) |
| 73 | AST_END(self_class_name) | 75 | AST_END(self_class_name, "self_class_name"sv) |
| 74 | 76 | ||
| 75 | AST_NODE(SelfName) | 77 | AST_NODE(SelfName) |
| 76 | ast_sel<true, self_class_name_t, self_class_t, self_name_t, self_t> name; | 78 | ast_sel<true, self_class_name_t, self_class_t, self_name_t, self_t> name; |
| 77 | AST_MEMBER(SelfName, &name) | 79 | AST_MEMBER(SelfName, &name) |
| 78 | AST_END(SelfName) | 80 | AST_END(SelfName, "self_item"sv) |
| 79 | 81 | ||
| 80 | AST_NODE(KeyName) | 82 | AST_NODE(KeyName) |
| 81 | ast_sel<true, SelfName_t, Name_t> name; | 83 | ast_sel<true, SelfName_t, Name_t> name; |
| 82 | AST_MEMBER(KeyName, &name) | 84 | AST_MEMBER(KeyName, &name) |
| 83 | AST_END(KeyName) | 85 | AST_END(KeyName, "key_name"sv) |
| 84 | 86 | ||
| 85 | AST_LEAF(VarArg) | 87 | AST_LEAF(VarArg) |
| 86 | AST_END(VarArg) | 88 | AST_END(VarArg, "var_arg"sv) |
| 87 | 89 | ||
| 88 | AST_LEAF(local_flag) | 90 | AST_LEAF(local_flag) |
| 89 | AST_END(local_flag) | 91 | AST_END(local_flag, "local_flag"sv) |
| 90 | 92 | ||
| 91 | AST_LEAF(Seperator) | 93 | AST_LEAF(Seperator) |
| 92 | AST_END(Seperator) | 94 | AST_END(Seperator, "seperator"sv) |
| 93 | 95 | ||
| 94 | AST_NODE(NameList) | 96 | AST_NODE(NameList) |
| 95 | ast_ptr<true, Seperator_t> sep; | 97 | ast_ptr<true, Seperator_t> sep; |
| 96 | ast_list<true, Variable_t> names; | 98 | ast_list<true, Variable_t> names; |
| 97 | AST_MEMBER(NameList, &sep, &names) | 99 | AST_MEMBER(NameList, &sep, &names) |
| 98 | AST_END(NameList) | 100 | AST_END(NameList, "name_list"sv) |
| 99 | 101 | ||
| 100 | class ExpListLow_t; | 102 | class ExpListLow_t; |
| 101 | class TableBlock_t; | 103 | class TableBlock_t; |
| @@ -105,7 +107,7 @@ AST_NODE(local_values) | |||
| 105 | ast_ptr<true, NameList_t> nameList; | 107 | ast_ptr<true, NameList_t> nameList; |
| 106 | ast_sel<false, TableBlock_t, ExpListLow_t> valueList; | 108 | ast_sel<false, TableBlock_t, ExpListLow_t> valueList; |
| 107 | AST_MEMBER(local_values, &nameList, &valueList) | 109 | AST_MEMBER(local_values, &nameList, &valueList) |
| 108 | AST_END(local_values) | 110 | AST_END(local_values, "local_values"sv) |
| 109 | 111 | ||
| 110 | AST_NODE(Local) | 112 | AST_NODE(Local) |
| 111 | ast_sel<true, local_flag_t, local_values_t> item; | 113 | ast_sel<true, local_flag_t, local_values_t> item; |
| @@ -114,43 +116,43 @@ AST_NODE(Local) | |||
| 114 | bool collected = false; | 116 | bool collected = false; |
| 115 | bool defined = false; | 117 | bool defined = false; |
| 116 | AST_MEMBER(Local, &item) | 118 | AST_MEMBER(Local, &item) |
| 117 | AST_END(Local) | 119 | AST_END(Local, "local"sv) |
| 118 | 120 | ||
| 119 | class Assign_t; | 121 | class Assign_t; |
| 120 | 122 | ||
| 121 | AST_LEAF(Attrib) | 123 | AST_LEAF(Attrib) |
| 122 | AST_END(Attrib) | 124 | AST_END(Attrib, "attrib"sv) |
| 123 | 125 | ||
| 124 | AST_NODE(LocalAttrib) | 126 | AST_NODE(LocalAttrib) |
| 125 | ast_ptr<true, Attrib_t> attrib; | 127 | ast_ptr<true, Attrib_t> attrib; |
| 126 | ast_ptr<true, NameList_t> nameList; | 128 | ast_ptr<true, NameList_t> nameList; |
| 127 | ast_ptr<true, Assign_t> assign; | 129 | ast_ptr<true, Assign_t> assign; |
| 128 | AST_MEMBER(LocalAttrib, &attrib, &nameList, &assign) | 130 | AST_MEMBER(LocalAttrib, &attrib, &nameList, &assign) |
| 129 | AST_END(LocalAttrib) | 131 | AST_END(LocalAttrib, "local_attrib"sv) |
| 130 | 132 | ||
| 131 | AST_NODE(colon_import_name) | 133 | AST_NODE(colon_import_name) |
| 132 | ast_ptr<true, Variable_t> name; | 134 | ast_ptr<true, Variable_t> name; |
| 133 | AST_MEMBER(colon_import_name, &name) | 135 | AST_MEMBER(colon_import_name, &name) |
| 134 | AST_END(colon_import_name) | 136 | AST_END(colon_import_name, "colon_import_name"sv) |
| 135 | 137 | ||
| 136 | class Exp_t; | 138 | class Exp_t; |
| 137 | class TableLit_t; | 139 | class TableLit_t; |
| 138 | 140 | ||
| 139 | AST_LEAF(import_literal_inner) | 141 | AST_LEAF(import_literal_inner) |
| 140 | AST_END(import_literal_inner) | 142 | AST_END(import_literal_inner, "import_literal_inner"sv) |
| 141 | 143 | ||
| 142 | AST_NODE(ImportLiteral) | 144 | AST_NODE(ImportLiteral) |
| 143 | ast_ptr<true, Seperator_t> sep; | 145 | ast_ptr<true, Seperator_t> sep; |
| 144 | ast_sel_list<true, import_literal_inner_t> inners; | 146 | ast_sel_list<true, import_literal_inner_t> inners; |
| 145 | AST_MEMBER(ImportLiteral, &sep, &inners) | 147 | AST_MEMBER(ImportLiteral, &sep, &inners) |
| 146 | AST_END(ImportLiteral) | 148 | AST_END(ImportLiteral, "import_literal"sv) |
| 147 | 149 | ||
| 148 | AST_NODE(ImportFrom) | 150 | AST_NODE(ImportFrom) |
| 149 | ast_ptr<true, Seperator_t> sep; | 151 | ast_ptr<true, Seperator_t> sep; |
| 150 | ast_sel_list<true, colon_import_name_t, Variable_t> names; | 152 | ast_sel_list<true, colon_import_name_t, Variable_t> names; |
| 151 | ast_ptr<true, Exp_t> exp; | 153 | ast_ptr<true, Exp_t> exp; |
| 152 | AST_MEMBER(ImportFrom, &sep, &names, &exp) | 154 | AST_MEMBER(ImportFrom, &sep, &names, &exp) |
| 153 | AST_END(ImportFrom) | 155 | AST_END(ImportFrom, "import_from"sv) |
| 154 | 156 | ||
| 155 | class MacroName_t; | 157 | class MacroName_t; |
| 156 | 158 | ||
| @@ -158,10 +160,10 @@ AST_NODE(macro_name_pair) | |||
| 158 | ast_ptr<true, MacroName_t> key; | 160 | ast_ptr<true, MacroName_t> key; |
| 159 | ast_ptr<true, MacroName_t> value; | 161 | ast_ptr<true, MacroName_t> value; |
| 160 | AST_MEMBER(macro_name_pair, &key, &value) | 162 | AST_MEMBER(macro_name_pair, &key, &value) |
| 161 | AST_END(macro_name_pair) | 163 | AST_END(macro_name_pair, "macro_name_pair"sv) |
| 162 | 164 | ||
| 163 | AST_LEAF(import_all_macro) | 165 | AST_LEAF(import_all_macro) |
| 164 | AST_END(import_all_macro) | 166 | AST_END(import_all_macro, "import_all_macro"sv) |
| 165 | 167 | ||
| 166 | class variable_pair_t; | 168 | class variable_pair_t; |
| 167 | class normal_pair_t; | 169 | class normal_pair_t; |
| @@ -172,33 +174,33 @@ AST_NODE(ImportTabLit) | |||
| 172 | ast_ptr<true, Seperator_t> sep; | 174 | ast_ptr<true, Seperator_t> sep; |
| 173 | ast_sel_list<false, variable_pair_t, normal_pair_t, MacroName_t, macro_name_pair_t, import_all_macro_t, Exp_t, meta_variable_pair_t, meta_normal_pair_t> items; | 175 | ast_sel_list<false, variable_pair_t, normal_pair_t, MacroName_t, macro_name_pair_t, import_all_macro_t, Exp_t, meta_variable_pair_t, meta_normal_pair_t> items; |
| 174 | AST_MEMBER(ImportTabLit, &sep, &items) | 176 | AST_MEMBER(ImportTabLit, &sep, &items) |
| 175 | AST_END(ImportTabLit) | 177 | AST_END(ImportTabLit, "import_tab_lit"sv) |
| 176 | 178 | ||
| 177 | AST_NODE(ImportAs) | 179 | AST_NODE(ImportAs) |
| 178 | ast_ptr<true, ImportLiteral_t> literal; | 180 | ast_ptr<true, ImportLiteral_t> literal; |
| 179 | ast_sel<false, Variable_t, ImportTabLit_t, import_all_macro_t> target; | 181 | ast_sel<false, Variable_t, ImportTabLit_t, import_all_macro_t> target; |
| 180 | AST_MEMBER(ImportAs, &literal, &target) | 182 | AST_MEMBER(ImportAs, &literal, &target) |
| 181 | AST_END(ImportAs) | 183 | AST_END(ImportAs, "import_as"sv) |
| 182 | 184 | ||
| 183 | AST_NODE(Import) | 185 | AST_NODE(Import) |
| 184 | ast_sel<true, ImportAs_t, ImportFrom_t> content; | 186 | ast_sel<true, ImportAs_t, ImportFrom_t> content; |
| 185 | AST_MEMBER(Import, &content) | 187 | AST_MEMBER(Import, &content) |
| 186 | AST_END(Import) | 188 | AST_END(Import, "import"sv) |
| 187 | 189 | ||
| 188 | AST_NODE(Label) | 190 | AST_NODE(Label) |
| 189 | ast_ptr<true, LabelName_t> label; | 191 | ast_ptr<true, LabelName_t> label; |
| 190 | AST_MEMBER(Label, &label) | 192 | AST_MEMBER(Label, &label) |
| 191 | AST_END(Label) | 193 | AST_END(Label, "label"sv) |
| 192 | 194 | ||
| 193 | AST_NODE(Goto) | 195 | AST_NODE(Goto) |
| 194 | ast_ptr<true, LabelName_t> label; | 196 | ast_ptr<true, LabelName_t> label; |
| 195 | AST_MEMBER(Goto, &label) | 197 | AST_MEMBER(Goto, &label) |
| 196 | AST_END(Goto) | 198 | AST_END(Goto, "goto"sv) |
| 197 | 199 | ||
| 198 | class FnArgsDef_t; | 200 | class FnArgsDef_t; |
| 199 | 201 | ||
| 200 | AST_LEAF(fn_arrow_back) | 202 | AST_LEAF(fn_arrow_back) |
| 201 | AST_END(fn_arrow_back) | 203 | AST_END(fn_arrow_back, "fn_arrow_back"sv) |
| 202 | 204 | ||
| 203 | class ChainValue_t; | 205 | class ChainValue_t; |
| 204 | 206 | ||
| @@ -207,19 +209,19 @@ AST_NODE(Backcall) | |||
| 207 | ast_ptr<true, fn_arrow_back_t> arrow; | 209 | ast_ptr<true, fn_arrow_back_t> arrow; |
| 208 | ast_ptr<true, ChainValue_t> value; | 210 | ast_ptr<true, ChainValue_t> value; |
| 209 | AST_MEMBER(Backcall, &argsDef, &arrow, &value) | 211 | AST_MEMBER(Backcall, &argsDef, &arrow, &value) |
| 210 | AST_END(Backcall) | 212 | AST_END(Backcall, "backcall"sv) |
| 211 | 213 | ||
| 212 | AST_NODE(ExpListLow) | 214 | AST_NODE(ExpListLow) |
| 213 | ast_ptr<true, Seperator_t> sep; | 215 | ast_ptr<true, Seperator_t> sep; |
| 214 | ast_list<true, Exp_t> exprs; | 216 | ast_list<true, Exp_t> exprs; |
| 215 | AST_MEMBER(ExpListLow, &sep, &exprs) | 217 | AST_MEMBER(ExpListLow, &sep, &exprs) |
| 216 | AST_END(ExpListLow) | 218 | AST_END(ExpListLow, "exp_list_low"sv) |
| 217 | 219 | ||
| 218 | AST_NODE(ExpList) | 220 | AST_NODE(ExpList) |
| 219 | ast_ptr<true, Seperator_t> sep; | 221 | ast_ptr<true, Seperator_t> sep; |
| 220 | ast_list<true, Exp_t> exprs; | 222 | ast_list<true, Exp_t> exprs; |
| 221 | AST_MEMBER(ExpList, &sep, &exprs) | 223 | AST_MEMBER(ExpList, &sep, &exprs) |
| 222 | AST_END(ExpList) | 224 | AST_END(ExpList, "exp_list"sv) |
| 223 | 225 | ||
| 224 | class TableBlock_t; | 226 | class TableBlock_t; |
| 225 | 227 | ||
| @@ -227,7 +229,7 @@ AST_NODE(Return) | |||
| 227 | bool allowBlockMacroReturn = false; | 229 | bool allowBlockMacroReturn = false; |
| 228 | ast_sel<false, TableBlock_t, ExpListLow_t> valueList; | 230 | ast_sel<false, TableBlock_t, ExpListLow_t> valueList; |
| 229 | AST_MEMBER(Return, &valueList) | 231 | AST_MEMBER(Return, &valueList) |
| 230 | AST_END(Return) | 232 | AST_END(Return, "return"sv) |
| 231 | 233 | ||
| 232 | class existential_op_t; | 234 | class existential_op_t; |
| 233 | class Assign_t; | 235 | class Assign_t; |
| @@ -240,13 +242,13 @@ AST_NODE(With) | |||
| 240 | ast_ptr<false, Assign_t> assigns; | 242 | ast_ptr<false, Assign_t> assigns; |
| 241 | ast_sel<true, Block_t, Statement_t> body; | 243 | ast_sel<true, Block_t, Statement_t> body; |
| 242 | AST_MEMBER(With, &eop, &valueList, &assigns, &body) | 244 | AST_MEMBER(With, &eop, &valueList, &assigns, &body) |
| 243 | AST_END(With) | 245 | AST_END(With, "with"sv) |
| 244 | 246 | ||
| 245 | AST_NODE(SwitchCase) | 247 | AST_NODE(SwitchCase) |
| 246 | ast_ptr<true, ExpList_t> valueList; | 248 | ast_ptr<true, ExpList_t> valueList; |
| 247 | ast_sel<true, Block_t, Statement_t> body; | 249 | ast_sel<true, Block_t, Statement_t> body; |
| 248 | AST_MEMBER(SwitchCase, &valueList, &body) | 250 | AST_MEMBER(SwitchCase, &valueList, &body) |
| 249 | AST_END(SwitchCase) | 251 | AST_END(SwitchCase, "switch_case"sv) |
| 250 | 252 | ||
| 251 | AST_NODE(Switch) | 253 | AST_NODE(Switch) |
| 252 | ast_ptr<true, Exp_t> target; | 254 | ast_ptr<true, Exp_t> target; |
| @@ -254,37 +256,37 @@ AST_NODE(Switch) | |||
| 254 | ast_list<true, SwitchCase_t> branches; | 256 | ast_list<true, SwitchCase_t> branches; |
| 255 | ast_sel<false, Block_t, Statement_t> lastBranch; | 257 | ast_sel<false, Block_t, Statement_t> lastBranch; |
| 256 | AST_MEMBER(Switch, &target, &sep, &branches, &lastBranch) | 258 | AST_MEMBER(Switch, &target, &sep, &branches, &lastBranch) |
| 257 | AST_END(Switch) | 259 | AST_END(Switch, "switch"sv) |
| 258 | 260 | ||
| 259 | AST_NODE(assignment) | 261 | AST_NODE(assignment) |
| 260 | ast_ptr<true, ExpList_t> expList; | 262 | ast_ptr<true, ExpList_t> expList; |
| 261 | ast_ptr<true, Assign_t> assign; | 263 | ast_ptr<true, Assign_t> assign; |
| 262 | AST_MEMBER(assignment, &expList, &assign) | 264 | AST_MEMBER(assignment, &expList, &assign) |
| 263 | AST_END(assignment) | 265 | AST_END(assignment, "assignment"sv) |
| 264 | 266 | ||
| 265 | AST_NODE(IfCond) | 267 | AST_NODE(IfCond) |
| 266 | ast_sel<true, Exp_t, assignment_t> condition; | 268 | ast_sel<true, Exp_t, assignment_t> condition; |
| 267 | AST_MEMBER(IfCond, &condition) | 269 | AST_MEMBER(IfCond, &condition) |
| 268 | AST_END(IfCond) | 270 | AST_END(IfCond, "if_cond"sv) |
| 269 | 271 | ||
| 270 | AST_LEAF(IfType) | 272 | AST_LEAF(IfType) |
| 271 | AST_END(IfType) | 273 | AST_END(IfType, "if_type"sv) |
| 272 | 274 | ||
| 273 | AST_NODE(If) | 275 | AST_NODE(If) |
| 274 | ast_ptr<true, IfType_t> type; | 276 | ast_ptr<true, IfType_t> type; |
| 275 | ast_sel_list<true, IfCond_t, Block_t, Statement_t> nodes; | 277 | ast_sel_list<true, IfCond_t, Block_t, Statement_t> nodes; |
| 276 | AST_MEMBER(If, &type, &nodes) | 278 | AST_MEMBER(If, &type, &nodes) |
| 277 | AST_END(If) | 279 | AST_END(If, "if"sv) |
| 278 | 280 | ||
| 279 | AST_LEAF(WhileType) | 281 | AST_LEAF(WhileType) |
| 280 | AST_END(WhileType) | 282 | AST_END(WhileType, "while_type"sv) |
| 281 | 283 | ||
| 282 | AST_NODE(While) | 284 | AST_NODE(While) |
| 283 | ast_ptr<true, WhileType_t> type; | 285 | ast_ptr<true, WhileType_t> type; |
| 284 | ast_ptr<true, Exp_t> condition; | 286 | ast_ptr<true, Exp_t> condition; |
| 285 | ast_sel<true, Block_t, Statement_t> body; | 287 | ast_sel<true, Block_t, Statement_t> body; |
| 286 | AST_MEMBER(While, &type, &condition, &body) | 288 | AST_MEMBER(While, &type, &condition, &body) |
| 287 | AST_END(While) | 289 | AST_END(While, "while"sv) |
| 288 | 290 | ||
| 289 | class Body_t; | 291 | class Body_t; |
| 290 | 292 | ||
| @@ -292,12 +294,12 @@ AST_NODE(Repeat) | |||
| 292 | ast_ptr<true, Body_t> body; | 294 | ast_ptr<true, Body_t> body; |
| 293 | ast_ptr<true, Exp_t> condition; | 295 | ast_ptr<true, Exp_t> condition; |
| 294 | AST_MEMBER(Repeat, &body, &condition) | 296 | AST_MEMBER(Repeat, &body, &condition) |
| 295 | AST_END(Repeat) | 297 | AST_END(Repeat, "repeat"sv) |
| 296 | 298 | ||
| 297 | AST_NODE(for_step_value) | 299 | AST_NODE(for_step_value) |
| 298 | ast_ptr<true, Exp_t> value; | 300 | ast_ptr<true, Exp_t> value; |
| 299 | AST_MEMBER(for_step_value, &value) | 301 | AST_MEMBER(for_step_value, &value) |
| 300 | AST_END(for_step_value) | 302 | AST_END(for_step_value, "for_step_value"sv) |
| 301 | 303 | ||
| 302 | AST_NODE(For) | 304 | AST_NODE(For) |
| 303 | ast_ptr<true, Variable_t> varName; | 305 | ast_ptr<true, Variable_t> varName; |
| @@ -306,7 +308,7 @@ AST_NODE(For) | |||
| 306 | ast_ptr<false, for_step_value_t> stepValue; | 308 | ast_ptr<false, for_step_value_t> stepValue; |
| 307 | ast_sel<true, Block_t, Statement_t> body; | 309 | ast_sel<true, Block_t, Statement_t> body; |
| 308 | AST_MEMBER(For, &varName, &startValue, &stopValue, &stepValue, &body) | 310 | AST_MEMBER(For, &varName, &startValue, &stopValue, &stepValue, &body) |
| 309 | AST_END(For) | 311 | AST_END(For, "for"sv) |
| 310 | 312 | ||
| 311 | class AssignableNameList_t; | 313 | class AssignableNameList_t; |
| 312 | class star_exp_t; | 314 | class star_exp_t; |
| @@ -316,24 +318,24 @@ AST_NODE(ForEach) | |||
| 316 | ast_sel<true, star_exp_t, ExpList_t> loopValue; | 318 | ast_sel<true, star_exp_t, ExpList_t> loopValue; |
| 317 | ast_sel<true, Block_t, Statement_t> body; | 319 | ast_sel<true, Block_t, Statement_t> body; |
| 318 | AST_MEMBER(ForEach, &nameList, &loopValue, &body) | 320 | AST_MEMBER(ForEach, &nameList, &loopValue, &body) |
| 319 | AST_END(ForEach) | 321 | AST_END(ForEach, "for_each"sv) |
| 320 | 322 | ||
| 321 | AST_NODE(Do) | 323 | AST_NODE(Do) |
| 322 | ast_ptr<true, Body_t> body; | 324 | ast_ptr<true, Body_t> body; |
| 323 | AST_MEMBER(Do, &body) | 325 | AST_MEMBER(Do, &body) |
| 324 | AST_END(Do) | 326 | AST_END(Do, "do"sv) |
| 325 | 327 | ||
| 326 | AST_NODE(catch_block) | 328 | AST_NODE(catch_block) |
| 327 | ast_ptr<true, Variable_t> err; | 329 | ast_ptr<true, Variable_t> err; |
| 328 | ast_ptr<true, Block_t> body; | 330 | ast_ptr<true, Block_t> body; |
| 329 | AST_MEMBER(catch_block, &err, &body) | 331 | AST_MEMBER(catch_block, &err, &body) |
| 330 | AST_END(catch_block) | 332 | AST_END(catch_block, "catch_block"sv) |
| 331 | 333 | ||
| 332 | AST_NODE(Try) | 334 | AST_NODE(Try) |
| 333 | ast_sel<true, Block_t, Exp_t> func; | 335 | ast_sel<true, Block_t, Exp_t> func; |
| 334 | ast_ptr<false, catch_block_t> catchBlock; | 336 | ast_ptr<false, catch_block_t> catchBlock; |
| 335 | AST_MEMBER(Try, &func, &catchBlock) | 337 | AST_MEMBER(Try, &func, &catchBlock) |
| 336 | AST_END(Try) | 338 | AST_END(Try, "try"sv) |
| 337 | 339 | ||
| 338 | class CompInner_t; | 340 | class CompInner_t; |
| 339 | 341 | ||
| @@ -341,30 +343,30 @@ AST_NODE(Comprehension) | |||
| 341 | ast_sel<true, Exp_t, Statement_t> value; | 343 | ast_sel<true, Exp_t, Statement_t> value; |
| 342 | ast_ptr<true, CompInner_t> forLoop; | 344 | ast_ptr<true, CompInner_t> forLoop; |
| 343 | AST_MEMBER(Comprehension, &value, &forLoop) | 345 | AST_MEMBER(Comprehension, &value, &forLoop) |
| 344 | AST_END(Comprehension) | 346 | AST_END(Comprehension, "comp"sv) |
| 345 | 347 | ||
| 346 | AST_NODE(comp_value) | 348 | AST_NODE(comp_value) |
| 347 | ast_ptr<true, Exp_t> value; | 349 | ast_ptr<true, Exp_t> value; |
| 348 | AST_MEMBER(comp_value, &value) | 350 | AST_MEMBER(comp_value, &value) |
| 349 | AST_END(comp_value) | 351 | AST_END(comp_value, "comp_value"sv) |
| 350 | 352 | ||
| 351 | AST_NODE(TblComprehension) | 353 | AST_NODE(TblComprehension) |
| 352 | ast_ptr<true, Exp_t> key; | 354 | ast_ptr<true, Exp_t> key; |
| 353 | ast_ptr<false, comp_value_t> value; | 355 | ast_ptr<false, comp_value_t> value; |
| 354 | ast_ptr<true, CompInner_t> forLoop; | 356 | ast_ptr<true, CompInner_t> forLoop; |
| 355 | AST_MEMBER(TblComprehension, &key, &value, &forLoop) | 357 | AST_MEMBER(TblComprehension, &key, &value, &forLoop) |
| 356 | AST_END(TblComprehension) | 358 | AST_END(TblComprehension, "tbl_comp"sv) |
| 357 | 359 | ||
| 358 | AST_NODE(star_exp) | 360 | AST_NODE(star_exp) |
| 359 | ast_ptr<true, Exp_t> value; | 361 | ast_ptr<true, Exp_t> value; |
| 360 | AST_MEMBER(star_exp, &value) | 362 | AST_MEMBER(star_exp, &value) |
| 361 | AST_END(star_exp) | 363 | AST_END(star_exp, "star_exp"sv) |
| 362 | 364 | ||
| 363 | AST_NODE(CompForEach) | 365 | AST_NODE(CompForEach) |
| 364 | ast_ptr<true, AssignableNameList_t> nameList; | 366 | ast_ptr<true, AssignableNameList_t> nameList; |
| 365 | ast_sel<true, star_exp_t, Exp_t> loopValue; | 367 | ast_sel<true, star_exp_t, Exp_t> loopValue; |
| 366 | AST_MEMBER(CompForEach, &nameList, &loopValue) | 368 | AST_MEMBER(CompForEach, &nameList, &loopValue) |
| 367 | AST_END(CompForEach) | 369 | AST_END(CompForEach, "comp_for_each"sv) |
| 368 | 370 | ||
| 369 | AST_NODE(CompFor) | 371 | AST_NODE(CompFor) |
| 370 | ast_ptr<true, Variable_t> varName; | 372 | ast_ptr<true, Variable_t> varName; |
| @@ -372,13 +374,13 @@ AST_NODE(CompFor) | |||
| 372 | ast_ptr<true, Exp_t> stopValue; | 374 | ast_ptr<true, Exp_t> stopValue; |
| 373 | ast_ptr<false, for_step_value_t> stepValue; | 375 | ast_ptr<false, for_step_value_t> stepValue; |
| 374 | AST_MEMBER(CompFor, &varName, &startValue, &stopValue, &stepValue) | 376 | AST_MEMBER(CompFor, &varName, &startValue, &stopValue, &stepValue) |
| 375 | AST_END(CompFor) | 377 | AST_END(CompFor, "comp_for"sv) |
| 376 | 378 | ||
| 377 | AST_NODE(CompInner) | 379 | AST_NODE(CompInner) |
| 378 | ast_ptr<true, Seperator_t> sep; | 380 | ast_ptr<true, Seperator_t> sep; |
| 379 | ast_sel_list<true, CompFor_t, CompForEach_t, Exp_t> items; | 381 | ast_sel_list<true, CompFor_t, CompForEach_t, Exp_t> items; |
| 380 | AST_MEMBER(CompInner, &sep, &items) | 382 | AST_MEMBER(CompInner, &sep, &items) |
| 381 | AST_END(CompInner) | 383 | AST_END(CompInner, "comp_inner"sv) |
| 382 | 384 | ||
| 383 | class TableBlock_t; | 385 | class TableBlock_t; |
| 384 | 386 | ||
| @@ -386,29 +388,29 @@ AST_NODE(Assign) | |||
| 386 | ast_ptr<true, Seperator_t> sep; | 388 | ast_ptr<true, Seperator_t> sep; |
| 387 | ast_sel_list<true, With_t, If_t, Switch_t, TableBlock_t, Exp_t> values; | 389 | ast_sel_list<true, With_t, If_t, Switch_t, TableBlock_t, Exp_t> values; |
| 388 | AST_MEMBER(Assign, &sep, &values) | 390 | AST_MEMBER(Assign, &sep, &values) |
| 389 | AST_END(Assign) | 391 | AST_END(Assign, "assign"sv) |
| 390 | 392 | ||
| 391 | AST_LEAF(update_op) | 393 | AST_LEAF(update_op) |
| 392 | AST_END(update_op) | 394 | AST_END(update_op, "update_op"sv) |
| 393 | 395 | ||
| 394 | AST_NODE(Update) | 396 | AST_NODE(Update) |
| 395 | ast_ptr<true, update_op_t> op; | 397 | ast_ptr<true, update_op_t> op; |
| 396 | ast_ptr<true, Exp_t> value; | 398 | ast_ptr<true, Exp_t> value; |
| 397 | AST_MEMBER(Update, &op, &value) | 399 | AST_MEMBER(Update, &op, &value) |
| 398 | AST_END(Update) | 400 | AST_END(Update, "update"sv) |
| 399 | 401 | ||
| 400 | AST_LEAF(BinaryOperator) | 402 | AST_LEAF(BinaryOperator) |
| 401 | AST_END(BinaryOperator) | 403 | AST_END(BinaryOperator, "binary_op"sv) |
| 402 | 404 | ||
| 403 | AST_LEAF(unary_operator) | 405 | AST_LEAF(unary_operator) |
| 404 | AST_END(unary_operator) | 406 | AST_END(unary_operator, "unary_op"sv) |
| 405 | 407 | ||
| 406 | class AssignableChain_t; | 408 | class AssignableChain_t; |
| 407 | 409 | ||
| 408 | AST_NODE(Assignable) | 410 | AST_NODE(Assignable) |
| 409 | ast_sel<true, AssignableChain_t, Variable_t, SelfName_t> item; | 411 | ast_sel<true, AssignableChain_t, Variable_t, SelfName_t> item; |
| 410 | AST_MEMBER(Assignable, &item) | 412 | AST_MEMBER(Assignable, &item) |
| 411 | AST_END(Assignable) | 413 | AST_END(Assignable, "assignable"sv) |
| 412 | 414 | ||
| 413 | class unary_exp_t; | 415 | class unary_exp_t; |
| 414 | 416 | ||
| @@ -416,7 +418,7 @@ AST_NODE(exp_op_value) | |||
| 416 | ast_ptr<true, BinaryOperator_t> op; | 418 | ast_ptr<true, BinaryOperator_t> op; |
| 417 | ast_list<true, unary_exp_t> pipeExprs; | 419 | ast_list<true, unary_exp_t> pipeExprs; |
| 418 | AST_MEMBER(exp_op_value, &op, &pipeExprs) | 420 | AST_MEMBER(exp_op_value, &op, &pipeExprs) |
| 419 | AST_END(exp_op_value) | 421 | AST_END(exp_op_value, "exp_op_value"sv) |
| 420 | 422 | ||
| 421 | AST_NODE(Exp) | 423 | AST_NODE(Exp) |
| 422 | ast_ptr<true, Seperator_t> sep; | 424 | ast_ptr<true, Seperator_t> sep; |
| @@ -424,7 +426,7 @@ AST_NODE(Exp) | |||
| 424 | ast_list<false, exp_op_value_t> opValues; | 426 | ast_list<false, exp_op_value_t> opValues; |
| 425 | ast_ptr<false, Exp_t> nilCoalesed; | 427 | ast_ptr<false, Exp_t> nilCoalesed; |
| 426 | AST_MEMBER(Exp, &sep, &pipeExprs, &opValues, &nilCoalesed) | 428 | AST_MEMBER(Exp, &sep, &pipeExprs, &opValues, &nilCoalesed) |
| 427 | AST_END(Exp) | 429 | AST_END(Exp, "exp"sv) |
| 428 | 430 | ||
| 429 | class Parens_t; | 431 | class Parens_t; |
| 430 | class MacroName_t; | 432 | class MacroName_t; |
| @@ -432,12 +434,12 @@ class MacroName_t; | |||
| 432 | AST_NODE(Callable) | 434 | AST_NODE(Callable) |
| 433 | ast_sel<true, Variable_t, SelfName_t, VarArg_t, Parens_t, MacroName_t> item; | 435 | ast_sel<true, Variable_t, SelfName_t, VarArg_t, Parens_t, MacroName_t> item; |
| 434 | AST_MEMBER(Callable, &item) | 436 | AST_MEMBER(Callable, &item) |
| 435 | AST_END(Callable) | 437 | AST_END(Callable, "callable"sv) |
| 436 | 438 | ||
| 437 | AST_NODE(variable_pair) | 439 | AST_NODE(variable_pair) |
| 438 | ast_ptr<true, Variable_t> name; | 440 | ast_ptr<true, Variable_t> name; |
| 439 | AST_MEMBER(variable_pair, &name) | 441 | AST_MEMBER(variable_pair, &name) |
| 440 | AST_END(variable_pair) | 442 | AST_END(variable_pair, "variable_pair"sv) |
| 441 | 443 | ||
| 442 | class DoubleString_t; | 444 | class DoubleString_t; |
| 443 | class SingleString_t; | 445 | class SingleString_t; |
| @@ -447,7 +449,7 @@ AST_NODE(normal_pair) | |||
| 447 | ast_sel<true, KeyName_t, Exp_t, DoubleString_t, SingleString_t, LuaString_t> key; | 449 | ast_sel<true, KeyName_t, Exp_t, DoubleString_t, SingleString_t, LuaString_t> key; |
| 448 | ast_sel<true, Exp_t, TableBlock_t> value; | 450 | ast_sel<true, Exp_t, TableBlock_t> value; |
| 449 | AST_MEMBER(normal_pair, &key, &value) | 451 | AST_MEMBER(normal_pair, &key, &value) |
| 450 | AST_END(normal_pair) | 452 | AST_END(normal_pair, "normal_pair"sv) |
| 451 | 453 | ||
| 452 | AST_NODE(default_pair) | 454 | AST_NODE(default_pair) |
| 453 | ast_sel<true, Variable_t, KeyName_t, Exp_t> key; | 455 | ast_sel<true, Variable_t, KeyName_t, Exp_t> key; |
| @@ -455,18 +457,18 @@ AST_NODE(default_pair) | |||
| 455 | ast_ptr<false, Exp_t> value; | 457 | ast_ptr<false, Exp_t> value; |
| 456 | ast_ptr<true, Exp_t> defVal; | 458 | ast_ptr<true, Exp_t> defVal; |
| 457 | AST_MEMBER(default_pair, &key, &sep, &value, &defVal) | 459 | AST_MEMBER(default_pair, &key, &sep, &value, &defVal) |
| 458 | AST_END(default_pair) | 460 | AST_END(default_pair, "default_pair"sv) |
| 459 | 461 | ||
| 460 | AST_NODE(meta_variable_pair) | 462 | AST_NODE(meta_variable_pair) |
| 461 | ast_ptr<true, Variable_t> name; | 463 | ast_ptr<true, Variable_t> name; |
| 462 | AST_MEMBER(meta_variable_pair, &name) | 464 | AST_MEMBER(meta_variable_pair, &name) |
| 463 | AST_END(meta_variable_pair) | 465 | AST_END(meta_variable_pair, "meta_variable_pair"sv) |
| 464 | 466 | ||
| 465 | AST_NODE(meta_normal_pair) | 467 | AST_NODE(meta_normal_pair) |
| 466 | ast_sel<false, Name_t, Exp_t> key; | 468 | ast_sel<false, Name_t, Exp_t> key; |
| 467 | ast_sel<true, Exp_t, TableBlock_t> value; | 469 | ast_sel<true, Exp_t, TableBlock_t> value; |
| 468 | AST_MEMBER(meta_normal_pair, &key, &value) | 470 | AST_MEMBER(meta_normal_pair, &key, &value) |
| 469 | AST_END(meta_normal_pair) | 471 | AST_END(meta_normal_pair, "meta_normal_pair"sv) |
| 470 | 472 | ||
| 471 | AST_NODE(meta_default_pair) | 473 | AST_NODE(meta_default_pair) |
| 472 | ast_sel<false, Variable_t, Name_t> key; | 474 | ast_sel<false, Variable_t, Name_t> key; |
| @@ -474,13 +476,13 @@ AST_NODE(meta_default_pair) | |||
| 474 | ast_ptr<false, Exp_t> value; | 476 | ast_ptr<false, Exp_t> value; |
| 475 | ast_ptr<true, Exp_t> defVal; | 477 | ast_ptr<true, Exp_t> defVal; |
| 476 | AST_MEMBER(meta_default_pair, &key, &sep, &value, &defVal) | 478 | AST_MEMBER(meta_default_pair, &key, &sep, &value, &defVal) |
| 477 | AST_END(meta_default_pair) | 479 | AST_END(meta_default_pair, "meta_default_pair"sv) |
| 478 | 480 | ||
| 479 | AST_NODE(simple_table) | 481 | AST_NODE(simple_table) |
| 480 | ast_ptr<true, Seperator_t> sep; | 482 | ast_ptr<true, Seperator_t> sep; |
| 481 | ast_sel_list<true, variable_pair_t, normal_pair_t, meta_variable_pair_t, meta_normal_pair_t> pairs; | 483 | ast_sel_list<true, variable_pair_t, normal_pair_t, meta_variable_pair_t, meta_normal_pair_t> pairs; |
| 482 | AST_MEMBER(simple_table, &sep, &pairs) | 484 | AST_MEMBER(simple_table, &sep, &pairs) |
| 483 | AST_END(simple_table) | 485 | AST_END(simple_table, "simple_table"sv) |
| 484 | 486 | ||
| 485 | class String_t; | 487 | class String_t; |
| 486 | class const_value_t; | 488 | class const_value_t; |
| @@ -497,64 +499,64 @@ AST_NODE(SimpleValue) | |||
| 497 | TblComprehension_t, TableLit_t, Comprehension_t, | 499 | TblComprehension_t, TableLit_t, Comprehension_t, |
| 498 | FunLit_t, Num_t> value; | 500 | FunLit_t, Num_t> value; |
| 499 | AST_MEMBER(SimpleValue, &value) | 501 | AST_MEMBER(SimpleValue, &value) |
| 500 | AST_END(SimpleValue) | 502 | AST_END(SimpleValue, "simple_value"sv) |
| 501 | 503 | ||
| 502 | AST_LEAF(LuaStringOpen) | 504 | AST_LEAF(LuaStringOpen) |
| 503 | AST_END(LuaStringOpen) | 505 | AST_END(LuaStringOpen, "lua_string_open"sv) |
| 504 | 506 | ||
| 505 | AST_LEAF(LuaStringContent) | 507 | AST_LEAF(LuaStringContent) |
| 506 | AST_END(LuaStringContent) | 508 | AST_END(LuaStringContent, "lua_string_content"sv) |
| 507 | 509 | ||
| 508 | AST_LEAF(LuaStringClose) | 510 | AST_LEAF(LuaStringClose) |
| 509 | AST_END(LuaStringClose) | 511 | AST_END(LuaStringClose, "lua_string_close"sv) |
| 510 | 512 | ||
| 511 | AST_NODE(LuaString) | 513 | AST_NODE(LuaString) |
| 512 | ast_ptr<true, LuaStringOpen_t> open; | 514 | ast_ptr<true, LuaStringOpen_t> open; |
| 513 | ast_ptr<true, LuaStringContent_t> content; | 515 | ast_ptr<true, LuaStringContent_t> content; |
| 514 | ast_ptr<true, LuaStringClose_t> close; | 516 | ast_ptr<true, LuaStringClose_t> close; |
| 515 | AST_MEMBER(LuaString, &open, &content, &close) | 517 | AST_MEMBER(LuaString, &open, &content, &close) |
| 516 | AST_END(LuaString) | 518 | AST_END(LuaString, "lua_string"sv) |
| 517 | 519 | ||
| 518 | AST_LEAF(SingleString) | 520 | AST_LEAF(SingleString) |
| 519 | AST_END(SingleString) | 521 | AST_END(SingleString, "single_string"sv) |
| 520 | 522 | ||
| 521 | AST_LEAF(double_string_inner) | 523 | AST_LEAF(double_string_inner) |
| 522 | AST_END(double_string_inner) | 524 | AST_END(double_string_inner, "double_string_inner"sv) |
| 523 | 525 | ||
| 524 | AST_NODE(double_string_content) | 526 | AST_NODE(double_string_content) |
| 525 | ast_sel<true, double_string_inner_t, Exp_t> content; | 527 | ast_sel<true, double_string_inner_t, Exp_t> content; |
| 526 | AST_MEMBER(double_string_content, &content) | 528 | AST_MEMBER(double_string_content, &content) |
| 527 | AST_END(double_string_content) | 529 | AST_END(double_string_content, "double_string_content"sv) |
| 528 | 530 | ||
| 529 | AST_NODE(DoubleString) | 531 | AST_NODE(DoubleString) |
| 530 | ast_ptr<true, Seperator_t> sep; | 532 | ast_ptr<true, Seperator_t> sep; |
| 531 | ast_list<false, double_string_content_t> segments; | 533 | ast_list<false, double_string_content_t> segments; |
| 532 | AST_MEMBER(DoubleString, &sep, &segments) | 534 | AST_MEMBER(DoubleString, &sep, &segments) |
| 533 | AST_END(DoubleString) | 535 | AST_END(DoubleString, "double_string"sv) |
| 534 | 536 | ||
| 535 | AST_NODE(String) | 537 | AST_NODE(String) |
| 536 | ast_sel<true, DoubleString_t, SingleString_t, LuaString_t> str; | 538 | ast_sel<true, DoubleString_t, SingleString_t, LuaString_t> str; |
| 537 | AST_MEMBER(String, &str) | 539 | AST_MEMBER(String, &str) |
| 538 | AST_END(String) | 540 | AST_END(String, "string"sv) |
| 539 | 541 | ||
| 540 | AST_LEAF(Metatable) | 542 | AST_LEAF(Metatable) |
| 541 | AST_END(Metatable) | 543 | AST_END(Metatable, "metatable"sv) |
| 542 | 544 | ||
| 543 | AST_NODE(Metamethod) | 545 | AST_NODE(Metamethod) |
| 544 | ast_ptr<true, Name_t> name; | 546 | ast_ptr<true, Name_t> name; |
| 545 | AST_MEMBER(Metamethod, &name) | 547 | AST_MEMBER(Metamethod, &name) |
| 546 | AST_END(Metamethod) | 548 | AST_END(Metamethod, "metamethod"sv) |
| 547 | 549 | ||
| 548 | AST_NODE(DotChainItem) | 550 | AST_NODE(DotChainItem) |
| 549 | ast_sel<true, Name_t, Metatable_t, Metamethod_t> name; | 551 | ast_sel<true, Name_t, Metatable_t, Metamethod_t> name; |
| 550 | AST_MEMBER(DotChainItem, &name) | 552 | AST_MEMBER(DotChainItem, &name) |
| 551 | AST_END(DotChainItem) | 553 | AST_END(DotChainItem, "dot_chain_item"sv) |
| 552 | 554 | ||
| 553 | AST_NODE(ColonChainItem) | 555 | AST_NODE(ColonChainItem) |
| 554 | ast_sel<true, LuaKeyword_t, Name_t, Metamethod_t> name; | 556 | ast_sel<true, LuaKeyword_t, Name_t, Metamethod_t> name; |
| 555 | bool switchToDot = false; | 557 | bool switchToDot = false; |
| 556 | AST_MEMBER(ColonChainItem, &name) | 558 | AST_MEMBER(ColonChainItem, &name) |
| 557 | AST_END(ColonChainItem) | 559 | AST_END(ColonChainItem, "colon_chain_item"sv) |
| 558 | 560 | ||
| 559 | class default_value_t; | 561 | class default_value_t; |
| 560 | 562 | ||
| @@ -563,24 +565,24 @@ AST_NODE(Slice) | |||
| 563 | ast_sel<true, Exp_t, default_value_t> stopValue; | 565 | ast_sel<true, Exp_t, default_value_t> stopValue; |
| 564 | ast_sel<true, Exp_t, default_value_t> stepValue; | 566 | ast_sel<true, Exp_t, default_value_t> stepValue; |
| 565 | AST_MEMBER(Slice, &startValue, &stopValue, &stepValue) | 567 | AST_MEMBER(Slice, &startValue, &stopValue, &stepValue) |
| 566 | AST_END(Slice) | 568 | AST_END(Slice, "slice"sv) |
| 567 | 569 | ||
| 568 | AST_NODE(Parens) | 570 | AST_NODE(Parens) |
| 569 | ast_ptr<true, Exp_t> expr; | 571 | ast_ptr<true, Exp_t> expr; |
| 570 | AST_MEMBER(Parens, &expr) | 572 | AST_MEMBER(Parens, &expr) |
| 571 | AST_END(Parens) | 573 | AST_END(Parens, "parens"sv) |
| 572 | 574 | ||
| 573 | AST_NODE(Invoke) | 575 | AST_NODE(Invoke) |
| 574 | ast_ptr<true, Seperator_t> sep; | 576 | ast_ptr<true, Seperator_t> sep; |
| 575 | ast_sel_list<false, Exp_t, SingleString_t, DoubleString_t, LuaString_t, TableLit_t> args; | 577 | ast_sel_list<false, Exp_t, SingleString_t, DoubleString_t, LuaString_t, TableLit_t> args; |
| 576 | AST_MEMBER(Invoke, &sep, &args) | 578 | AST_MEMBER(Invoke, &sep, &args) |
| 577 | AST_END(Invoke) | 579 | AST_END(Invoke, "invoke"sv) |
| 578 | 580 | ||
| 579 | AST_LEAF(existential_op) | 581 | AST_LEAF(existential_op) |
| 580 | AST_END(existential_op) | 582 | AST_END(existential_op, "existential_op"sv) |
| 581 | 583 | ||
| 582 | AST_LEAF(table_appending_op) | 584 | AST_LEAF(table_appending_op) |
| 583 | AST_END(table_appending_op) | 585 | AST_END(table_appending_op, "table_appending_op"sv) |
| 584 | 586 | ||
| 585 | class InvokeArgs_t; | 587 | class InvokeArgs_t; |
| 586 | 588 | ||
| @@ -588,21 +590,21 @@ AST_NODE(ChainValue) | |||
| 588 | ast_ptr<true, Seperator_t> sep; | 590 | ast_ptr<true, Seperator_t> sep; |
| 589 | ast_sel_list<true, Callable_t, Invoke_t, DotChainItem_t, ColonChainItem_t, Slice_t, Exp_t, String_t, InvokeArgs_t, existential_op_t, table_appending_op_t> items; | 591 | ast_sel_list<true, Callable_t, Invoke_t, DotChainItem_t, ColonChainItem_t, Slice_t, Exp_t, String_t, InvokeArgs_t, existential_op_t, table_appending_op_t> items; |
| 590 | AST_MEMBER(ChainValue, &sep, &items) | 592 | AST_MEMBER(ChainValue, &sep, &items) |
| 591 | AST_END(ChainValue) | 593 | AST_END(ChainValue, "chain_value"sv) |
| 592 | 594 | ||
| 593 | AST_NODE(AssignableChain) | 595 | AST_NODE(AssignableChain) |
| 594 | ast_ptr<true, Seperator_t> sep; | 596 | ast_ptr<true, Seperator_t> sep; |
| 595 | ast_sel_list<true, Callable_t, Invoke_t, DotChainItem_t, ColonChainItem_t, Exp_t, String_t> items; | 597 | ast_sel_list<true, Callable_t, Invoke_t, DotChainItem_t, ColonChainItem_t, Exp_t, String_t> items; |
| 596 | AST_MEMBER(AssignableChain, &sep, &items) | 598 | AST_MEMBER(AssignableChain, &sep, &items) |
| 597 | AST_END(AssignableChain) | 599 | AST_END(AssignableChain, "assignable_chain"sv) |
| 598 | 600 | ||
| 599 | AST_NODE(Value) | 601 | AST_NODE(Value) |
| 600 | ast_sel<true, SimpleValue_t, simple_table_t, ChainValue_t, String_t> item; | 602 | ast_sel<true, SimpleValue_t, simple_table_t, ChainValue_t, String_t> item; |
| 601 | AST_MEMBER(Value, &item) | 603 | AST_MEMBER(Value, &item) |
| 602 | AST_END(Value) | 604 | AST_END(Value, "value"sv) |
| 603 | 605 | ||
| 604 | AST_LEAF(default_value) | 606 | AST_LEAF(default_value) |
| 605 | AST_END(default_value) | 607 | AST_END(default_value, "default_value"sv) |
| 606 | 608 | ||
| 607 | class default_pair_t; | 609 | class default_pair_t; |
| 608 | class meta_default_pair_t; | 610 | class meta_default_pair_t; |
| @@ -610,7 +612,7 @@ class meta_default_pair_t; | |||
| 610 | AST_NODE(SpreadExp) | 612 | AST_NODE(SpreadExp) |
| 611 | ast_ptr<true, Exp_t> exp; | 613 | ast_ptr<true, Exp_t> exp; |
| 612 | AST_MEMBER(SpreadExp, &exp) | 614 | AST_MEMBER(SpreadExp, &exp) |
| 613 | AST_END(SpreadExp) | 615 | AST_END(SpreadExp, "spread_exp"sv) |
| 614 | 616 | ||
| 615 | AST_NODE(TableLit) | 617 | AST_NODE(TableLit) |
| 616 | ast_ptr<true, Seperator_t> sep; | 618 | ast_ptr<true, Seperator_t> sep; |
| @@ -618,7 +620,7 @@ AST_NODE(TableLit) | |||
| 618 | variable_pair_t, normal_pair_t, SpreadExp_t, Exp_t, default_pair_t, | 620 | variable_pair_t, normal_pair_t, SpreadExp_t, Exp_t, default_pair_t, |
| 619 | meta_variable_pair_t, meta_normal_pair_t, meta_default_pair_t> values; | 621 | meta_variable_pair_t, meta_normal_pair_t, meta_default_pair_t> values; |
| 620 | AST_MEMBER(TableLit, &sep, &values) | 622 | AST_MEMBER(TableLit, &sep, &values) |
| 621 | AST_END(TableLit) | 623 | AST_END(TableLit, "table_lit"sv) |
| 622 | 624 | ||
| 623 | AST_NODE(TableBlockIndent) | 625 | AST_NODE(TableBlockIndent) |
| 624 | ast_ptr<true, Seperator_t> sep; | 626 | ast_ptr<true, Seperator_t> sep; |
| @@ -626,26 +628,26 @@ AST_NODE(TableBlockIndent) | |||
| 626 | variable_pair_t, normal_pair_t, TableBlockIndent_t, default_pair_t, | 628 | variable_pair_t, normal_pair_t, TableBlockIndent_t, default_pair_t, |
| 627 | meta_variable_pair_t, meta_normal_pair_t, meta_default_pair_t> values; | 629 | meta_variable_pair_t, meta_normal_pair_t, meta_default_pair_t> values; |
| 628 | AST_MEMBER(TableBlockIndent, &sep, &values) | 630 | AST_MEMBER(TableBlockIndent, &sep, &values) |
| 629 | AST_END(TableBlockIndent) | 631 | AST_END(TableBlockIndent, "table_block_indent"sv) |
| 630 | 632 | ||
| 631 | AST_NODE(TableBlock) | 633 | AST_NODE(TableBlock) |
| 632 | ast_ptr<true, Seperator_t> sep; | 634 | ast_ptr<true, Seperator_t> sep; |
| 633 | ast_sel_list<false, variable_pair_t, normal_pair_t, TableBlockIndent_t, Exp_t, TableBlock_t, SpreadExp_t, default_pair_t, | 635 | ast_sel_list<false, variable_pair_t, normal_pair_t, TableBlockIndent_t, Exp_t, TableBlock_t, SpreadExp_t, default_pair_t, |
| 634 | meta_variable_pair_t, meta_normal_pair_t, meta_default_pair_t> values; | 636 | meta_variable_pair_t, meta_normal_pair_t, meta_default_pair_t> values; |
| 635 | AST_MEMBER(TableBlock, &sep, &values) | 637 | AST_MEMBER(TableBlock, &sep, &values) |
| 636 | AST_END(TableBlock) | 638 | AST_END(TableBlock, "table_block"sv) |
| 637 | 639 | ||
| 638 | AST_NODE(class_member_list) | 640 | AST_NODE(class_member_list) |
| 639 | ast_ptr<true, Seperator_t> sep; | 641 | ast_ptr<true, Seperator_t> sep; |
| 640 | ast_sel_list<true, variable_pair_t, normal_pair_t> values; | 642 | ast_sel_list<true, variable_pair_t, normal_pair_t> values; |
| 641 | AST_MEMBER(class_member_list, &sep, &values) | 643 | AST_MEMBER(class_member_list, &sep, &values) |
| 642 | AST_END(class_member_list) | 644 | AST_END(class_member_list, "class_member_list"sv) |
| 643 | 645 | ||
| 644 | AST_NODE(ClassBlock) | 646 | AST_NODE(ClassBlock) |
| 645 | ast_ptr<true, Seperator_t> sep; | 647 | ast_ptr<true, Seperator_t> sep; |
| 646 | ast_sel_list<true, class_member_list_t, Statement_t> contents; | 648 | ast_sel_list<true, class_member_list_t, Statement_t> contents; |
| 647 | AST_MEMBER(ClassBlock, &sep, &contents) | 649 | AST_MEMBER(ClassBlock, &sep, &contents) |
| 648 | AST_END(ClassBlock) | 650 | AST_END(ClassBlock, "class_block"sv) |
| 649 | 651 | ||
| 650 | AST_NODE(ClassDecl) | 652 | AST_NODE(ClassDecl) |
| 651 | ast_ptr<false, Assignable_t> name; | 653 | ast_ptr<false, Assignable_t> name; |
| @@ -653,24 +655,24 @@ AST_NODE(ClassDecl) | |||
| 653 | ast_ptr<false, ExpList_t> mixes; | 655 | ast_ptr<false, ExpList_t> mixes; |
| 654 | ast_ptr<false, ClassBlock_t> body; | 656 | ast_ptr<false, ClassBlock_t> body; |
| 655 | AST_MEMBER(ClassDecl, &name, &extend, &mixes, &body) | 657 | AST_MEMBER(ClassDecl, &name, &extend, &mixes, &body) |
| 656 | AST_END(ClassDecl) | 658 | AST_END(ClassDecl, "class_decl"sv) |
| 657 | 659 | ||
| 658 | AST_NODE(global_values) | 660 | AST_NODE(global_values) |
| 659 | ast_ptr<true, NameList_t> nameList; | 661 | ast_ptr<true, NameList_t> nameList; |
| 660 | ast_sel<false, TableBlock_t, ExpListLow_t> valueList; | 662 | ast_sel<false, TableBlock_t, ExpListLow_t> valueList; |
| 661 | AST_MEMBER(global_values, &nameList, &valueList) | 663 | AST_MEMBER(global_values, &nameList, &valueList) |
| 662 | AST_END(global_values) | 664 | AST_END(global_values, "global_values"sv) |
| 663 | 665 | ||
| 664 | AST_LEAF(global_op) | 666 | AST_LEAF(global_op) |
| 665 | AST_END(global_op) | 667 | AST_END(global_op, "global_op"sv) |
| 666 | 668 | ||
| 667 | AST_NODE(Global) | 669 | AST_NODE(Global) |
| 668 | ast_sel<true, ClassDecl_t, global_op_t, global_values_t> item; | 670 | ast_sel<true, ClassDecl_t, global_op_t, global_values_t> item; |
| 669 | AST_MEMBER(Global, &item) | 671 | AST_MEMBER(Global, &item) |
| 670 | AST_END(Global) | 672 | AST_END(Global, "global"sv) |
| 671 | 673 | ||
| 672 | AST_LEAF(export_default) | 674 | AST_LEAF(export_default) |
| 673 | AST_END(export_default) | 675 | AST_END(export_default, "export_default"sv) |
| 674 | 676 | ||
| 675 | class Macro_t; | 677 | class Macro_t; |
| 676 | 678 | ||
| @@ -679,125 +681,125 @@ AST_NODE(Export) | |||
| 679 | ast_sel<true, ExpList_t, Exp_t, Macro_t> target; | 681 | ast_sel<true, ExpList_t, Exp_t, Macro_t> target; |
| 680 | ast_ptr<false, Assign_t> assign; | 682 | ast_ptr<false, Assign_t> assign; |
| 681 | AST_MEMBER(Export, &def, &target, &assign) | 683 | AST_MEMBER(Export, &def, &target, &assign) |
| 682 | AST_END(Export) | 684 | AST_END(Export, "export"sv) |
| 683 | 685 | ||
| 684 | AST_NODE(FnArgDef) | 686 | AST_NODE(FnArgDef) |
| 685 | ast_sel<true, Variable_t, SelfName_t> name; | 687 | ast_sel<true, Variable_t, SelfName_t> name; |
| 686 | ast_ptr<false, existential_op_t> op; | 688 | ast_ptr<false, existential_op_t> op; |
| 687 | ast_ptr<false, Exp_t> defaultValue; | 689 | ast_ptr<false, Exp_t> defaultValue; |
| 688 | AST_MEMBER(FnArgDef, &name, &op, &defaultValue) | 690 | AST_MEMBER(FnArgDef, &name, &op, &defaultValue) |
| 689 | AST_END(FnArgDef) | 691 | AST_END(FnArgDef, "fn_arg_def"sv) |
| 690 | 692 | ||
| 691 | AST_NODE(FnArgDefList) | 693 | AST_NODE(FnArgDefList) |
| 692 | ast_ptr<true, Seperator_t> sep; | 694 | ast_ptr<true, Seperator_t> sep; |
| 693 | ast_list<false, FnArgDef_t> definitions; | 695 | ast_list<false, FnArgDef_t> definitions; |
| 694 | ast_ptr<false, VarArg_t> varArg; | 696 | ast_ptr<false, VarArg_t> varArg; |
| 695 | AST_MEMBER(FnArgDefList, &sep, &definitions, &varArg) | 697 | AST_MEMBER(FnArgDefList, &sep, &definitions, &varArg) |
| 696 | AST_END(FnArgDefList) | 698 | AST_END(FnArgDefList, "fn_arg_def_list"sv) |
| 697 | 699 | ||
| 698 | AST_NODE(outer_var_shadow) | 700 | AST_NODE(outer_var_shadow) |
| 699 | ast_ptr<false, NameList_t> varList; | 701 | ast_ptr<false, NameList_t> varList; |
| 700 | AST_MEMBER(outer_var_shadow, &varList) | 702 | AST_MEMBER(outer_var_shadow, &varList) |
| 701 | AST_END(outer_var_shadow) | 703 | AST_END(outer_var_shadow, "outer_var_shadow"sv) |
| 702 | 704 | ||
| 703 | AST_NODE(FnArgsDef) | 705 | AST_NODE(FnArgsDef) |
| 704 | ast_ptr<false, FnArgDefList_t> defList; | 706 | ast_ptr<false, FnArgDefList_t> defList; |
| 705 | ast_ptr<false, outer_var_shadow_t> shadowOption; | 707 | ast_ptr<false, outer_var_shadow_t> shadowOption; |
| 706 | AST_MEMBER(FnArgsDef, &defList, &shadowOption) | 708 | AST_MEMBER(FnArgsDef, &defList, &shadowOption) |
| 707 | AST_END(FnArgsDef) | 709 | AST_END(FnArgsDef, "fn_args_def"sv) |
| 708 | 710 | ||
| 709 | AST_LEAF(fn_arrow) | 711 | AST_LEAF(fn_arrow) |
| 710 | AST_END(fn_arrow) | 712 | AST_END(fn_arrow, "fn_arrow"sv) |
| 711 | 713 | ||
| 712 | AST_NODE(FunLit) | 714 | AST_NODE(FunLit) |
| 713 | ast_ptr<false, FnArgsDef_t> argsDef; | 715 | ast_ptr<false, FnArgsDef_t> argsDef; |
| 714 | ast_ptr<true, fn_arrow_t> arrow; | 716 | ast_ptr<true, fn_arrow_t> arrow; |
| 715 | ast_ptr<false, Body_t> body; | 717 | ast_ptr<false, Body_t> body; |
| 716 | AST_MEMBER(FunLit, &argsDef, &arrow, &body) | 718 | AST_MEMBER(FunLit, &argsDef, &arrow, &body) |
| 717 | AST_END(FunLit) | 719 | AST_END(FunLit, "fun_lit"sv) |
| 718 | 720 | ||
| 719 | AST_NODE(MacroName) | 721 | AST_NODE(MacroName) |
| 720 | ast_ptr<true, Name_t> name; | 722 | ast_ptr<true, Name_t> name; |
| 721 | AST_MEMBER(MacroName, &name) | 723 | AST_MEMBER(MacroName, &name) |
| 722 | AST_END(MacroName) | 724 | AST_END(MacroName, "macro_name"sv) |
| 723 | 725 | ||
| 724 | AST_NODE(MacroLit) | 726 | AST_NODE(MacroLit) |
| 725 | ast_ptr<false, FnArgDefList_t> argsDef; | 727 | ast_ptr<false, FnArgDefList_t> argsDef; |
| 726 | ast_ptr<true, Body_t> body; | 728 | ast_ptr<true, Body_t> body; |
| 727 | AST_MEMBER(MacroLit, &argsDef, &body) | 729 | AST_MEMBER(MacroLit, &argsDef, &body) |
| 728 | AST_END(MacroLit) | 730 | AST_END(MacroLit, "macro_lit"sv) |
| 729 | 731 | ||
| 730 | AST_NODE(MacroInPlace) | 732 | AST_NODE(MacroInPlace) |
| 731 | ast_ptr<true, Body_t> body; | 733 | ast_ptr<true, Body_t> body; |
| 732 | AST_MEMBER(MacroInPlace, &body) | 734 | AST_MEMBER(MacroInPlace, &body) |
| 733 | AST_END(MacroInPlace) | 735 | AST_END(MacroInPlace, "macro_in_place"sv) |
| 734 | 736 | ||
| 735 | AST_NODE(Macro) | 737 | AST_NODE(Macro) |
| 736 | ast_ptr<true, Name_t> name; | 738 | ast_ptr<true, Name_t> name; |
| 737 | ast_ptr<true, MacroLit_t> macroLit; | 739 | ast_ptr<true, MacroLit_t> macroLit; |
| 738 | AST_MEMBER(Macro, &name, ¯oLit) | 740 | AST_MEMBER(Macro, &name, ¯oLit) |
| 739 | AST_END(Macro) | 741 | AST_END(Macro, "macro"sv) |
| 740 | 742 | ||
| 741 | AST_NODE(NameOrDestructure) | 743 | AST_NODE(NameOrDestructure) |
| 742 | ast_sel<true, Variable_t, TableLit_t> item; | 744 | ast_sel<true, Variable_t, TableLit_t> item; |
| 743 | AST_MEMBER(NameOrDestructure, &item) | 745 | AST_MEMBER(NameOrDestructure, &item) |
| 744 | AST_END(NameOrDestructure) | 746 | AST_END(NameOrDestructure, "name_or_des"sv) |
| 745 | 747 | ||
| 746 | AST_NODE(AssignableNameList) | 748 | AST_NODE(AssignableNameList) |
| 747 | ast_ptr<true, Seperator_t> sep; | 749 | ast_ptr<true, Seperator_t> sep; |
| 748 | ast_list<true, NameOrDestructure_t> items; | 750 | ast_list<true, NameOrDestructure_t> items; |
| 749 | AST_MEMBER(AssignableNameList, &sep, &items) | 751 | AST_MEMBER(AssignableNameList, &sep, &items) |
| 750 | AST_END(AssignableNameList) | 752 | AST_END(AssignableNameList, "assignable_name_list"sv) |
| 751 | 753 | ||
| 752 | AST_NODE(InvokeArgs) | 754 | AST_NODE(InvokeArgs) |
| 753 | ast_ptr<true, Seperator_t> sep; | 755 | ast_ptr<true, Seperator_t> sep; |
| 754 | ast_sel_list<true, Exp_t, TableBlock_t> args; | 756 | ast_sel_list<true, Exp_t, TableBlock_t> args; |
| 755 | AST_MEMBER(InvokeArgs, &sep, &args) | 757 | AST_MEMBER(InvokeArgs, &sep, &args) |
| 756 | AST_END(InvokeArgs) | 758 | AST_END(InvokeArgs, "invoke_args"sv) |
| 757 | 759 | ||
| 758 | AST_LEAF(const_value) | 760 | AST_LEAF(const_value) |
| 759 | AST_END(const_value) | 761 | AST_END(const_value, "const_value"sv) |
| 760 | 762 | ||
| 761 | AST_NODE(unary_value) | 763 | AST_NODE(unary_value) |
| 762 | ast_list<true, unary_operator_t> ops; | 764 | ast_list<true, unary_operator_t> ops; |
| 763 | ast_ptr<true, Value_t> value; | 765 | ast_ptr<true, Value_t> value; |
| 764 | AST_MEMBER(unary_value, &ops, &value) | 766 | AST_MEMBER(unary_value, &ops, &value) |
| 765 | AST_END(unary_value) | 767 | AST_END(unary_value, "unary_value"sv) |
| 766 | 768 | ||
| 767 | AST_NODE(unary_exp) | 769 | AST_NODE(unary_exp) |
| 768 | ast_list<false, unary_operator_t> ops; | 770 | ast_list<false, unary_operator_t> ops; |
| 769 | ast_list<true, Value_t> expos; | 771 | ast_list<true, Value_t> expos; |
| 770 | AST_MEMBER(unary_exp, &ops, &expos) | 772 | AST_MEMBER(unary_exp, &ops, &expos) |
| 771 | AST_END(unary_exp) | 773 | AST_END(unary_exp, "unary_exp"sv) |
| 772 | 774 | ||
| 773 | AST_NODE(ExpListAssign) | 775 | AST_NODE(ExpListAssign) |
| 774 | ast_ptr<true, ExpList_t> expList; | 776 | ast_ptr<true, ExpList_t> expList; |
| 775 | ast_sel<false, Update_t, Assign_t> action; | 777 | ast_sel<false, Update_t, Assign_t> action; |
| 776 | AST_MEMBER(ExpListAssign, &expList, &action) | 778 | AST_MEMBER(ExpListAssign, &expList, &action) |
| 777 | AST_END(ExpListAssign) | 779 | AST_END(ExpListAssign, "exp_list_assign"sv) |
| 778 | 780 | ||
| 779 | AST_NODE(if_line) | 781 | AST_NODE(if_line) |
| 780 | ast_ptr<true, IfType_t> type; | 782 | ast_ptr<true, IfType_t> type; |
| 781 | ast_ptr<true, IfCond_t> condition; | 783 | ast_ptr<true, IfCond_t> condition; |
| 782 | AST_MEMBER(if_line, &type, &condition) | 784 | AST_MEMBER(if_line, &type, &condition) |
| 783 | AST_END(if_line) | 785 | AST_END(if_line, "if_line"sv) |
| 784 | 786 | ||
| 785 | AST_LEAF(BreakLoop) | 787 | AST_LEAF(BreakLoop) |
| 786 | AST_END(BreakLoop) | 788 | AST_END(BreakLoop, "break_loop"sv) |
| 787 | 789 | ||
| 788 | AST_NODE(PipeBody) | 790 | AST_NODE(PipeBody) |
| 789 | ast_ptr<true, Seperator_t> sep; | 791 | ast_ptr<true, Seperator_t> sep; |
| 790 | ast_list<true, unary_exp_t> values; | 792 | ast_list<true, unary_exp_t> values; |
| 791 | AST_MEMBER(PipeBody, &sep, &values) | 793 | AST_MEMBER(PipeBody, &sep, &values) |
| 792 | AST_END(PipeBody) | 794 | AST_END(PipeBody, "pipe_body"sv) |
| 793 | 795 | ||
| 794 | AST_NODE(statement_appendix) | 796 | AST_NODE(statement_appendix) |
| 795 | ast_sel<true, if_line_t, CompInner_t> item; | 797 | ast_sel<true, if_line_t, CompInner_t> item; |
| 796 | AST_MEMBER(statement_appendix, &item) | 798 | AST_MEMBER(statement_appendix, &item) |
| 797 | AST_END(statement_appendix) | 799 | AST_END(statement_appendix, "statement_appendix"sv) |
| 798 | 800 | ||
| 799 | AST_LEAF(statement_sep) | 801 | AST_LEAF(statement_sep) |
| 800 | AST_END(statement_sep) | 802 | AST_END(statement_sep, "statement_sep"sv) |
| 801 | 803 | ||
| 802 | AST_NODE(Statement) | 804 | AST_NODE(Statement) |
| 803 | ast_sel<true, Import_t, While_t, Repeat_t, For_t, ForEach_t, | 805 | ast_sel<true, Import_t, While_t, Repeat_t, For_t, ForEach_t, |
| @@ -807,29 +809,29 @@ AST_NODE(Statement) | |||
| 807 | ast_ptr<false, statement_appendix_t> appendix; | 809 | ast_ptr<false, statement_appendix_t> appendix; |
| 808 | ast_ptr<false, statement_sep_t> needSep; | 810 | ast_ptr<false, statement_sep_t> needSep; |
| 809 | AST_MEMBER(Statement, &content, &appendix, &needSep) | 811 | AST_MEMBER(Statement, &content, &appendix, &needSep) |
| 810 | AST_END(Statement) | 812 | AST_END(Statement, "statement"sv) |
| 811 | 813 | ||
| 812 | class Block_t; | 814 | class Block_t; |
| 813 | 815 | ||
| 814 | AST_NODE(Body) | 816 | AST_NODE(Body) |
| 815 | ast_sel<true, Block_t, Statement_t> content; | 817 | ast_sel<true, Block_t, Statement_t> content; |
| 816 | AST_MEMBER(Body, &content) | 818 | AST_MEMBER(Body, &content) |
| 817 | AST_END(Body) | 819 | AST_END(Body, "body"sv) |
| 818 | 820 | ||
| 819 | AST_NODE(Block) | 821 | AST_NODE(Block) |
| 820 | ast_ptr<true, Seperator_t> sep; | 822 | ast_ptr<true, Seperator_t> sep; |
| 821 | ast_list<false, Statement_t> statements; | 823 | ast_list<false, Statement_t> statements; |
| 822 | AST_MEMBER(Block, &sep, &statements) | 824 | AST_MEMBER(Block, &sep, &statements) |
| 823 | AST_END(Block) | 825 | AST_END(Block, "block"sv) |
| 824 | 826 | ||
| 825 | AST_NODE(BlockEnd) | 827 | AST_NODE(BlockEnd) |
| 826 | ast_ptr<true, Block_t> block; | 828 | ast_ptr<true, Block_t> block; |
| 827 | AST_MEMBER(BlockEnd, &block) | 829 | AST_MEMBER(BlockEnd, &block) |
| 828 | AST_END(BlockEnd) | 830 | AST_END(BlockEnd, "block_end"sv) |
| 829 | 831 | ||
| 830 | AST_NODE(File) | 832 | AST_NODE(File) |
| 831 | ast_ptr<false, Block_t> block; | 833 | ast_ptr<false, Block_t> block; |
| 832 | AST_MEMBER(File, &block) | 834 | AST_MEMBER(File, &block) |
| 833 | AST_END(File) | 835 | AST_END(File, "file"sv) |
| 834 | 836 | ||
| 835 | } // namespace parserlib | 837 | } // namespace parserlib |
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index 1546b85..7d7bf25 100755 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp | |||
| @@ -60,7 +60,7 @@ using namespace parserlib; | |||
| 60 | 60 | ||
| 61 | typedef std::list<std::string> str_list; | 61 | typedef std::list<std::string> str_list; |
| 62 | 62 | ||
| 63 | const std::string_view version = "0.10.16"sv; | 63 | const std::string_view version = "0.10.17"sv; |
| 64 | const std::string_view extension = "yue"sv; | 64 | const std::string_view extension = "yue"sv; |
| 65 | 65 | ||
| 66 | class YueCompilerImpl { | 66 | class YueCompilerImpl { |
diff --git a/src/yuescript/yuescript.cpp b/src/yuescript/yuescript.cpp index 5e21fc5..2e96f16 100644 --- a/src/yuescript/yuescript.cpp +++ b/src/yuescript/yuescript.cpp | |||
| @@ -5,7 +5,9 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of | |||
| 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
| 6 | 6 | ||
| 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 8 | |||
| 8 | #include "yuescript/yue_compiler.h" | 9 | #include "yuescript/yue_compiler.h" |
| 10 | #include "yuescript/yue_parser.h" | ||
| 9 | 11 | ||
| 10 | #if defined(YUE_BUILD_AS_DLL) | 12 | #if defined(YUE_BUILD_AS_DLL) |
| 11 | #define YUE_API __declspec(dllexport) | 13 | #define YUE_API __declspec(dllexport) |
| @@ -130,8 +132,87 @@ static int yuetolua(lua_State* L) { | |||
| 130 | return 3; | 132 | return 3; |
| 131 | } | 133 | } |
| 132 | 134 | ||
| 135 | static int yuetoast(lua_State* L) { | ||
| 136 | size_t size = 0; | ||
| 137 | const char* input = luaL_checklstring(L, 1, &size); | ||
| 138 | int flattenLevel = 2; | ||
| 139 | if (lua_isnoneornil(L, 2) == 0) { | ||
| 140 | flattenLevel = static_cast<int>(luaL_checkinteger(L, 2)); | ||
| 141 | flattenLevel = std::max(std::min(2, flattenLevel), 0); | ||
| 142 | } | ||
| 143 | yue::YueParser parser; | ||
| 144 | auto info = parser.parse<yue::File_t>({input, size}); | ||
| 145 | if (info.node) { | ||
| 146 | lua_createtable(L, 0, 0); | ||
| 147 | int cacheIndex = lua_gettop(L); | ||
| 148 | auto getName = [&](yue::ast_node* node) { | ||
| 149 | int id = node->getId(); | ||
| 150 | lua_rawgeti(L, cacheIndex, id); | ||
| 151 | if (lua_isnil(L, -1) != 0) { | ||
| 152 | lua_pop(L, 1); | ||
| 153 | auto name = node->getName(); | ||
| 154 | lua_pushlstring(L, &name.front(), name.length()); | ||
| 155 | lua_pushvalue(L, -1); | ||
| 156 | lua_rawseti(L, cacheIndex, id); | ||
| 157 | } | ||
| 158 | }; | ||
| 159 | std::function<void(yue::ast_node*)> visit; | ||
| 160 | visit = [&](yue::ast_node* node) { | ||
| 161 | int count = 0; | ||
| 162 | bool hasSep = false; | ||
| 163 | node->visitChild([&](yue::ast_node* child) { | ||
| 164 | if (yue::ast_is<yue::Seperator_t>(child)) { | ||
| 165 | hasSep = true; | ||
| 166 | return false; | ||
| 167 | } | ||
| 168 | count++; | ||
| 169 | visit(child); | ||
| 170 | return false; | ||
| 171 | }); | ||
| 172 | switch (count) { | ||
| 173 | case 0: { | ||
| 174 | lua_createtable(L, 2, 0); | ||
| 175 | getName(node); | ||
| 176 | lua_rawseti(L, -2, 1); | ||
| 177 | auto str = parser.toString(node); | ||
| 178 | yue::Utils::trim(str); | ||
| 179 | lua_pushlstring(L, str.c_str(), str.length()); | ||
| 180 | lua_rawseti(L, -2, 2); | ||
| 181 | break; | ||
| 182 | } | ||
| 183 | case 1: { | ||
| 184 | if (flattenLevel > 1 || (flattenLevel == 1 && !hasSep)) { | ||
| 185 | getName(node); | ||
| 186 | lua_rawseti(L, -2, 1); | ||
| 187 | break; | ||
| 188 | } | ||
| 189 | } | ||
| 190 | default: { | ||
| 191 | lua_createtable(L, count + 1, 0); | ||
| 192 | getName(node); | ||
| 193 | lua_rawseti(L, -2, 1); | ||
| 194 | for (int i = count, j = 2; i >= 1; i--, j++) { | ||
| 195 | lua_pushvalue(L, -1 - i); | ||
| 196 | lua_rawseti(L, -2, j); | ||
| 197 | } | ||
| 198 | lua_insert(L, -1 - count); | ||
| 199 | lua_pop(L, count); | ||
| 200 | break; | ||
| 201 | } | ||
| 202 | } | ||
| 203 | }; | ||
| 204 | visit(info.node); | ||
| 205 | return 1; | ||
| 206 | } else { | ||
| 207 | lua_pushnil(L); | ||
| 208 | lua_pushlstring(L, info.error.c_str(), info.error.length()); | ||
| 209 | return 2; | ||
| 210 | } | ||
| 211 | } | ||
| 212 | |||
| 133 | static const luaL_Reg yuelib[] = { | 213 | static const luaL_Reg yuelib[] = { |
| 134 | {"to_lua", yuetolua}, | 214 | {"to_lua", yuetolua}, |
| 215 | {"to_ast", yuetoast}, | ||
| 135 | {"version", nullptr}, | 216 | {"version", nullptr}, |
| 136 | {"options", nullptr}, | 217 | {"options", nullptr}, |
| 137 | {"load_stacktraceplus", nullptr}, | 218 | {"load_stacktraceplus", nullptr}, |
