diff --git a/moonscript/parse.lua b/moonscript/parse.lua index 38ea86b..ecdb784 100644 --- a/moonscript/parse.lua +++ b/moonscript/parse.lua @@ -501,7 +501,7 @@ local build_grammar = wrap_env(function() Ct(ClassLine * (SpaceBreak^1 * ClassLine)^0) * PopIndent, ClassLine = CheckIndent * (( KeyValueList / mark"props" + - (Assign + Update) / mark"stm" + + Statement / mark"stm" + Exp / mark"stm" ) * sym","^-1), diff --git a/tests/outputs/class.lua b/tests/outputs/class.lua index 4d06d6e..1f1aa4f 100644 --- a/tests/outputs/class.lua +++ b/tests/outputs/class.lua @@ -540,53 +540,53 @@ local self = self + self / self self = 343 self.hello(2, 3, 4) local _ = hello[self].world -if something then - local Whacko - Whacko = (function() - local hello - local _parent_0 = nil - local _base_0 = { } - _base_0.__index = _base_0 - if _parent_0 then - setmetatable(_base_0, _parent_0.__base) - end - local _class_0 = setmetatable({ - __init = function(self, ...) - if _parent_0 then - return _parent_0.__init(self, ...) - end - end, - __base = _base_0, - __name = "Whacko", - __parent = _parent_0 - }, { - __index = function(cls, name) - local val = rawget(_base_0, name) - if val == nil and _parent_0 then - return _parent_0[name] - else - return val - end - end, - __call = function(cls, ...) - local _self_0 = setmetatable({}, _base_0) - cls.__init(_self_0, ...) - return _self_0 +local Whacko +Whacko = (function() + local hello + local _parent_0 = nil + local _base_0 = { } + _base_0.__index = _base_0 + if _parent_0 then + setmetatable(_base_0, _parent_0.__base) + end + local _class_0 = setmetatable({ + __init = function(self, ...) + if _parent_0 then + return _parent_0.__init(self, ...) end - }) - _base_0.__class = _class_0 - local self = _class_0 - _ = self.hello - if something then - print("hello world") + end, + __base = _base_0, + __name = "Whacko", + __parent = _parent_0 + }, { + __index = function(cls, name) + local val = rawget(_base_0, name) + if val == nil and _parent_0 then + return _parent_0[name] + else + return val + end + end, + __call = function(cls, ...) + local _self_0 = setmetatable({}, _base_0) + cls.__init(_self_0, ...) + return _self_0 end - hello = "world" - self.another = "day" + }) + _base_0.__class = _class_0 + local self = _class_0 + _ = self.hello + if something then + print("hello world") + end + hello = "world" + self.another = "day" + if something then print("yeah") - if _parent_0 and _parent_0.__inherited then - _parent_0.__inherited(_parent_0, _class_0) - end - return _class_0 - end)() -end + end + if _parent_0 and _parent_0.__inherited then + _parent_0.__inherited(_parent_0, _class_0) + end + return _class_0 +end)() print("hello") \ No newline at end of file