diff options
-rw-r--r-- | spec/inputs/attrib.yue | 3 | ||||
-rw-r--r-- | spec/outputs/5.1/attrib.lua | 10 | ||||
-rw-r--r-- | spec/outputs/attrib.lua | 10 | ||||
-rw-r--r-- | src/yuescript/yue_ast.h | 3 | ||||
-rw-r--r-- | src/yuescript/yue_compiler.cpp | 5 | ||||
-rw-r--r-- | src/yuescript/yue_parser.cpp | 2 |
6 files changed, 29 insertions, 4 deletions
diff --git a/spec/inputs/attrib.yue b/spec/inputs/attrib.yue index fbff75a..36aca99 100644 --- a/spec/inputs/attrib.yue +++ b/spec/inputs/attrib.yue | |||
@@ -14,6 +14,9 @@ do | |||
14 | const a, {b, c}, {d} = f! | 14 | const a, {b, c}, {d} = f! |
15 | 15 | ||
16 | do | 16 | do |
17 | const [a, b] = [2, 3] | ||
18 | |||
19 | do | ||
17 | close v = if flag | 20 | close v = if flag |
18 | func! | 21 | func! |
19 | else | 22 | else |
diff --git a/spec/outputs/5.1/attrib.lua b/spec/outputs/5.1/attrib.lua index f782b45..70e7e24 100644 --- a/spec/outputs/5.1/attrib.lua +++ b/spec/outputs/5.1/attrib.lua | |||
@@ -41,6 +41,16 @@ do | |||
41 | end | 41 | end |
42 | end | 42 | end |
43 | do | 43 | do |
44 | local a, b | ||
45 | do | ||
46 | local _obj_0 = { | ||
47 | 2, | ||
48 | 3 | ||
49 | } | ||
50 | a, b = _obj_0[1], _obj_0[2] | ||
51 | end | ||
52 | end | ||
53 | do | ||
44 | local v = (function() | 54 | local v = (function() |
45 | if flag then | 55 | if flag then |
46 | return func() | 56 | return func() |
diff --git a/spec/outputs/attrib.lua b/spec/outputs/attrib.lua index 919b7e0..181555f 100644 --- a/spec/outputs/attrib.lua +++ b/spec/outputs/attrib.lua | |||
@@ -30,6 +30,16 @@ do | |||
30 | end | 30 | end |
31 | end | 31 | end |
32 | do | 32 | do |
33 | local a, b | ||
34 | do | ||
35 | local _obj_0 = { | ||
36 | 2, | ||
37 | 3 | ||
38 | } | ||
39 | a, b = _obj_0[1], _obj_0[2] | ||
40 | end | ||
41 | end | ||
42 | do | ||
33 | local v <close> = (function() | 43 | local v <close> = (function() |
34 | if flag then | 44 | if flag then |
35 | return func() | 45 | return func() |
diff --git a/src/yuescript/yue_ast.h b/src/yuescript/yue_ast.h index 6b2b7f8..6d90add 100644 --- a/src/yuescript/yue_ast.h +++ b/src/yuescript/yue_ast.h | |||
@@ -80,6 +80,7 @@ class Macro_t; | |||
80 | class In_t; | 80 | class In_t; |
81 | class NormalDef_t; | 81 | class NormalDef_t; |
82 | class SpreadListExp_t; | 82 | class SpreadListExp_t; |
83 | class Comprehension_t; | ||
83 | } // namespace yue | 84 | } // namespace yue |
84 | 85 | ||
85 | AST_LEAF(Num) | 86 | AST_LEAF(Num) |
@@ -171,7 +172,7 @@ AST_END(CloseAttrib, "close"sv) | |||
171 | AST_NODE(LocalAttrib) | 172 | AST_NODE(LocalAttrib) |
172 | ast_sel<true, ConstAttrib_t, CloseAttrib_t> attrib; | 173 | ast_sel<true, ConstAttrib_t, CloseAttrib_t> attrib; |
173 | ast_ptr<true, Seperator_t> sep; | 174 | ast_ptr<true, Seperator_t> sep; |
174 | ast_sel_list<true, Variable_t, SimpleTable_t, TableLit_t> leftList; | 175 | ast_sel_list<true, Variable_t, SimpleTable_t, TableLit_t, Comprehension_t> leftList; |
175 | ast_ptr<true, Assign_t> assign; | 176 | ast_ptr<true, Assign_t> assign; |
176 | AST_MEMBER(LocalAttrib, &attrib, &sep, &leftList, &assign) | 177 | AST_MEMBER(LocalAttrib, &attrib, &sep, &leftList, &assign) |
177 | AST_END(LocalAttrib, "local_attrib"sv) | 178 | AST_END(LocalAttrib, "local_attrib"sv) |
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index d43f79b..f163bdf 100644 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp | |||
@@ -75,7 +75,7 @@ static std::unordered_set<std::string> Metamethods = { | |||
75 | "close"s // Lua 5.4 | 75 | "close"s // Lua 5.4 |
76 | }; | 76 | }; |
77 | 77 | ||
78 | const std::string_view version = "0.21.5"sv; | 78 | const std::string_view version = "0.21.6"sv; |
79 | const std::string_view extension = "yue"sv; | 79 | const std::string_view extension = "yue"sv; |
80 | 80 | ||
81 | class CompileError : public std::logic_error { | 81 | class CompileError : public std::logic_error { |
@@ -9376,7 +9376,8 @@ private: | |||
9376 | case id<SimpleTable_t>(): | 9376 | case id<SimpleTable_t>(): |
9377 | value->item.set(item); | 9377 | value->item.set(item); |
9378 | break; | 9378 | break; |
9379 | case id<TableLit_t>(): { | 9379 | case id<TableLit_t>(): |
9380 | case id<Comprehension_t>(): { | ||
9380 | auto simpleValue = item->new_ptr<SimpleValue_t>(); | 9381 | auto simpleValue = item->new_ptr<SimpleValue_t>(); |
9381 | simpleValue->value.set(item); | 9382 | simpleValue->value.set(item); |
9382 | value->item.set(simpleValue); | 9383 | value->item.set(simpleValue); |
diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp index 3557534..4e6105b 100644 --- a/src/yuescript/yue_parser.cpp +++ b/src/yuescript/yue_parser.cpp | |||
@@ -286,7 +286,7 @@ YueParser::YueParser() { | |||
286 | 286 | ||
287 | ConstAttrib = key("const"); | 287 | ConstAttrib = key("const"); |
288 | CloseAttrib = key("close"); | 288 | CloseAttrib = key("close"); |
289 | local_const_item = Variable | SimpleTable | TableLit; | 289 | local_const_item = Variable | SimpleTable | TableLit | Comprehension; |
290 | LocalAttrib = ( | 290 | LocalAttrib = ( |
291 | ConstAttrib >> Seperator >> space >> local_const_item >> *(space >> ',' >> space >> local_const_item) | | 291 | ConstAttrib >> Seperator >> space >> local_const_item >> *(space >> ',' >> space >> local_const_item) | |
292 | CloseAttrib >> Seperator >> space >> Variable >> *(space >> ',' >> space >> Variable) | 292 | CloseAttrib >> Seperator >> space >> Variable >> *(space >> ',' >> space >> Variable) |