-
Notifications
You must be signed in to change notification settings - Fork 80
Open
Description
I'm evaluating the feasibility of using Serpent as Metalua's pretty-printer. I'm stuck with the fact that the result of __tostring metamethods are put into quotes. There's a similar issue with custom printers. For instance:
token_mt = { }
function token_mt :__tostring()
return string.format("token(%s, %s)", self.tag, self.value)
end
function token(tag, value)
return setmetatable({tag=tag; value=value}, token_mt)
end
stream = { token("Keyword", "local"), token("Id", "x") }
s = require 'serpent'
print(s.block(stream))
-- incorrectly produces {"token(Keyword, local)", "token(Id, x)"} which can't be deserialized
pp = require'metalua.pprint'
pp.print(stream)
-- produces { token(Keyword, local), token(Id, x) }, readily accepted by loadstring().
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels