Skip to content

Commit

Permalink
format: bodge longstring like string
Browse files Browse the repository at this point in the history
  • Loading branch information
LunNova committed Dec 4, 2023
1 parent 0425da3 commit 7297f47
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions format-adapter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion format.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 7297f47

Please sign in to comment.