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