diff options
author | Li Jin <dragon-fly@qq.com> | 2022-04-01 17:47:27 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2022-04-01 17:47:27 +0800 |
commit | ca1ed557769352c0ac0ca7804dd25e18c1fdf2e1 (patch) | |
tree | bf86d3990b90054f8d82aaf87cb9efae444a08ce /spec | |
parent | 7be6c300256bfe411942a7ccc66f6bc3afa7390d (diff) | |
download | yuescript-ca1ed557769352c0ac0ca7804dd25e18c1fdf2e1.tar.gz yuescript-ca1ed557769352c0ac0ca7804dd25e18c1fdf2e1.tar.bz2 yuescript-ca1ed557769352c0ac0ca7804dd25e18c1fdf2e1.zip |
fix some ambiguous syntax caused by arg table block.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/inputs/ambiguous.yue | 30 | ||||
-rw-r--r-- | spec/inputs/syntax.yue | 9 | ||||
-rw-r--r-- | spec/outputs/ambiguous.lua | 69 |
3 files changed, 104 insertions, 4 deletions
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 | |||
28 | global * | 28 | global * |
29 | $v! | 29 | $v! |
30 | 30 | ||
31 | do | ||
32 | f | ||
33 | :v | ||
34 | |||
35 | tb = while f | ||
36 | :v | ||
37 | |||
38 | repeat | ||
39 | print v | ||
40 | until f | ||
41 | :v | ||
42 | |||
43 | with f | ||
44 | :v = tb | ||
45 | .x = 1 | ||
46 | |||
47 | x = if f | ||
48 | :v | ||
49 | |||
50 | x = switch f | ||
51 | :v | ||
52 | when f | ||
53 | :v | ||
54 | |||
55 | nums = for num = 1, len | ||
56 | :num | ||
57 | |||
58 | objects = for item in *items | ||
59 | name: item | ||
60 | |||
31 | nil | 61 | 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 | |||
267 | z = x andb | 267 | z = x andb |
268 | 268 | ||
269 | 269 | ||
270 | -- undelimited tables | 270 | while 10 > something( |
271 | something: "world" | ||
272 | ) | ||
273 | print "yeah" | ||
271 | 274 | ||
272 | while 10 > something | 275 | -- undelimited tables |
273 | something: "world" | ||
274 | print "yeah" | ||
275 | 276 | ||
276 | x = | 277 | x = |
277 | okay: sure | 278 | 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 | |||
27 | do | 27 | do |
28 | print(123) | 28 | print(123) |
29 | end | 29 | end |
30 | do | ||
31 | f({ | ||
32 | v = v | ||
33 | }) | ||
34 | local tb | ||
35 | do | ||
36 | local _accum_0 = { } | ||
37 | local _len_0 = 1 | ||
38 | while f do | ||
39 | _accum_0[_len_0] = { | ||
40 | v = v | ||
41 | } | ||
42 | _len_0 = _len_0 + 1 | ||
43 | end | ||
44 | tb = _accum_0 | ||
45 | end | ||
46 | repeat | ||
47 | print(v) | ||
48 | until f({ | ||
49 | v = v | ||
50 | }) | ||
51 | do | ||
52 | local _with_0 = f | ||
53 | local v = tb.v | ||
54 | _with_0.x = 1 | ||
55 | end | ||
56 | local x | ||
57 | if f then | ||
58 | x = { | ||
59 | v = v | ||
60 | } | ||
61 | end | ||
62 | do | ||
63 | local _exp_0 = f({ | ||
64 | v = v | ||
65 | }) | ||
66 | if f == _exp_0 then | ||
67 | x = { | ||
68 | v = v | ||
69 | } | ||
70 | end | ||
71 | end | ||
72 | local nums | ||
73 | do | ||
74 | local _accum_0 = { } | ||
75 | local _len_0 = 1 | ||
76 | for num = 1, len do | ||
77 | _accum_0[_len_0] = { | ||
78 | num = num | ||
79 | } | ||
80 | _len_0 = _len_0 + 1 | ||
81 | end | ||
82 | nums = _accum_0 | ||
83 | end | ||
84 | local objects | ||
85 | do | ||
86 | local _accum_0 = { } | ||
87 | local _len_0 = 1 | ||
88 | local _list_0 = items | ||
89 | for _index_0 = 1, #_list_0 do | ||
90 | local item = _list_0[_index_0] | ||
91 | _accum_0[_len_0] = { | ||
92 | name = item | ||
93 | } | ||
94 | _len_0 = _len_0 + 1 | ||
95 | end | ||
96 | objects = _accum_0 | ||
97 | end | ||
98 | end | ||
30 | return nil | 99 | return nil |