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.h62
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)
93AST_END(NameList) 93AST_END(NameList)
94 94
95class ExpListLow_t;
96
97AST_NODE(local_values)
98 ast_ptr<true, NameList_t> nameList;
99 ast_ptr<false, ExpListLow_t> valueList;
100 AST_MEMBER(local_values, &nameList, &valueList)
101AST_END(local_values)
102
95AST_NODE(Local) 103AST_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)
100AST_END(Local) 108AST_END(Local)
101 109
102AST_NODE(colon_import_name) 110AST_NODE(colon_import_name)
@@ -116,12 +124,6 @@ AST_NODE(ImportLiteral)
116 AST_MEMBER(ImportLiteral, &sep, &inners) 124 AST_MEMBER(ImportLiteral, &sep, &inners)
117AST_END(ImportLiteral) 125AST_END(ImportLiteral)
118 126
119AST_NODE(ImportAs)
120 ast_ptr<true, ImportLiteral_t> literal;
121 ast_sel<false, Variable_t, TableLit_t> target;
122 AST_MEMBER(ImportAs, &literal, &target)
123AST_END(ImportAs)
124
125AST_NODE(ImportFrom) 127AST_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)
130AST_END(ImportFrom) 132AST_END(ImportFrom)
131 133
134AST_NODE(ImportAs)
135 ast_ptr<true, ImportLiteral_t> literal;
136 ast_sel<false, Variable_t, TableLit_t> target;
137 AST_MEMBER(ImportAs, &literal, &target)
138AST_END(ImportAs)
139
132AST_NODE(Import) 140AST_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)
333AST_END(Exp) 341AST_END(Exp)
334 342
335class Parens_t; 343class Parens_t;
344class MacroName_t;
336 345
337AST_NODE(Callable) 346AST_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)
340AST_END(Callable) 349AST_END(Callable)
341 350
@@ -469,9 +478,15 @@ AST_END(Value)
469AST_LEAF(default_value) 478AST_LEAF(default_value)
470AST_END(default_value) 479AST_END(default_value)
471 480
481AST_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)
485AST_END(macro_name_pair)
486
472AST_NODE(TableLit) 487AST_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)
476AST_END(TableLit) 491AST_END(TableLit)
477 492
@@ -517,9 +532,11 @@ AST_END(Global)
517AST_LEAF(export_default) 532AST_LEAF(export_default)
518AST_END(export_default) 533AST_END(export_default)
519 534
535class Macro_t;
536
520AST_NODE(Export) 537AST_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)
525AST_END(Export) 542AST_END(Export)
@@ -558,6 +575,27 @@ AST_NODE(FunLit)
558 AST_MEMBER(FunLit, &argsDef, &arrow, &body) 575 AST_MEMBER(FunLit, &argsDef, &arrow, &body)
559AST_END(FunLit) 576AST_END(FunLit)
560 577
578AST_LEAF(macro_type)
579AST_END(macro_type)
580
581AST_NODE(MacroName)
582 ast_ptr<true, Name_t> name;
583 AST_MEMBER(MacroName, &name)
584AST_END(MacroName)
585
586AST_NODE(MacroLit)
587 ast_ptr<false, FnArgDefList_t> argsDef;
588 ast_ptr<true, Body_t> body;
589 AST_MEMBER(MacroLit, &argsDef, &body)
590AST_END(MacroLit)
591
592AST_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, &macroLit)
597AST_END(Macro)
598
561AST_NODE(NameOrDestructure) 599AST_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
612AST_NODE(Statement) 650AST_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)