mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
updated syntax
This commit is contained in:
parent
361feef825
commit
f0b3690362
@ -170,11 +170,11 @@ line_compile = {
|
||||
local b = self:block()
|
||||
b:stms(block, ret)
|
||||
self:add_line(b:render())
|
||||
for i, cond in ipairs(node) do
|
||||
if i > 3 then
|
||||
local _item_0 = node
|
||||
for _index_0=4,#_item_0 do
|
||||
local cond = _item_0[_index_0]
|
||||
add_clause(cond)
|
||||
end
|
||||
end
|
||||
return self:add_line("end")
|
||||
end,
|
||||
["while"] = function(self, node)
|
||||
@ -234,11 +234,11 @@ line_compile = {
|
||||
local calling_name = block:get("current_block")
|
||||
local slice = (function()
|
||||
local _moon_0 = {}
|
||||
for i, item in ipairs(chain) do
|
||||
if i > 2 then
|
||||
local _item_0 = chain
|
||||
for _index_0=3,#_item_0 do
|
||||
local item = _item_0[_index_0]
|
||||
table.insert(_moon_0, item)
|
||||
end
|
||||
end
|
||||
return _moon_0
|
||||
end)()
|
||||
slice[1] = { "call", { "self", unpack(slice[1][2]) } }
|
||||
|
@ -130,7 +130,7 @@ line_compile =
|
||||
b\stms block, ret
|
||||
@add_line b\render!
|
||||
|
||||
add_clause cond for i, cond in ipairs node when i > 3
|
||||
add_clause cond for cond in *node[4:]
|
||||
|
||||
@add_line "end"
|
||||
|
||||
@ -183,7 +183,7 @@ line_compile =
|
||||
|
||||
def_scope\set "super" (block, chain) ->
|
||||
calling_name = block\get"current_block"
|
||||
slice = [item for i, item in ipairs chain when i > 2]
|
||||
slice = [item for item in *chain[3:]]
|
||||
-- inject self
|
||||
slice[1] = {"call", {"self", unpack slice[1][2]}}
|
||||
|
||||
|
@ -33,11 +33,11 @@ local value_compile = {
|
||||
end,
|
||||
explist = function(self, node) return concat((function()
|
||||
local _moon_0 = {}
|
||||
for i, v in ipairs(node) do
|
||||
if i > 1 then
|
||||
local _item_0 = node
|
||||
for _index_0=2,#_item_0 do
|
||||
local v = _item_0[_index_0]
|
||||
table.insert(_moon_0, self:value(v))
|
||||
end
|
||||
end
|
||||
return _moon_0
|
||||
end)(), ", ") end,
|
||||
parens = function(self, node) return "(" .. (self:value(node[2])) .. ")" end,
|
||||
@ -90,11 +90,11 @@ local value_compile = {
|
||||
end
|
||||
local actions = (function()
|
||||
local _moon_0 = {}
|
||||
for i, act in ipairs(node) do
|
||||
if i > 2 then
|
||||
local _item_0 = node
|
||||
for _index_0=3,#_item_0 do
|
||||
local act = _item_0[_index_0]
|
||||
table.insert(_moon_0, chain_item(act))
|
||||
end
|
||||
end
|
||||
return _moon_0
|
||||
end)()
|
||||
if ntype(callee) == "self" and node[3] and ntype(node[3]) == "call" then
|
||||
|
@ -29,7 +29,7 @@ value_compile =
|
||||
@name name
|
||||
|
||||
explist: (node) =>
|
||||
concat [@value v for i,v in ipairs node when i > 1], ", "
|
||||
concat [@value v for v in *node[2:]], ", "
|
||||
|
||||
parens: (node) =>
|
||||
"("..(@value node[2])..")"
|
||||
@ -82,7 +82,7 @@ value_compile =
|
||||
else
|
||||
error "Unknown chain action: "..t
|
||||
|
||||
actions = [chain_item act for i, act in ipairs node when i > 2]
|
||||
actions = [chain_item act for act in *node[3:]]
|
||||
|
||||
if ntype(callee) == "self" and node[3] and ntype(node[3]) == "call"
|
||||
callee[1] = "self_colon"
|
||||
|
Loading…
Reference in New Issue
Block a user