From 7a7dcefc447c4a4b20755fb6fb919a2f6328eafd Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 29 Nov 2018 14:23:02 -0800 Subject: Added text comprehensions (in the style of the list/dict ones) --- nomsu_compiler.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'nomsu_compiler.lua') diff --git a/nomsu_compiler.lua b/nomsu_compiler.lua index b08b5e1..ada9c87 100644 --- a/nomsu_compiler.lua +++ b/nomsu_compiler.lua @@ -330,6 +330,9 @@ local compile = setmetatable({ string_buffer = "" end local bit_lua = compile(bit) + if bit.type == "Block" then + bit_lua = LuaCode:from(bit.source, "(function()", "\n local _buffer = List{}", "\n local function add(bit) _buffer:add(bit) end", "\n local function join_with(glue) _buffer = _buffer:joined_with(glue) end", "\n ", bit_lua, "\n if lua_type_of(_buffer) == 'table' then _buffer = _buffer:joined() end", "\n return _buffer", "\nend)()") + end if lua:trailing_line_len() + #bit_lua:text() > MAX_LINE then lua:append("\n ") end -- cgit v1.2.3