diff --git a/moonscript/cmd/lint.lua b/moonscript/cmd/lint.lua index 1fd80b0..52dba4e 100644 --- a/moonscript/cmd/lint.lua +++ b/moonscript/cmd/lint.lua @@ -167,7 +167,7 @@ do local sc = self.statement_compilers self.statement_compilers = setmetatable({ assign = function(block, node) - local _, names, values = unpack(node) + local names = node[2] for _index_0 = 1, #names do local _continue_0 = false repeat diff --git a/moonscript/cmd/lint.moon b/moonscript/cmd/lint.moon index 8317e5c..103c25e 100644 --- a/moonscript/cmd/lint.moon +++ b/moonscript/cmd/lint.moon @@ -76,7 +76,7 @@ class LinterBlock extends Block sc = @statement_compilers @statement_compilers = setmetatable { assign: (block, node) -> - _, names, values = unpack node + names = node[2] -- extract the names to be declared for name in *names -- don't include autogenerated names diff --git a/moonscript/parse.lua b/moonscript/parse.lua index 6345859..b26562d 100644 --- a/moonscript/parse.lua +++ b/moonscript/parse.lua @@ -277,8 +277,8 @@ local function check_lua_string(str, pos, right, left) end -- :name in table literal -local function self_assign(name) - return {{"key_literal", name}, name} +local function self_assign(name, pos) + return {{"key_literal", name}, {"ref", name, [-1] = pos}} end local err_msg = "Failed to parse:%s\n [%d] >> %s" @@ -552,7 +552,7 @@ local build_grammar = wrap_env(function() op"*" + op"^" + Ct(NameList) * (sym"=" * Ct(ExpListLow))^-1) / mark"export", - KeyValue = (sym":" * -SomeSpace * Name) / self_assign + Ct((KeyName + sym"[" * Exp * sym"]" + DoubleString + SingleString) * symx":" * (Exp + TableBlock)), + KeyValue = (sym":" * -SomeSpace * Name * lpeg.Cp()) / self_assign + Ct((KeyName + sym"[" * Exp * sym"]" + DoubleString + SingleString) * symx":" * (Exp + TableBlock)), KeyValueList = KeyValue * (sym"," * KeyValue)^0, KeyValueLine = CheckIndent * KeyValueList * sym","^-1,