From 4e821308af654706b8bda5f3d00dce7a933d9942 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 25 Apr 2018 17:43:48 -0700 Subject: Overhauling parsing of Blocks (can no longer contain only one statement) --- nomsu_tree.lua | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'nomsu_tree.lua') diff --git a/nomsu_tree.lua b/nomsu_tree.lua index 4a3d7f6..f7a56d7 100644 --- a/nomsu_tree.lua +++ b/nomsu_tree.lua @@ -110,9 +110,6 @@ Tree("Nomsu", { }) Tree("Block", { as_lua = function(self, nomsu) - if #self.value == 1 then - return self.value[1]:as_lua(nomsu) - end local lua = Lua(self.source) for i, line in ipairs(self.value) do local line_lua = line:as_lua(nomsu) @@ -128,11 +125,19 @@ Tree("Block", { if inline == nil then inline = false end - if #self.value == 1 then - return self.value[1]:as_nomsu(inline) - end if inline then - return nil + local nomsu = Nomsu(self.source) + for i, line in ipairs(self.value) do + if i > 1 then + nomsu:append("; ") + end + local line_nomsu = line:as_nomsu(true) + if not (line_nomsu) then + return nil + end + nomsu:append(line_nomsu) + end + return nomsu end local nomsu = Nomsu(self.source) for i, line in ipairs(self.value) do -- cgit v1.2.3