aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nomsu.4.peg2
-rw-r--r--nomsu_compiler.lua3
-rw-r--r--nomsu_compiler.moon10
3 files changed, 14 insertions, 1 deletions
diff --git a/nomsu.4.peg b/nomsu.4.peg
index f5ce940..d1840f9 100644
--- a/nomsu.4.peg
+++ b/nomsu.4.peg
@@ -171,7 +171,7 @@ indented_plain_text (Text):
~}
text_interpolation:
- inline_text_interpolation / ("\" indented_expression (blank_lines =curr_indent "..")?)
+ inline_text_interpolation / ("\" (indented_expression / indented_block) (blank_lines =curr_indent "..")?)
number (Number):
(&("-"? "0x" [0-9a-fA-F]+) {:hex: '' -> 'yes' :})?
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
diff --git a/nomsu_compiler.moon b/nomsu_compiler.moon
index a818c99..0266dab 100644
--- a/nomsu_compiler.moon
+++ b/nomsu_compiler.moon
@@ -227,7 +227,17 @@ compile = setmetatable({
lua\append string_buffer
added += 1
string_buffer = ""
+
bit_lua = compile(bit)
+ if bit.type == "Block"
+ 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)()"
if lua\trailing_line_len! + #bit_lua\text! > MAX_LINE
lua\append "\n "
if added > 0 then lua\append ".."