mirror of
https://github.com/Reuh/candran.git
synced 2026-02-04 02:08:40 +00:00
feat: add prefix attributes in variables declarations
This commit is contained in:
parent
1e118381f8
commit
19405a4d8e
3 changed files with 15 additions and 3 deletions
|
|
@ -585,8 +585,9 @@ local G = { V"Lua",
|
||||||
ImplicitPushStat = tagC("Push", commaSep(V"Expr", "RetList")) / markImplicit;
|
ImplicitPushStat = tagC("Push", commaSep(V"Expr", "RetList")) / markImplicit;
|
||||||
|
|
||||||
NameList = tagC("NameList", commaSep(V"Id"));
|
NameList = tagC("NameList", commaSep(V"Id"));
|
||||||
DestructuringNameList = tagC("NameList", commaSep(V"DestructuringId")),
|
DestructuringNameList = tagC("NameList", commaSep(V"DestructuringId"));
|
||||||
AttributeNameList = tagC("AttributeNameList", commaSep(V"AttributeId"));
|
AttributeNameList = tagC("AttributeNameList", commaSep(V"AttributeId"))
|
||||||
|
+ tagC("PrefixedAttributeNameList", V"Attribute" * commaSep(V"AttributeId"));
|
||||||
VarList = tagC("VarList", commaSep(V"VarExpr"));
|
VarList = tagC("VarList", commaSep(V"VarExpr"));
|
||||||
ExprList = tagC("ExpList", commaSep(V"Expr", "ExprList"));
|
ExprList = tagC("ExpList", commaSep(V"Expr", "ExprList"));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,9 @@ tags.AttributeId = (t)
|
||||||
return t[1]
|
return t[1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
tags.PrefixedAttributeNameList = (t)
|
||||||
|
error("target "..targetName.." does not support variable attributes")
|
||||||
|
end
|
||||||
|
|
||||||
#placeholder("patch")
|
#placeholder("patch")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -465,7 +465,7 @@ return function(code, ast, options, macros={functions={}, variables={}})
|
||||||
-- Local{ {attributeident+} {expr+}? }
|
-- Local{ {attributeident+} {expr+}? }
|
||||||
Local = (t)
|
Local = (t)
|
||||||
local destructured = {}
|
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
|
if t[2][1] then
|
||||||
r ..= " = "..lua(t[2], "_lhs")
|
r ..= " = "..lua(t[2], "_lhs")
|
||||||
end
|
end
|
||||||
|
|
@ -822,6 +822,14 @@ return function(code, ast, options, macros={functions={}, variables={}})
|
||||||
end
|
end
|
||||||
return r
|
return r
|
||||||
end,
|
end,
|
||||||
|
-- PrefixedAttributeNameList{ attribute {AttributeId+} }
|
||||||
|
PrefixedAttributeNameList = (t)
|
||||||
|
return "<" .. t[1] .. "> " .. lua(t, "_lhs", 2)
|
||||||
|
end,
|
||||||
|
-- AttributeNameList{ {AttributeId+} }
|
||||||
|
AttributeNameList = (t)
|
||||||
|
return lua(t, "_lhs")
|
||||||
|
end,
|
||||||
-- AttributeId{ <string> <string>? }
|
-- AttributeId{ <string> <string>? }
|
||||||
AttributeId = (t)
|
AttributeId = (t)
|
||||||
if t[2] then
|
if t[2] then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue