diff --git a/format-adapter.lua b/format-adapter.lua index 060af49b..fe6ac55a 100644 --- a/format-adapter.lua +++ b/format-adapter.lua @@ -16,6 +16,9 @@ local function syntax_convert(tree) elseif tree.kind == "literal" then return metalanguage.value(tree.anchor, { type = tree.literaltype, val = tree.val }) elseif tree.kind == "string" then + if type(tree.elements) == "string" then + return metalanguage.value(tree.anchor, { type = "string", val = tree.elements }) + end if #tree.elements ~= 1 or tree.elements[1].literaltype ~= "bytes" then error "NYI: strings with splices / not exactly one literal" end diff --git a/format.lua b/format.lua index 624a19b6..f416a2ac 100644 --- a/format.lua +++ b/format.lua @@ -139,7 +139,7 @@ local grammar = P { * (C(V "subordinate_indent" * V "contiguous_body") + (C(V "newline") * S "\t " ^ 0 * #V "newline")) ^ 0, comment = element("comment", Cg(P "#" * lpeg.Cf(V "subordinate_body", string_concat), "val")), -- TODO automatically convert body to schema bytes variant - longstring = element("string", Cg(lpeg.Cf((P [[""""]] * V "subordinate_body"), string_concat), "val")), + longstring = element("string", Cg(lpeg.Cf((P [[""""]] * V "subordinate_body"), string_concat), "elements")), -- numbers are limited, they are not bignums, they are standard lua numbers. scopes shares the problem of files not having arbitrary precision -- so it probably doesn't matter.