Skip to content

Commit 2e7d515

Browse files
committed
expression can be used inside slide boundaries, fixes #233
1 parent 0a2399e commit 2e7d515

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

moonscript/parse.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ local build_grammar = wrap_env(debug_grammar, function(root)
155155
SimpleValue = If + Unless + Switch + With + ClassDecl + ForEach + For + While + Cmt(Do, check_do) + sym("-") * -SomeSpace * Exp / mark("minus") + sym("#") * Exp / mark("length") + sym("~") * Exp / mark("bitnot") + key("not") * Exp / mark("not") + TblComprehension + TableLit + Comprehension + FunLit + Num,
156156
ChainValue = (Chain + Callable) * Ct(InvokeArgs ^ -1) / join_chain,
157157
Value = pos(SimpleValue + Ct(KeyValueList) / mark("table") + ChainValue + String),
158-
SliceValue = SimpleValue + ChainValue,
158+
SliceValue = Exp,
159159
String = Space * DoubleString + Space * SingleString + LuaString,
160160
SingleString = simple_string("'"),
161161
DoubleString = simple_string('"', true),

moonscript/parse.moon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ build_grammar = wrap_env debug_grammar, (root) ->
211211
ChainValue +
212212
String)
213213

214-
SliceValue: SimpleValue + ChainValue
214+
SliceValue: Exp
215215

216216
String: Space * DoubleString + Space * SingleString + LuaString
217217
SingleString: simple_string("'")

spec/inputs/comprehension.moon

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,11 @@ hi = {hello,world for {:hello, :world} in *things}
4242

4343
ok(a,b,c) for {a,b,c} in things
4444

45+
--
46+
47+
[item for item in *items[1 + 2,3+4]]
48+
[item for item in *items[hello! * 4, 2 - thing[4]]]
49+
50+
4551

4652
nil

spec/outputs/comprehension.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,4 +247,14 @@ for _des_0 in things do
247247
a, b, c = _des_0[1], _des_0[2], _des_0[3]
248248
ok(a, b, c)
249249
end
250+
local _max_0 = 3 + 4
251+
for _index_0 = 1 + 2, _max_0 < 0 and #items + _max_0 or _max_0 do
252+
local item = items[_index_0]
253+
_ = item
254+
end
255+
local _max_1 = 2 - thing[4]
256+
for _index_0 = hello() * 4, _max_1 < 0 and #items + _max_1 or _max_1 do
257+
local item = items[_index_0]
258+
_ = item
259+
end
250260
return nil

0 commit comments

Comments
 (0)