From 09fc831f540ce3966aeff679164f37e7d40457c9 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Fri, 11 Feb 2022 10:37:35 +0800 Subject: add Lua table appending idiom: tb #= 123 --- spec/inputs/syntax.yue | 13 ++++++++++++- spec/outputs/syntax.lua | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/inputs/syntax.yue b/spec/inputs/syntax.yue index cb947e1..67d3a27 100644 --- a/spec/inputs/syntax.yue +++ b/spec/inputs/syntax.yue @@ -184,10 +184,21 @@ a["hello#{tostring ff}"] += 10 a[four].x += 10 a.b += 1 -a.b[1].c[2+3] += 1 +a.b[1].c[2 + 3] += 1 with tb .a.c += 1 +tb #= 10 +a.b.c #= 1 +x #= if v + 1 +else + 2 +with tb + .b.c #= with vec + .x = 1 + .y = 2 + x = 0 _ = (if ntype(v) == "fndef" then x += 1) for v in *values diff --git a/spec/outputs/syntax.lua b/spec/outputs/syntax.lua index ed8ed39..4596a29 100644 --- a/spec/outputs/syntax.lua +++ b/spec/outputs/syntax.lua @@ -195,6 +195,24 @@ do local _obj_2 = _with_0.a _obj_2.c = _obj_2.c + 1 end +tb[#tb + 1] = 10 +local _obj_2 = a.b.c +_obj_2[#_obj_2 + 1] = 1 +if v then + x[#x + 1] = 1 +else + x[#x + 1] = 2 +end +do + local _with_0 = tb + local _obj_3 = _with_0.b.c + do + local _with_1 = vec + _with_1.x = 1 + _with_1.y = 2 + _obj_3[#_obj_3 + 1] = _with_1 + end +end x = 0 local _list_0 = values for _index_0 = 1, #_list_0 do -- cgit v1.2.3-55-g6feb