diff --git a/moonscript/parse.lua b/moonscript/parse.lua index 8631715..36be661 100644 --- a/moonscript/parse.lua +++ b/moonscript/parse.lua @@ -395,8 +395,9 @@ local build_grammar = wrap(function() TableValueList = TableValue * (sym"," * TableValue)^0, TableLitLine = PushIndent * ((TableValueList * PopIndent) + (PopIndent * Cut)) + Space, - TableBlockInner = Ct(KeyValueLine * (Break^1 * KeyValueLine)^0), - TableBlock = Break * Advance * TableBlockInner * PopIndent / mark"table", + -- the unbounded table + TableBlockInner = Ct(KeyValueLine * (SpaceBreak^1 * KeyValueLine)^0), + TableBlock = SpaceBreak^1 * Advance * TableBlockInner * PopIndent / mark"table", ClassDecl = key"class" * Name * (key"extends" * Exp + C"")^-1 * TableBlock / mark"class", Export = key"export" * Ct(NameList) / mark"export", diff --git a/tests/inputs/class.moon b/tests/inputs/class.moon index 6cbf22f..b604137 100644 --- a/tests/inputs/class.moon +++ b/tests/inputs/class.moon @@ -38,3 +38,9 @@ x\cool() print x.__class == Simple + +class Okay + -- what is going on + something: 20323 + -- yeaha + diff --git a/tests/inputs/tables.moon b/tests/inputs/tables.moon index b4db5eb..0143fd8 100644 --- a/tests/inputs/tables.moon +++ b/tests/inputs/tables.moon @@ -66,5 +66,20 @@ whatabout = { hello "world", yeah } +x = + -- yeah + something: => "hello" + cool: -- umm + --so ething + bed: { + 2323,2323 + } + red: 2343 -- here + -- what + name: (node) => @value node -- here + -- comment me +-- okay + + diff --git a/tests/outputs/class.lua b/tests/outputs/class.lua index 6d51357..163eb61 100644 --- a/tests/outputs/class.lua +++ b/tests/outputs/class.lua @@ -136,4 +136,30 @@ Simple = (function(_parent_0) end)(Hi) x = Simple() x:cool() -print(x.__class == Simple) \ No newline at end of file +print(x.__class == Simple) +local Okay +Okay = (function(_parent_0) + local _base_0 = { + something = 20323 + } + _base_0.__index = _base_0 + if _parent_0 then + setmetatable(_base_0, getmetatable(_parent_0).__index) + end + local _class_0 = setmetatable({ + __init = function(self, ...) + if _parent_0 then + return _parent_0.__init(self, ...) + end + end + }, { + __index = _base_0, + __call = function(mt, ...) + local self = setmetatable({}, _base_0) + mt.__init(self, ...) + return self + end + }) + _base_0.__class = _class_0 + return _class_0 +end)() \ No newline at end of file diff --git a/tests/outputs/tables.lua b/tests/outputs/tables.lua index 532dc2b..049b7e3 100644 --- a/tests/outputs/tables.lua +++ b/tests/outputs/tables.lua @@ -85,4 +85,19 @@ local whatabout = { hello("world"), yeah, hello("world", yeah) +} +x = { + something = function(self) + return "hello" + end, + cool = { + bed = { + 2323, + 2323 + }, + red = 2343 + }, + name = function(self, node) + return self:value(node) + end } \ No newline at end of file