diff --git a/candran/can-parser/parser.lua b/candran/can-parser/parser.lua index 5b44859..9964c08 100644 --- a/candran/can-parser/parser.lua +++ b/candran/can-parser/parser.lua @@ -585,8 +585,9 @@ local G = { V"Lua", ImplicitPushStat = tagC("Push", commaSep(V"Expr", "RetList")) / markImplicit; NameList = tagC("NameList", commaSep(V"Id")); - DestructuringNameList = tagC("NameList", commaSep(V"DestructuringId")), - AttributeNameList = tagC("AttributeNameList", commaSep(V"AttributeId")); + DestructuringNameList = tagC("NameList", commaSep(V"DestructuringId")); + AttributeNameList = tagC("AttributeNameList", commaSep(V"AttributeId")) + + tagC("PrefixedAttributeNameList", V"Attribute" * commaSep(V"AttributeId")); VarList = tagC("VarList", commaSep(V"VarExpr")); ExprList = tagC("ExpList", commaSep(V"Expr", "ExprList")); diff --git a/compiler/lua53.can b/compiler/lua53.can index ab354f7..e71ab55 100644 --- a/compiler/lua53.can +++ b/compiler/lua53.can @@ -8,6 +8,9 @@ tags.AttributeId = (t) return t[1] end end +tags.PrefixedAttributeNameList = (t) + error("target "..targetName.." does not support variable attributes") +end #placeholder("patch") diff --git a/compiler/lua54.can b/compiler/lua54.can index 49bf3a1..fcfc2ef 100644 --- a/compiler/lua54.can +++ b/compiler/lua54.can @@ -465,7 +465,7 @@ return function(code, ast, options, macros={functions={}, variables={}}) -- Local{ {attributeident+} {expr+}? } Local = (t) local destructured = {} - local r = "local "..push("destructuring", destructured)..lua(t[1], "_lhs")..pop("destructuring") + local r = "local "..push("destructuring", destructured)..lua(t[1])..pop("destructuring") if t[2][1] then r ..= " = "..lua(t[2], "_lhs") end @@ -822,6 +822,14 @@ return function(code, ast, options, macros={functions={}, variables={}}) end return r end, + -- PrefixedAttributeNameList{ attribute {AttributeId+} } + PrefixedAttributeNameList = (t) + return "<" .. t[1] .. "> " .. lua(t, "_lhs", 2) + end, + -- AttributeNameList{ {AttributeId+} } + AttributeNameList = (t) + return lua(t, "_lhs") + end, -- AttributeId{ ? } AttributeId = (t) if t[2] then