From ccfe66f87663e10603e453f02894bb82dd23c93b Mon Sep 17 00:00:00 2001 From: Li Jin Date: Mon, 19 Jan 2026 17:11:31 +0800 Subject: Made `;` work as statements separator. --- spec/outputs/codes_from_doc.lua | 6 +++ spec/outputs/codes_from_doc_zh.lua | 6 +++ spec/outputs/syntax.lua | 74 ++++++++++++++++++++++++++++++++++++- spec/outputs/unicode/syntax.lua | 4 +- spec/outputs/unicode/whitespace.lua | 8 ++-- spec/outputs/whitespace.lua | 8 ++-- 6 files changed, 94 insertions(+), 12 deletions(-) (limited to 'spec/outputs') diff --git a/spec/outputs/codes_from_doc.lua b/spec/outputs/codes_from_doc.lua index 1df7cef..3b0724a 100644 --- a/spec/outputs/codes_from_doc.lua +++ b/spec/outputs/codes_from_doc.lua @@ -756,6 +756,9 @@ end local first = select(1, ...) return print(ok, count, first) end)(fn(true)) +local a = 1 +local b = 2 +print(a + b) Rx.Observable.fromRange(1, 8):filter(function(x) return x % 2 == 0 end):concat(Rx.Observable.of('who do we appreciate')):map(function(value) @@ -3283,6 +3286,9 @@ end local first = select(1, ...) return print(ok, count, first) end)(fn(true)) +local a = 1 +local b = 2 +print(a + b) Rx.Observable.fromRange(1, 8):filter(function(x) return x % 2 == 0 end):concat(Rx.Observable.of('who do we appreciate')):map(function(value) diff --git a/spec/outputs/codes_from_doc_zh.lua b/spec/outputs/codes_from_doc_zh.lua index b407895..89335c9 100644 --- a/spec/outputs/codes_from_doc_zh.lua +++ b/spec/outputs/codes_from_doc_zh.lua @@ -756,6 +756,9 @@ end local first = select(1, ...) return print(ok, count, first) end)(fn(true)) +local a = 1 +local b = 2 +print(a + b) Rx.Observable.fromRange(1, 8):filter(function(x) return x % 2 == 0 end):concat(Rx.Observable.of('who do we appreciate')):map(function(value) @@ -3277,6 +3280,9 @@ end local first = select(1, ...) return print(ok, count, first) end)(fn(true)) +local a = 1 +local b = 2 +print(a + b) Rx.Observable.fromRange(1, 8):filter(function(x) return x % 2 == 0 end):concat(Rx.Observable.of('who do we appreciate')):map(function(value) diff --git a/spec/outputs/syntax.lua b/spec/outputs/syntax.lua index 2df3473..d975ef7 100644 --- a/spec/outputs/syntax.lua +++ b/spec/outputs/syntax.lua @@ -5,9 +5,9 @@ func(arg1, arg2, another, arg3) local we here, we = function() end, yeah local the, different -the, different = function() +the, different = (function() return approach -end, yeah +end), yeah dad() dad(lord) hello(one, two)(); @@ -441,4 +441,74 @@ do end end)()) end +do + a = 1 + local b = 2 + local c = a + b + print(a) + print(b) + print(c) + f = function() + a = 1 + b = 2 + return a + b + end + a = 1 + b = 2 + local success, result = pcall(function() + return func() + end) + if success then + print(result) + end + local value = "foo" + print(value) + value = value .. "bar" + print(value) + do + if ok then + print("ok!") + end + return 42 + end + for i = 1, 3 do + print(i) + goto _continue_0 + ::_continue_0:: + end + local n = 0 + while n < 2 do + print("n=", n) + n = n + 1 + end + local obj = { } + obj:set(10) + obj:get() + print("done") + do + local _with_0 = tbl + _with_0:push(1) + print("push") + end + a = 5 + if a > 3 then + print("big") + b = a * 2 + print(b) + else + print("small") + b = a + end + xpcall(function() + x = 1 + y = 2 + return print(x + y) + end, function(err) + return print("error:", err) + end) + local q = 1 + local w = 2 + local e = 3 + print(q, w, e) +end return nil diff --git a/spec/outputs/unicode/syntax.lua b/spec/outputs/unicode/syntax.lua index a13302b..f5d5d8a 100644 --- a/spec/outputs/unicode/syntax.lua +++ b/spec/outputs/unicode/syntax.lua @@ -5,9 +5,9 @@ _u51fd_u6570(_u53c2_u65701, _u53c2_u65702, _u53e6_u5916, _u53c2_u65703) local _u6211_u4eec _u8fd9_u91cc, _u6211_u4eec = function() end, _u662f_u7684 local _u8fd9_u4e2a, _u4e0d_u540c -_u8fd9_u4e2a, _u4e0d_u540c = function() +_u8fd9_u4e2a, _u4e0d_u540c = (function() return _u65b9_u6cd5 -end, _u662f_u7684 +end), _u662f_u7684 _u7238_u7238() _u7238_u7238(_u4e3b) _u4f60_u597d(_u4e00, _u4e8c)(); diff --git a/spec/outputs/unicode/whitespace.lua b/spec/outputs/unicode/whitespace.lua index d026abb..7a83d9f 100644 --- a/spec/outputs/unicode/whitespace.lua +++ b/spec/outputs/unicode/whitespace.lua @@ -82,12 +82,12 @@ v = function() return _u53d8_u91cfa, _u53d8_u91cfb, _u53d8_u91cfc end local v1, v2, v3 -v1, v2, v3 = function() +v1, v2, v3 = (function() return _u53d8_u91cfa -end, _u53d8_u91cfb, _u53d8_u91cfc -local _u53d8_u91cfa, _u53d8_u91cfb, _u53d8_u91cfc, _u53d8_u91cfd, _u53d8_u91cfe, _u53d8_u91cff = 1, f2({ +end), _u53d8_u91cfb, _u53d8_u91cfc +local _u53d8_u91cfa, _u53d8_u91cfb, _u53d8_u91cfc, _u53d8_u91cfd, _u53d8_u91cfe, _u53d8_u91cff = 1, (f2({ abc = abc -}), 3, 4, _u51fd_u65705(abc), 6 +})), 3, 4, _u51fd_u65705(abc), 6 for _u53d8_u91cfa, _u53d8_u91cfb, _u53d8_u91cfc in pairs(_u5bf9_u8c61tb) do _u6253_u5370(_u53d8_u91cfa, _u53d8_u91cfb, _u53d8_u91cfc) end diff --git a/spec/outputs/whitespace.lua b/spec/outputs/whitespace.lua index 0251968..864f085 100644 --- a/spec/outputs/whitespace.lua +++ b/spec/outputs/whitespace.lua @@ -94,12 +94,12 @@ v = function() return a, b, c end local v1, v2, v3 -v1, v2, v3 = function() +v1, v2, v3 = (function() return a -end, b, c -local a, b, c, d, e, f = 1, f2({ +end), b, c +local a, b, c, d, e, f = 1, (f2({ abc = abc -}), 3, 4, f5(abc), 6 +})), 3, 4, f5(abc), 6 for a, b, c in pairs(tb) do print(a, b, c) end -- cgit v1.2.3-55-g6feb