diff options
Diffstat (limited to 'src/MoonP/moon_ast.h')
-rw-r--r-- | src/MoonP/moon_ast.h | 62 |
1 files changed, 50 insertions, 12 deletions
diff --git a/src/MoonP/moon_ast.h b/src/MoonP/moon_ast.h index 9fab215..0725bda 100644 --- a/src/MoonP/moon_ast.h +++ b/src/MoonP/moon_ast.h | |||
@@ -92,11 +92,19 @@ AST_NODE(NameList) | |||
92 | AST_MEMBER(NameList, &sep, &names) | 92 | AST_MEMBER(NameList, &sep, &names) |
93 | AST_END(NameList) | 93 | AST_END(NameList) |
94 | 94 | ||
95 | class ExpListLow_t; | ||
96 | |||
97 | AST_NODE(local_values) | ||
98 | ast_ptr<true, NameList_t> nameList; | ||
99 | ast_ptr<false, ExpListLow_t> valueList; | ||
100 | AST_MEMBER(local_values, &nameList, &valueList) | ||
101 | AST_END(local_values) | ||
102 | |||
95 | AST_NODE(Local) | 103 | AST_NODE(Local) |
96 | ast_sel<true, local_flag_t, NameList_t> name; | 104 | ast_sel<true, local_flag_t, local_values_t> item; |
97 | std::list<std::string> forceDecls; | 105 | std::list<std::string> forceDecls; |
98 | std::list<std::string> decls; | 106 | std::list<std::string> decls; |
99 | AST_MEMBER(Local, &name) | 107 | AST_MEMBER(Local, &item) |
100 | AST_END(Local) | 108 | AST_END(Local) |
101 | 109 | ||
102 | AST_NODE(colon_import_name) | 110 | AST_NODE(colon_import_name) |
@@ -116,12 +124,6 @@ AST_NODE(ImportLiteral) | |||
116 | AST_MEMBER(ImportLiteral, &sep, &inners) | 124 | AST_MEMBER(ImportLiteral, &sep, &inners) |
117 | AST_END(ImportLiteral) | 125 | AST_END(ImportLiteral) |
118 | 126 | ||
119 | AST_NODE(ImportAs) | ||
120 | ast_ptr<true, ImportLiteral_t> literal; | ||
121 | ast_sel<false, Variable_t, TableLit_t> target; | ||
122 | AST_MEMBER(ImportAs, &literal, &target) | ||
123 | AST_END(ImportAs) | ||
124 | |||
125 | AST_NODE(ImportFrom) | 127 | AST_NODE(ImportFrom) |
126 | ast_ptr<true, Seperator_t> sep; | 128 | ast_ptr<true, Seperator_t> sep; |
127 | ast_sel_list<true, colon_import_name_t, Variable_t> names; | 129 | ast_sel_list<true, colon_import_name_t, Variable_t> names; |
@@ -129,6 +131,12 @@ AST_NODE(ImportFrom) | |||
129 | AST_MEMBER(ImportFrom, &sep, &names, &exp) | 131 | AST_MEMBER(ImportFrom, &sep, &names, &exp) |
130 | AST_END(ImportFrom) | 132 | AST_END(ImportFrom) |
131 | 133 | ||
134 | AST_NODE(ImportAs) | ||
135 | ast_ptr<true, ImportLiteral_t> literal; | ||
136 | ast_sel<false, Variable_t, TableLit_t> target; | ||
137 | AST_MEMBER(ImportAs, &literal, &target) | ||
138 | AST_END(ImportAs) | ||
139 | |||
132 | AST_NODE(Import) | 140 | AST_NODE(Import) |
133 | ast_sel<true, ImportAs_t, ImportFrom_t> content; | 141 | ast_sel<true, ImportAs_t, ImportFrom_t> content; |
134 | AST_MEMBER(Import, &content) | 142 | AST_MEMBER(Import, &content) |
@@ -333,9 +341,10 @@ AST_NODE(Exp) | |||
333 | AST_END(Exp) | 341 | AST_END(Exp) |
334 | 342 | ||
335 | class Parens_t; | 343 | class Parens_t; |
344 | class MacroName_t; | ||
336 | 345 | ||
337 | AST_NODE(Callable) | 346 | AST_NODE(Callable) |
338 | ast_sel<true, Variable_t, SelfName_t, VarArg_t, Parens_t> item; | 347 | ast_sel<true, Variable_t, SelfName_t, VarArg_t, Parens_t, MacroName_t> item; |
339 | AST_MEMBER(Callable, &item) | 348 | AST_MEMBER(Callable, &item) |
340 | AST_END(Callable) | 349 | AST_END(Callable) |
341 | 350 | ||
@@ -469,9 +478,15 @@ AST_END(Value) | |||
469 | AST_LEAF(default_value) | 478 | AST_LEAF(default_value) |
470 | AST_END(default_value) | 479 | AST_END(default_value) |
471 | 480 | ||
481 | AST_NODE(macro_name_pair) | ||
482 | ast_ptr<true, MacroName_t> key; | ||
483 | ast_ptr<true, MacroName_t> value; | ||
484 | AST_MEMBER(macro_name_pair, &key, &value) | ||
485 | AST_END(macro_name_pair) | ||
486 | |||
472 | AST_NODE(TableLit) | 487 | AST_NODE(TableLit) |
473 | ast_ptr<true, Seperator_t> sep; | 488 | ast_ptr<true, Seperator_t> sep; |
474 | ast_sel_list<false, variable_pair_t, normal_pair_t, Exp_t> values; | 489 | ast_sel_list<false, variable_pair_t, normal_pair_t, Exp_t, MacroName_t, macro_name_pair_t> values; |
475 | AST_MEMBER(TableLit, &sep, &values) | 490 | AST_MEMBER(TableLit, &sep, &values) |
476 | AST_END(TableLit) | 491 | AST_END(TableLit) |
477 | 492 | ||
@@ -517,9 +532,11 @@ AST_END(Global) | |||
517 | AST_LEAF(export_default) | 532 | AST_LEAF(export_default) |
518 | AST_END(export_default) | 533 | AST_END(export_default) |
519 | 534 | ||
535 | class Macro_t; | ||
536 | |||
520 | AST_NODE(Export) | 537 | AST_NODE(Export) |
521 | ast_ptr<false, export_default_t> def; | 538 | ast_ptr<false, export_default_t> def; |
522 | ast_sel<true, ExpList_t, Exp_t> target; | 539 | ast_sel<true, ExpList_t, Exp_t, Macro_t> target; |
523 | ast_ptr<false, Assign_t> assign; | 540 | ast_ptr<false, Assign_t> assign; |
524 | AST_MEMBER(Export, &def, &target, &assign) | 541 | AST_MEMBER(Export, &def, &target, &assign) |
525 | AST_END(Export) | 542 | AST_END(Export) |
@@ -558,6 +575,27 @@ AST_NODE(FunLit) | |||
558 | AST_MEMBER(FunLit, &argsDef, &arrow, &body) | 575 | AST_MEMBER(FunLit, &argsDef, &arrow, &body) |
559 | AST_END(FunLit) | 576 | AST_END(FunLit) |
560 | 577 | ||
578 | AST_LEAF(macro_type) | ||
579 | AST_END(macro_type) | ||
580 | |||
581 | AST_NODE(MacroName) | ||
582 | ast_ptr<true, Name_t> name; | ||
583 | AST_MEMBER(MacroName, &name) | ||
584 | AST_END(MacroName) | ||
585 | |||
586 | AST_NODE(MacroLit) | ||
587 | ast_ptr<false, FnArgDefList_t> argsDef; | ||
588 | ast_ptr<true, Body_t> body; | ||
589 | AST_MEMBER(MacroLit, &argsDef, &body) | ||
590 | AST_END(MacroLit) | ||
591 | |||
592 | AST_NODE(Macro) | ||
593 | ast_ptr<true, macro_type_t> type; | ||
594 | ast_ptr<true, Name_t> name; | ||
595 | ast_ptr<true, MacroLit_t> macroLit; | ||
596 | AST_MEMBER(Macro, &type, &name, ¯oLit) | ||
597 | AST_END(Macro) | ||
598 | |||
561 | AST_NODE(NameOrDestructure) | 599 | AST_NODE(NameOrDestructure) |
562 | ast_sel<true, Variable_t, TableLit_t> item; | 600 | ast_sel<true, Variable_t, TableLit_t> item; |
563 | AST_MEMBER(NameOrDestructure, &item) | 601 | AST_MEMBER(NameOrDestructure, &item) |
@@ -611,7 +649,7 @@ AST_END(BreakLoop) | |||
611 | 649 | ||
612 | AST_NODE(Statement) | 650 | AST_NODE(Statement) |
613 | ast_sel<true, Import_t, While_t, For_t, ForEach_t, | 651 | ast_sel<true, Import_t, While_t, For_t, ForEach_t, |
614 | Return_t, Local_t, Global_t, Export_t, BreakLoop_t, | 652 | Return_t, Local_t, Global_t, Export_t, Macro_t, BreakLoop_t, |
615 | Backcall_t, ExpListAssign_t> content; | 653 | Backcall_t, ExpListAssign_t> content; |
616 | ast_ptr<false, statement_appendix_t> appendix; | 654 | ast_ptr<false, statement_appendix_t> appendix; |
617 | AST_MEMBER(Statement, &content, &appendix) | 655 | AST_MEMBER(Statement, &content, &appendix) |