mirror of
https://github.com/leafo/moonscript.git
synced 2025-01-09 00:04:22 +00:00
expression can be used inside slide boundaries, fixes #233
This commit is contained in:
parent
0a2399ef39
commit
2e7d5153f1
@ -155,7 +155,7 @@ local build_grammar = wrap_env(debug_grammar, function(root)
|
||||
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,
|
||||
ChainValue = (Chain + Callable) * Ct(InvokeArgs ^ -1) / join_chain,
|
||||
Value = pos(SimpleValue + Ct(KeyValueList) / mark("table") + ChainValue + String),
|
||||
SliceValue = SimpleValue + ChainValue,
|
||||
SliceValue = Exp,
|
||||
String = Space * DoubleString + Space * SingleString + LuaString,
|
||||
SingleString = simple_string("'"),
|
||||
DoubleString = simple_string('"', true),
|
||||
|
@ -211,7 +211,7 @@ build_grammar = wrap_env debug_grammar, (root) ->
|
||||
ChainValue +
|
||||
String)
|
||||
|
||||
SliceValue: SimpleValue + ChainValue
|
||||
SliceValue: Exp
|
||||
|
||||
String: Space * DoubleString + Space * SingleString + LuaString
|
||||
SingleString: simple_string("'")
|
||||
|
@ -42,5 +42,11 @@ hi = {hello,world for {:hello, :world} in *things}
|
||||
|
||||
ok(a,b,c) for {a,b,c} in things
|
||||
|
||||
--
|
||||
|
||||
[item for item in *items[1 + 2,3+4]]
|
||||
[item for item in *items[hello! * 4, 2 - thing[4]]]
|
||||
|
||||
|
||||
|
||||
nil
|
||||
|
@ -247,4 +247,14 @@ for _des_0 in things do
|
||||
a, b, c = _des_0[1], _des_0[2], _des_0[3]
|
||||
ok(a, b, c)
|
||||
end
|
||||
local _max_0 = 3 + 4
|
||||
for _index_0 = 1 + 2, _max_0 < 0 and #items + _max_0 or _max_0 do
|
||||
local item = items[_index_0]
|
||||
_ = item
|
||||
end
|
||||
local _max_1 = 2 - thing[4]
|
||||
for _index_0 = hello() * 4, _max_1 < 0 and #items + _max_1 or _max_1 do
|
||||
local item = items[_index_0]
|
||||
_ = item
|
||||
end
|
||||
return nil
|
Loading…
Reference in New Issue
Block a user