aboutsummaryrefslogtreecommitdiff
path: root/nomsu_tree.lua
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-04-25 17:43:48 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-04-25 17:44:24 -0700
commit4e821308af654706b8bda5f3d00dce7a933d9942 (patch)
tree674f4eea13cd7475a14344132ec6f12937ac9a96 /nomsu_tree.lua
parent5d59d510cd6fdc8553250e5ec10f19a285e8878c (diff)
Overhauling parsing of Blocks (can no longer contain only one statement)
Diffstat (limited to 'nomsu_tree.lua')
-rw-r--r--nomsu_tree.lua19
1 files changed, 12 insertions, 7 deletions
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