diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2019-03-04 14:30:38 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2019-03-04 14:30:44 -0800 |
| commit | 58707b18f7d0e1c7526d7c6d39110b52d25a9e4f (patch) | |
| tree | 403f0ebd313fd18a3e1d484f6e5efe8d65faff83 /nomsu_environment.lua | |
| parent | de1f80fe51ea3a760966a304500de75325e1b70b (diff) | |
Fixed a shebang issue
Diffstat (limited to 'nomsu_environment.lua')
| -rw-r--r-- | nomsu_environment.lua | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/nomsu_environment.lua b/nomsu_environment.lua index 08993ea..08face7 100644 --- a/nomsu_environment.lua +++ b/nomsu_environment.lua @@ -170,7 +170,18 @@ nomsu_environment = Importer({ assert(parse, "No parser found for Nomsu syntax version " .. tostring(syntax_version)) local tree = parse(nomsu_code, source.filename) if tree.shebang then - tree.version = tree.version or tree.shebang:match("nomsu %-V[ ]*([%d.]*)") + local shebang_version = tree.shebang:match("nomsu %-V[ ]*([%d.]+)") + if shebang_version and shebang_version ~= "" then + tree.version = tree.version or List((function() + local _accum_0 = { } + local _len_0 = 1 + for v in shebang_version:gmatch("%d+") do + _accum_0[_len_0] = tonumber(v) + _len_0 = _len_0 + 1 + end + return _accum_0 + end)()) + end end return tree end, @@ -288,6 +299,7 @@ nomsu_environment = Importer({ return self:run(tree) elseif SyntaxTree:is_instance(to_run) then local filename = to_run.source.filename:gsub("\n.*", "...") + local version = to_run.version if to_run.type ~= "FileChunks" then to_run = { to_run @@ -295,6 +307,7 @@ nomsu_environment = Importer({ end local ret = nil for chunk_no, chunk in ipairs(to_run) do + chunk.version = version local lua = self:compile(chunk) lua:declare_locals() lua:prepend("-- File: " .. tostring(filename) .. " chunk #" .. tostring(chunk_no) .. "\n") |
