diff options
Diffstat (limited to 'src/MoonP/moon_ast.h')
-rw-r--r-- | src/MoonP/moon_ast.h | 587 |
1 files changed, 587 insertions, 0 deletions
diff --git a/src/MoonP/moon_ast.h b/src/MoonP/moon_ast.h new file mode 100644 index 0000000..a614465 --- /dev/null +++ b/src/MoonP/moon_ast.h | |||
@@ -0,0 +1,587 @@ | |||
1 | /* Copyright (c) 2020 Jin Li, http://www.luvfight.me | ||
2 | |||
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
4 | |||
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
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. */ | ||
8 | |||
9 | #pragma once | ||
10 | |||
11 | #include "MoonP/moon_parser.h" | ||
12 | |||
13 | namespace MoonP { | ||
14 | |||
15 | #define AST_LEAF(type, id) \ | ||
16 | extern rule type; \ | ||
17 | class type##_t : public ast_node \ | ||
18 | { \ | ||
19 | public: \ | ||
20 | virtual int get_type() override { return ast_type<type##_t>(); } \ | ||
21 | virtual size_t getId() const override { return id; } \ | ||
22 | |||
23 | #define AST_NODE(type, id) \ | ||
24 | extern rule type; \ | ||
25 | class type##_t : public ast_container \ | ||
26 | { \ | ||
27 | public: \ | ||
28 | virtual int get_type() override { return ast_type<type##_t>(); } \ | ||
29 | virtual size_t getId() const override { return id; } \ | ||
30 | |||
31 | #define AST_MEMBER(type, ...) \ | ||
32 | type##_t() { \ | ||
33 | add_members({__VA_ARGS__}); \ | ||
34 | } | ||
35 | |||
36 | #define AST_END(type) \ | ||
37 | }; | ||
38 | |||
39 | AST_LEAF(Num, "Num"_id) | ||
40 | AST_END(Num) | ||
41 | |||
42 | AST_LEAF(Name, "Name"_id) | ||
43 | AST_END(Name) | ||
44 | |||
45 | AST_NODE(Variable, "Variable"_id) | ||
46 | ast_ptr<true, Name_t> name; | ||
47 | AST_MEMBER(Variable, &name) | ||
48 | AST_END(Variable) | ||
49 | |||
50 | AST_NODE(LuaKeyword, "LuaKeyword"_id) | ||
51 | ast_ptr<true, Name_t> name; | ||
52 | AST_MEMBER(LuaKeyword, &name) | ||
53 | AST_END(LuaKeyword) | ||
54 | |||
55 | AST_LEAF(self, "self"_id) | ||
56 | AST_END(self) | ||
57 | |||
58 | AST_NODE(self_name, "self_name"_id) | ||
59 | ast_ptr<true, Name_t> name; | ||
60 | AST_MEMBER(self_name, &name) | ||
61 | AST_END(self_name) | ||
62 | |||
63 | AST_LEAF(self_class, "self_class"_id) | ||
64 | AST_END(self_class) | ||
65 | |||
66 | AST_NODE(self_class_name, "self_class_name"_id) | ||
67 | ast_ptr<true, Name_t> name; | ||
68 | AST_MEMBER(self_class_name, &name) | ||
69 | AST_END(self_class_name) | ||
70 | |||
71 | AST_NODE(SelfName, "SelfName"_id) | ||
72 | ast_sel<true, self_class_name_t, self_class_t, self_name_t, self_t> name; | ||
73 | AST_MEMBER(SelfName, &name) | ||
74 | AST_END(SelfName) | ||
75 | |||
76 | AST_NODE(KeyName, "KeyName"_id) | ||
77 | ast_sel<true, SelfName_t, Name_t> name; | ||
78 | AST_MEMBER(KeyName, &name) | ||
79 | AST_END(KeyName) | ||
80 | |||
81 | AST_LEAF(VarArg, "VarArg"_id) | ||
82 | AST_END(VarArg) | ||
83 | |||
84 | AST_LEAF(local_flag, "local_flag"_id) | ||
85 | AST_END(local_flag) | ||
86 | |||
87 | AST_LEAF(Seperator, "Seperator"_id) | ||
88 | AST_END(Seperator) | ||
89 | |||
90 | AST_NODE(NameList, "NameList"_id) | ||
91 | ast_ptr<true, Seperator_t> sep; | ||
92 | ast_list<true, Variable_t> names; | ||
93 | AST_MEMBER(NameList, &sep, &names) | ||
94 | AST_END(NameList) | ||
95 | |||
96 | AST_NODE(Local, "Local"_id) | ||
97 | ast_sel<true, local_flag_t, NameList_t> name; | ||
98 | std::list<std::string> forceDecls; | ||
99 | std::list<std::string> decls; | ||
100 | AST_MEMBER(Local, &name) | ||
101 | AST_END(Local) | ||
102 | |||
103 | AST_NODE(colon_import_name, "colon_import_name"_id) | ||
104 | ast_ptr<true, Variable_t> name; | ||
105 | AST_MEMBER(colon_import_name, &name) | ||
106 | AST_END(colon_import_name) | ||
107 | |||
108 | class Exp_t; | ||
109 | |||
110 | AST_NODE(Import, "Import"_id) | ||
111 | ast_ptr<true, Seperator_t> sep; | ||
112 | ast_sel_list<true, colon_import_name_t, Variable_t> names; | ||
113 | ast_ptr<true, Exp_t> exp; | ||
114 | AST_MEMBER(Import, &sep, &names, &exp) | ||
115 | AST_END(Import) | ||
116 | |||
117 | AST_NODE(ExpListLow, "ExpListLow"_id) | ||
118 | ast_ptr<true, Seperator_t> sep; | ||
119 | ast_list<true, Exp_t> exprs; | ||
120 | AST_MEMBER(ExpListLow, &sep, &exprs) | ||
121 | AST_END(ExpListLow) | ||
122 | |||
123 | AST_NODE(ExpList, "ExpList"_id) | ||
124 | ast_ptr<true, Seperator_t> sep; | ||
125 | ast_list<true, Exp_t> exprs; | ||
126 | AST_MEMBER(ExpList, &sep, &exprs) | ||
127 | AST_END(ExpList) | ||
128 | |||
129 | AST_NODE(Return, "Return"_id) | ||
130 | ast_ptr<false, ExpListLow_t> valueList; | ||
131 | AST_MEMBER(Return, &valueList) | ||
132 | AST_END(Return) | ||
133 | |||
134 | class Assign_t; | ||
135 | class Body_t; | ||
136 | |||
137 | AST_NODE(With, "With"_id) | ||
138 | ast_ptr<true, ExpList_t> valueList; | ||
139 | ast_ptr<false, Assign_t> assigns; | ||
140 | ast_ptr<true, Body_t> body; | ||
141 | AST_MEMBER(With, &valueList, &assigns, &body) | ||
142 | AST_END(With) | ||
143 | |||
144 | AST_NODE(SwitchCase, "SwitchCase"_id) | ||
145 | ast_ptr<true, ExpList_t> valueList; | ||
146 | ast_ptr<true, Body_t> body; | ||
147 | AST_MEMBER(SwitchCase, &valueList, &body) | ||
148 | AST_END(SwitchCase) | ||
149 | |||
150 | AST_NODE(Switch, "Switch"_id) | ||
151 | ast_ptr<true, Exp_t> target; | ||
152 | ast_ptr<true, Seperator_t> sep; | ||
153 | ast_list<true, SwitchCase_t> branches; | ||
154 | ast_ptr<false, Body_t> lastBranch; | ||
155 | AST_MEMBER(Switch, &target, &sep, &branches, &lastBranch) | ||
156 | AST_END(Switch) | ||
157 | |||
158 | AST_NODE(IfCond, "IfCond"_id) | ||
159 | ast_ptr<true, Exp_t> condition; | ||
160 | ast_ptr<false, Assign_t> assign; | ||
161 | AST_MEMBER(IfCond, &condition, &assign) | ||
162 | AST_END(IfCond) | ||
163 | |||
164 | AST_NODE(If, "If"_id) | ||
165 | ast_ptr<true, Seperator_t> sep; | ||
166 | ast_sel_list<true, IfCond_t, Body_t> nodes; | ||
167 | AST_MEMBER(If, &sep, &nodes) | ||
168 | AST_END(If) | ||
169 | |||
170 | AST_NODE(Unless, "Unless"_id) | ||
171 | ast_ptr<true, Seperator_t> sep; | ||
172 | ast_sel_list<true, IfCond_t, Body_t> nodes; | ||
173 | AST_MEMBER(Unless, &sep, &nodes) | ||
174 | AST_END(Unless) | ||
175 | |||
176 | AST_NODE(While, "While"_id) | ||
177 | ast_ptr<true, Exp_t> condition; | ||
178 | ast_ptr<true, Body_t> body; | ||
179 | AST_MEMBER(While, &condition, &body) | ||
180 | AST_END(While) | ||
181 | |||
182 | AST_NODE(for_step_value, "for_step_value"_id) | ||
183 | ast_ptr<true, Exp_t> value; | ||
184 | AST_MEMBER(for_step_value, &value) | ||
185 | AST_END(for_step_value) | ||
186 | |||
187 | AST_NODE(For, "For"_id) | ||
188 | ast_ptr<true, Variable_t> varName; | ||
189 | ast_ptr<true, Exp_t> startValue; | ||
190 | ast_ptr<true, Exp_t> stopValue; | ||
191 | ast_ptr<false, for_step_value_t> stepValue; | ||
192 | ast_ptr<true, Body_t> body; | ||
193 | AST_MEMBER(For, &varName, &startValue, &stopValue, &stepValue, &body) | ||
194 | AST_END(For) | ||
195 | |||
196 | class AssignableNameList_t; | ||
197 | class star_exp_t; | ||
198 | |||
199 | AST_NODE(ForEach, "ForEach"_id) | ||
200 | ast_ptr<true, AssignableNameList_t> nameList; | ||
201 | ast_sel<true, star_exp_t, ExpList_t> loopValue; | ||
202 | ast_ptr<true, Body_t> body; | ||
203 | AST_MEMBER(ForEach, &nameList, &loopValue, &body) | ||
204 | AST_END(ForEach) | ||
205 | |||
206 | AST_NODE(Do, "Do"_id) | ||
207 | ast_ptr<true, Body_t> body; | ||
208 | AST_MEMBER(Do, &body) | ||
209 | AST_END(Do) | ||
210 | |||
211 | class CompInner_t; | ||
212 | class Statement_t; | ||
213 | |||
214 | AST_NODE(Comprehension, "Comprehension"_id) | ||
215 | ast_sel<true, Exp_t, Statement_t> value; | ||
216 | ast_ptr<true, CompInner_t> forLoop; | ||
217 | AST_MEMBER(Comprehension, &value, &forLoop) | ||
218 | AST_END(Comprehension) | ||
219 | |||
220 | AST_NODE(comp_value, "comp_value"_id) | ||
221 | ast_ptr<true, Exp_t> value; | ||
222 | AST_MEMBER(comp_value, &value) | ||
223 | AST_END(comp_value) | ||
224 | |||
225 | AST_NODE(TblComprehension, "TblComprehension"_id) | ||
226 | ast_ptr<true, Exp_t> key; | ||
227 | ast_ptr<false, comp_value_t> value; | ||
228 | ast_ptr<true, CompInner_t> forLoop; | ||
229 | AST_MEMBER(TblComprehension, &key, &value, &forLoop) | ||
230 | AST_END(TblComprehension) | ||
231 | |||
232 | AST_NODE(star_exp, "star_exp"_id) | ||
233 | ast_ptr<true, Exp_t> value; | ||
234 | AST_MEMBER(star_exp, &value) | ||
235 | AST_END(star_exp) | ||
236 | |||
237 | AST_NODE(CompForEach, "CompForEach"_id) | ||
238 | ast_ptr<true, AssignableNameList_t> nameList; | ||
239 | ast_sel<true, star_exp_t, Exp_t> loopValue; | ||
240 | AST_MEMBER(CompForEach, &nameList, &loopValue) | ||
241 | AST_END(CompForEach) | ||
242 | |||
243 | AST_NODE(CompFor, "CompFor"_id) | ||
244 | ast_ptr<true, Variable_t> varName; | ||
245 | ast_ptr<true, Exp_t> startValue; | ||
246 | ast_ptr<true, Exp_t> stopValue; | ||
247 | ast_ptr<false, for_step_value_t> stepValue; | ||
248 | AST_MEMBER(CompFor, &varName, &startValue, &stopValue, &stepValue) | ||
249 | AST_END(CompFor) | ||
250 | |||
251 | AST_NODE(CompInner, "CompInner"_id) | ||
252 | ast_ptr<true, Seperator_t> sep; | ||
253 | ast_sel_list<true, CompFor_t, CompForEach_t, Exp_t> items; | ||
254 | AST_MEMBER(CompInner, &sep, &items) | ||
255 | AST_END(CompInner) | ||
256 | |||
257 | class TableBlock_t; | ||
258 | |||
259 | AST_NODE(Assign, "Assign"_id) | ||
260 | ast_ptr<true, Seperator_t> sep; | ||
261 | ast_sel_list<true, With_t, If_t, Switch_t, TableBlock_t, Exp_t> values; | ||
262 | AST_MEMBER(Assign, &sep, &values) | ||
263 | AST_END(Assign) | ||
264 | |||
265 | AST_LEAF(update_op, "update_op"_id) | ||
266 | AST_END(update_op) | ||
267 | |||
268 | AST_NODE(Update, "Update"_id) | ||
269 | ast_ptr<true, update_op_t> op; | ||
270 | ast_ptr<true, Exp_t> value; | ||
271 | AST_MEMBER(Update, &op, &value) | ||
272 | AST_END(Update) | ||
273 | |||
274 | AST_LEAF(BinaryOperator, "BinaryOperator"_id) | ||
275 | AST_END(BinaryOperator) | ||
276 | |||
277 | class AssignableChain_t; | ||
278 | |||
279 | AST_NODE(Assignable, "Assignable"_id) | ||
280 | ast_sel<true, AssignableChain_t, Variable_t, SelfName_t> item; | ||
281 | AST_MEMBER(Assignable, &item) | ||
282 | AST_END(Assignable) | ||
283 | |||
284 | class Value_t; | ||
285 | |||
286 | AST_NODE(exp_op_value, "exp_op_value"_id) | ||
287 | ast_ptr<true, BinaryOperator_t> op; | ||
288 | ast_ptr<true, Value_t> value; | ||
289 | AST_MEMBER(exp_op_value, &op, &value) | ||
290 | AST_END(exp_op_value) | ||
291 | |||
292 | AST_NODE(Exp, "Exp"_id) | ||
293 | ast_ptr<true, Value_t> value; | ||
294 | ast_list<false, exp_op_value_t> opValues; | ||
295 | AST_MEMBER(Exp, &value, &opValues) | ||
296 | AST_END(Exp) | ||
297 | |||
298 | class Parens_t; | ||
299 | |||
300 | AST_NODE(Callable, "Callable"_id) | ||
301 | ast_sel<true, Variable_t, SelfName_t, VarArg_t, Parens_t> item; | ||
302 | AST_MEMBER(Callable, &item) | ||
303 | AST_END(Callable) | ||
304 | |||
305 | AST_NODE(variable_pair, "variable_pair"_id) | ||
306 | ast_ptr<true, Variable_t> name; | ||
307 | AST_MEMBER(variable_pair, &name) | ||
308 | AST_END(variable_pair) | ||
309 | |||
310 | class DoubleString_t; | ||
311 | class SingleString_t; | ||
312 | |||
313 | AST_NODE(normal_pair, "normal_pair"_id) | ||
314 | ast_sel<true, KeyName_t, Exp_t, DoubleString_t, SingleString_t> key; | ||
315 | ast_sel<true, Exp_t, TableBlock_t> value; | ||
316 | AST_MEMBER(normal_pair, &key, &value) | ||
317 | AST_END(normal_pair) | ||
318 | |||
319 | AST_NODE(simple_table, "simple_table"_id) | ||
320 | ast_ptr<true, Seperator_t> sep; | ||
321 | ast_sel_list<true, variable_pair_t, normal_pair_t> pairs; | ||
322 | AST_MEMBER(simple_table, &sep, &pairs) | ||
323 | AST_END(simple_table) | ||
324 | |||
325 | class String_t; | ||
326 | class const_value_t; | ||
327 | class ClassDecl_t; | ||
328 | class unary_exp_t; | ||
329 | class TableLit_t; | ||
330 | class FunLit_t; | ||
331 | |||
332 | AST_NODE(SimpleValue, "SimpleValue"_id) | ||
333 | ast_sel<true, const_value_t, | ||
334 | If_t, Unless_t, Switch_t, With_t, ClassDecl_t, | ||
335 | ForEach_t, For_t, While_t, Do_t, unary_exp_t, | ||
336 | TblComprehension_t, TableLit_t, Comprehension_t, | ||
337 | FunLit_t, Num_t> value; | ||
338 | AST_MEMBER(SimpleValue, &value) | ||
339 | AST_END(SimpleValue) | ||
340 | |||
341 | AST_LEAF(LuaStringOpen, "LuaStringOpen"_id) | ||
342 | AST_END(LuaStringOpen) | ||
343 | |||
344 | AST_LEAF(LuaStringContent, "LuaStringContent"_id) | ||
345 | AST_END(LuaStringContent) | ||
346 | |||
347 | AST_LEAF(LuaStringClose, "LuaStringClose"_id) | ||
348 | AST_END(LuaStringClose) | ||
349 | |||
350 | AST_NODE(LuaString, "LuaString"_id) | ||
351 | ast_ptr<true, LuaStringOpen_t> open; | ||
352 | ast_ptr<true, LuaStringContent_t> content; | ||
353 | ast_ptr<true, LuaStringClose_t> close; | ||
354 | AST_MEMBER(LuaString, &open, &content, &close) | ||
355 | AST_END(LuaString) | ||
356 | |||
357 | AST_LEAF(SingleString, "SingleString"_id) | ||
358 | AST_END(SingleString) | ||
359 | |||
360 | AST_LEAF(double_string_inner, "double_string_inner"_id) | ||
361 | AST_END(double_string_inner) | ||
362 | |||
363 | AST_NODE(double_string_content, "double_string_content"_id) | ||
364 | ast_sel<true, double_string_inner_t, Exp_t> content; | ||
365 | AST_MEMBER(double_string_content, &content) | ||
366 | AST_END(double_string_content) | ||
367 | |||
368 | AST_NODE(DoubleString, "DoubleString"_id) | ||
369 | ast_ptr<true, Seperator_t> sep; | ||
370 | ast_list<false, double_string_content_t> segments; | ||
371 | AST_MEMBER(DoubleString, &sep, &segments) | ||
372 | AST_END(DoubleString) | ||
373 | |||
374 | AST_NODE(String, "String"_id) | ||
375 | ast_sel<true, DoubleString_t, SingleString_t, LuaString_t> str; | ||
376 | AST_MEMBER(String, &str) | ||
377 | AST_END(String) | ||
378 | |||
379 | AST_NODE(DotChainItem, "DotChainItem"_id) | ||
380 | ast_ptr<true, Name_t> name; | ||
381 | AST_MEMBER(DotChainItem, &name) | ||
382 | AST_END(DotChainItem) | ||
383 | |||
384 | AST_NODE(ColonChainItem, "ColonChainItem"_id) | ||
385 | ast_sel<true, LuaKeyword_t, Name_t> name; | ||
386 | bool switchToDot = false; | ||
387 | AST_MEMBER(ColonChainItem, &name) | ||
388 | AST_END(ColonChainItem) | ||
389 | |||
390 | class default_value_t; | ||
391 | |||
392 | AST_NODE(Slice, "Slice"_id) | ||
393 | ast_sel<true, Exp_t, default_value_t> startValue; | ||
394 | ast_sel<true, Exp_t, default_value_t> stopValue; | ||
395 | ast_sel<true, Exp_t, default_value_t> stepValue; | ||
396 | AST_MEMBER(Slice, &startValue, &stopValue, &stepValue) | ||
397 | AST_END(Slice) | ||
398 | |||
399 | AST_NODE(Parens, "Parens"_id) | ||
400 | ast_ptr<true, Exp_t> expr; | ||
401 | AST_MEMBER(Parens, &expr) | ||
402 | AST_END(Parens) | ||
403 | |||
404 | AST_NODE(Invoke, "Invoke"_id) | ||
405 | ast_ptr<true, Seperator_t> sep; | ||
406 | ast_sel_list<false, Exp_t, SingleString_t, DoubleString_t, LuaString_t> args; | ||
407 | AST_MEMBER(Invoke, &sep, &args) | ||
408 | AST_END(Invoke) | ||
409 | |||
410 | class InvokeArgs_t; | ||
411 | |||
412 | AST_NODE(ChainValue, "ChainValue"_id) | ||
413 | ast_ptr<true, Seperator_t> sep; | ||
414 | ast_sel_list<true, Callable_t, Invoke_t, DotChainItem_t, ColonChainItem_t, Slice_t, Exp_t, String_t, InvokeArgs_t> items; | ||
415 | AST_MEMBER(ChainValue, &sep, &items) | ||
416 | AST_END(ChainValue) | ||
417 | |||
418 | AST_NODE(AssignableChain, "AssignableChain"_id) | ||
419 | ast_ptr<true, Seperator_t> sep; | ||
420 | ast_sel_list<true, Callable_t, Invoke_t, DotChainItem_t, ColonChainItem_t, Exp_t, String_t> items; | ||
421 | AST_MEMBER(AssignableChain, &sep, &items) | ||
422 | AST_END(AssignableChain) | ||
423 | |||
424 | AST_NODE(Value, "Value"_id) | ||
425 | ast_sel<true, SimpleValue_t, simple_table_t, ChainValue_t, String_t> item; | ||
426 | AST_MEMBER(Value, &item) | ||
427 | AST_END(Value) | ||
428 | |||
429 | AST_LEAF(default_value, "default_value"_id) | ||
430 | AST_END(default_value) | ||
431 | |||
432 | AST_NODE(TableLit, "TableLit"_id) | ||
433 | ast_ptr<true, Seperator_t> sep; | ||
434 | ast_sel_list<false, variable_pair_t, normal_pair_t, Exp_t> values; | ||
435 | AST_MEMBER(TableLit, &sep, &values) | ||
436 | AST_END(TableLit) | ||
437 | |||
438 | AST_NODE(TableBlock, "TableBlock"_id) | ||
439 | ast_ptr<true, Seperator_t> sep; | ||
440 | ast_sel_list<false, variable_pair_t, normal_pair_t> values; | ||
441 | AST_MEMBER(TableBlock, &sep, &values) | ||
442 | AST_END(TableBlock) | ||
443 | |||
444 | AST_NODE(class_member_list, "class_member_list"_id) | ||
445 | ast_ptr<true, Seperator_t> sep; | ||
446 | ast_sel_list<true, variable_pair_t, normal_pair_t> values; | ||
447 | AST_MEMBER(class_member_list, &sep, &values) | ||
448 | AST_END(class_member_list) | ||
449 | |||
450 | AST_NODE(ClassBlock, "ClassBlock"_id) | ||
451 | ast_ptr<true, Seperator_t> sep; | ||
452 | ast_sel_list<true, class_member_list_t, Statement_t> contents; | ||
453 | AST_MEMBER(ClassBlock, &sep, &contents) | ||
454 | AST_END(ClassBlock) | ||
455 | |||
456 | AST_NODE(ClassDecl, "ClassDecl"_id) | ||
457 | ast_ptr<false, Assignable_t> name; | ||
458 | ast_ptr<false, Exp_t> extend; | ||
459 | ast_ptr<false, ClassBlock_t> body; | ||
460 | AST_MEMBER(ClassDecl, &name, &extend, &body) | ||
461 | AST_END(ClassDecl) | ||
462 | |||
463 | AST_NODE(export_values, "export_values"_id) | ||
464 | ast_ptr<true, NameList_t> nameList; | ||
465 | ast_ptr<false, ExpListLow_t> valueList; | ||
466 | AST_MEMBER(export_values, &nameList, &valueList) | ||
467 | AST_END(export_values) | ||
468 | |||
469 | AST_LEAF(export_op, "export_op"_id) | ||
470 | AST_END(export_op) | ||
471 | |||
472 | AST_NODE(Export, "Export"_id) | ||
473 | ast_sel<true, ClassDecl_t, export_op_t, export_values_t> item; | ||
474 | AST_MEMBER(Export, &item) | ||
475 | AST_END(Export) | ||
476 | |||
477 | AST_NODE(FnArgDef, "FnArgDef"_id) | ||
478 | ast_sel<true, Variable_t, SelfName_t> name; | ||
479 | ast_ptr<false, Exp_t> defaultValue; | ||
480 | AST_MEMBER(FnArgDef, &name, &defaultValue) | ||
481 | AST_END(FnArgDef) | ||
482 | |||
483 | AST_NODE(FnArgDefList, "FnArgDefList"_id) | ||
484 | ast_ptr<true, Seperator_t> sep; | ||
485 | ast_list<false, FnArgDef_t> definitions; | ||
486 | ast_ptr<false, VarArg_t> varArg; | ||
487 | AST_MEMBER(FnArgDefList, &sep, &definitions, &varArg) | ||
488 | AST_END(FnArgDefList) | ||
489 | |||
490 | AST_NODE(outer_var_shadow, "outer_var_shadow"_id) | ||
491 | ast_ptr<false, NameList_t> varList; | ||
492 | AST_MEMBER(outer_var_shadow, &varList) | ||
493 | AST_END(outer_var_shadow) | ||
494 | |||
495 | AST_NODE(FnArgsDef, "FnArgsDef"_id) | ||
496 | ast_ptr<false, FnArgDefList_t> defList; | ||
497 | ast_ptr<false, outer_var_shadow_t> shadowOption; | ||
498 | AST_MEMBER(FnArgsDef, &defList, &shadowOption) | ||
499 | AST_END(FnArgsDef) | ||
500 | |||
501 | AST_LEAF(fn_arrow, "fn_arrow"_id) | ||
502 | AST_END(fn_arrow) | ||
503 | |||
504 | AST_NODE(FunLit, "FunLit"_id) | ||
505 | ast_ptr<false, FnArgsDef_t> argsDef; | ||
506 | ast_ptr<true, fn_arrow_t> arrow; | ||
507 | ast_ptr<false, Body_t> body; | ||
508 | AST_MEMBER(FunLit, &argsDef, &arrow, &body) | ||
509 | AST_END(FunLit) | ||
510 | |||
511 | AST_NODE(NameOrDestructure, "NameOrDestructure"_id) | ||
512 | ast_sel<true, Variable_t, TableLit_t> item; | ||
513 | AST_MEMBER(NameOrDestructure, &item) | ||
514 | AST_END(NameOrDestructure) | ||
515 | |||
516 | AST_NODE(AssignableNameList, "AssignableNameList"_id) | ||
517 | ast_ptr<true, Seperator_t> sep; | ||
518 | ast_list<true, NameOrDestructure_t> items; | ||
519 | AST_MEMBER(AssignableNameList, &sep, &items) | ||
520 | AST_END(AssignableNameList) | ||
521 | |||
522 | AST_NODE(InvokeArgs, "InvokeArgs"_id) | ||
523 | ast_ptr<true, Seperator_t> sep; | ||
524 | ast_sel_list<true, Exp_t, TableBlock_t> args; | ||
525 | AST_MEMBER(InvokeArgs, &sep, &args) | ||
526 | AST_END(InvokeArgs) | ||
527 | |||
528 | AST_LEAF(const_value, "const_value"_id) | ||
529 | AST_END(const_value) | ||
530 | |||
531 | AST_NODE(unary_exp, "unary_exp"_id) | ||
532 | ast_ptr<true, Exp_t> item; | ||
533 | AST_MEMBER(unary_exp, &item) | ||
534 | AST_END(unary_exp) | ||
535 | |||
536 | AST_NODE(ExpListAssign, "ExpListAssign"_id) | ||
537 | ast_ptr<true, ExpList_t> expList; | ||
538 | ast_sel<false, Update_t, Assign_t> action; | ||
539 | AST_MEMBER(ExpListAssign, &expList, &action) | ||
540 | AST_END(ExpListAssign) | ||
541 | |||
542 | AST_NODE(if_else_line, "if_else_line"_id) | ||
543 | ast_ptr<true, Exp_t> condition; | ||
544 | ast_sel<false, Exp_t, default_value_t> elseExpr; | ||
545 | AST_MEMBER(if_else_line, &condition, &elseExpr) | ||
546 | AST_END(if_else_line) | ||
547 | |||
548 | AST_NODE(unless_line, "unless_line"_id) | ||
549 | ast_ptr<true, Exp_t> condition; | ||
550 | AST_MEMBER(unless_line, &condition) | ||
551 | AST_END(unless_line) | ||
552 | |||
553 | AST_NODE(statement_appendix, "statement_appendix"_id) | ||
554 | ast_sel<true, if_else_line_t, unless_line_t, CompInner_t> item; | ||
555 | AST_MEMBER(statement_appendix, &item) | ||
556 | AST_END(statement_appendix) | ||
557 | |||
558 | AST_LEAF(BreakLoop, "BreakLoop"_id) | ||
559 | AST_END(BreakLoop) | ||
560 | |||
561 | AST_NODE(Statement, "Statement"_id) | ||
562 | ast_sel<true, Import_t, While_t, For_t, ForEach_t, | ||
563 | Return_t, Local_t, Export_t, BreakLoop_t, | ||
564 | ExpListAssign_t> content; | ||
565 | ast_ptr<false, statement_appendix_t> appendix; | ||
566 | AST_MEMBER(Statement, &content, &appendix) | ||
567 | AST_END(Statement) | ||
568 | |||
569 | class Block_t; | ||
570 | |||
571 | AST_NODE(Body, "Body"_id) | ||
572 | ast_sel<true, Block_t, Statement_t> content; | ||
573 | AST_MEMBER(Body, &content) | ||
574 | AST_END(Body) | ||
575 | |||
576 | AST_NODE(Block, "Block"_id) | ||
577 | ast_ptr<true, Seperator_t> sep; | ||
578 | ast_list<false, Statement_t> statements; | ||
579 | AST_MEMBER(Block, &sep, &statements) | ||
580 | AST_END(Block) | ||
581 | |||
582 | AST_NODE(File, "File"_id) | ||
583 | ast_ptr<true, Block_t> block; | ||
584 | AST_MEMBER(File, &block) | ||
585 | AST_END(File) | ||
586 | |||
587 | } // namespace MoonP | ||