From d82c4f85d8cdb1d4cdf97e90b2715d2fb06b4bef Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 15 Jan 2018 15:50:18 -0800 Subject: Added support for translating comments instead of dropping them. --- nomsu.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'nomsu.lua') diff --git a/nomsu.lua b/nomsu.lua index 587bc22..0df32fb 100644 --- a/nomsu.lua +++ b/nomsu.lua @@ -510,6 +510,12 @@ do elseif "Nomsu" == _exp_0 then local inside, inline = self:tree_to_nomsu(tree.value, force_inline) return "\\" .. tostring(inside), inline + elseif "Comment" == _exp_0 then + if tree.value:find("\n") then + return "#.." .. tostring(self:indent(tree.value)), false + else + return "#" .. tostring(tree.value), false + end elseif "Block" == _exp_0 then if force_inline then return "(:" .. tostring(concat((function() @@ -706,6 +712,10 @@ do return { statements = concat(lua_bits, "\n") } + elseif "Comment" == _exp_0 then + return { + statements = "--" .. tree.value:gsub("\n", "\n--") + } elseif "Nomsu" == _exp_0 then return { expr = "nomsu:parse(" .. tostring(repr(tree.value.src)) .. ", " .. tostring(repr(tree:get_line_no())) .. ").value[1]" -- cgit v1.2.3