From ca1ed557769352c0ac0ca7804dd25e18c1fdf2e1 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Fri, 1 Apr 2022 17:47:27 +0800 Subject: fix some ambiguous syntax caused by arg table block. --- spec/inputs/ambiguous.yue | 30 ++++++++++++++++++++ spec/inputs/syntax.yue | 9 +++--- spec/outputs/ambiguous.lua | 69 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 4 deletions(-) (limited to 'spec') diff --git a/spec/inputs/ambiguous.yue b/spec/inputs/ambiguous.yue index 0e09979..3ae0bfc 100644 --- a/spec/inputs/ambiguous.yue +++ b/spec/inputs/ambiguous.yue @@ -28,4 +28,34 @@ do global * $v! +do + f + :v + + tb = while f + :v + + repeat + print v + until f + :v + + with f + :v = tb + .x = 1 + + x = if f + :v + + x = switch f + :v + when f + :v + + nums = for num = 1, len + :num + + objects = for item in *items + name: item + nil diff --git a/spec/inputs/syntax.yue b/spec/inputs/syntax.yue index e7f0a8d..84c6578 100644 --- a/spec/inputs/syntax.yue +++ b/spec/inputs/syntax.yue @@ -267,11 +267,12 @@ z = x and b z = x andb --- undelimited tables +while 10 > something( + something: "world" + ) + print "yeah" -while 10 > something - something: "world" - print "yeah" +-- undelimited tables x = okay: sure diff --git a/spec/outputs/ambiguous.lua b/spec/outputs/ambiguous.lua index 6039d73..f96cee5 100644 --- a/spec/outputs/ambiguous.lua +++ b/spec/outputs/ambiguous.lua @@ -27,4 +27,73 @@ end do print(123) end +do + f({ + v = v + }) + local tb + do + local _accum_0 = { } + local _len_0 = 1 + while f do + _accum_0[_len_0] = { + v = v + } + _len_0 = _len_0 + 1 + end + tb = _accum_0 + end + repeat + print(v) + until f({ + v = v + }) + do + local _with_0 = f + local v = tb.v + _with_0.x = 1 + end + local x + if f then + x = { + v = v + } + end + do + local _exp_0 = f({ + v = v + }) + if f == _exp_0 then + x = { + v = v + } + end + end + local nums + do + local _accum_0 = { } + local _len_0 = 1 + for num = 1, len do + _accum_0[_len_0] = { + num = num + } + _len_0 = _len_0 + 1 + end + nums = _accum_0 + end + local objects + do + local _accum_0 = { } + local _len_0 = 1 + local _list_0 = items + for _index_0 = 1, #_list_0 do + local item = _list_0[_index_0] + _accum_0[_len_0] = { + name = item + } + _len_0 = _len_0 + 1 + end + objects = _accum_0 + end +end return nil -- cgit v1.2.3-55-g6feb