aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-11-23 17:22:22 -0800
committerBruce Hill <bruce@bruce-hill.com>2018-11-23 17:22:29 -0800
commit1a794c64871fa044c3024a7771ee4123e800d3b2 (patch)
treed4a9b215995365a037a67827db32856d4248e1c2
parent0b082397bb0366a5af250bdf1c757e0c26571de6 (diff)
Tweaks and tidying.
-rw-r--r--nomsu_compiler.lua7
-rw-r--r--nomsu_compiler.moon3
-rw-r--r--nomsu_environment.lua15
-rw-r--r--nomsu_environment.moon1
4 files changed, 16 insertions, 10 deletions
diff --git a/nomsu_compiler.lua b/nomsu_compiler.lua
index a83f4ec..5a840ea 100644
--- a/nomsu_compiler.lua
+++ b/nomsu_compiler.lua
@@ -68,11 +68,6 @@ compile_error = function(source, err_msg, hint)
})
return error(err_str, 0)
end
-local tree_to_nomsu, tree_to_inline_nomsu
-do
- local _obj_0 = require("nomsu_decompiler")
- tree_to_nomsu, tree_to_inline_nomsu = _obj_0.tree_to_nomsu, _obj_0.tree_to_inline_nomsu
-end
local math_expression = re.compile([[ (([*/^+-] / [0-9]+) " ")* [*/^+-] !. ]])
local MAX_LINE = 80
local compile = setmetatable({
@@ -434,7 +429,7 @@ local compile = setmetatable({
elseif "Number" == _exp_0 then
return LuaCode:from(tree.source, tostring(tree[1]))
elseif "Var" == _exp_0 then
- return LuaCode:from(tree.source, (tree[1]):as_lua_id())
+ return LuaCode:from(tree.source, (concat(tree, " ")):as_lua_id())
elseif "FileChunks" == _exp_0 then
return error("Can't convert FileChunks to a single block of lua, since each chunk's " .. "compilation depends on the earlier chunks")
elseif "Comment" == _exp_0 then
diff --git a/nomsu_compiler.moon b/nomsu_compiler.moon
index 794d87b..3600e60 100644
--- a/nomsu_compiler.moon
+++ b/nomsu_compiler.moon
@@ -41,7 +41,6 @@ compile_error = (source, err_msg, hint=nil)->
start:source.start, stop:source.stop, filename:source.filename
}
error(err_str, 0)
-{:tree_to_nomsu, :tree_to_inline_nomsu} = require "nomsu_decompiler"
-- This is a bit of a hack, but this code handles arbitrarily complex
-- math expressions like 2*x + 3^2 without having to define a single
@@ -322,7 +321,7 @@ compile = setmetatable({
return LuaCode\from(tree.source, tostring(tree[1]))
when "Var"
- return LuaCode\from(tree.source, (tree[1])\as_lua_id!)
+ return LuaCode\from(tree.source, (concat(tree, " "))\as_lua_id!)
when "FileChunks"
error("Can't convert FileChunks to a single block of lua, since each chunk's "..
diff --git a/nomsu_environment.lua b/nomsu_environment.lua
index 6f46640..5838a1d 100644
--- a/nomsu_environment.lua
+++ b/nomsu_environment.lua
@@ -30,8 +30,19 @@ for version = 1, 999 do
local peg_file
if package.nomsupath then
for path in package.nomsupath:gmatch("[^;]+") do
- peg_file = io.open(path .. "/nomsu." .. tostring(version) .. ".peg")
- if peg_file then
+ local _continue_0 = false
+ repeat
+ if path == "." and package.nomsupath ~= "." then
+ _continue_0 = true
+ break
+ end
+ peg_file = io.open(path .. "/nomsu." .. tostring(version) .. ".peg")
+ if peg_file then
+ break
+ end
+ _continue_0 = true
+ until true
+ if not _continue_0 then
break
end
end
diff --git a/nomsu_environment.moon b/nomsu_environment.moon
index 00b8a3f..add852a 100644
--- a/nomsu_environment.moon
+++ b/nomsu_environment.moon
@@ -20,6 +20,7 @@ for version=1,999
local peg_file
if package.nomsupath
for path in package.nomsupath\gmatch("[^;]+")
+ continue if path == "." and package.nomsupath != "."
peg_file = io.open(path.."/nomsu.#{version}.peg")
break if peg_file
else