Merge branch 'master' into patch-1

This commit is contained in:
leaf 2022-11-04 12:51:40 -07:00 committed by GitHub
commit b972b0d538
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 163 additions and 159 deletions

View File

@ -1,6 +1,6 @@
LUA ?= lua5.1
LUA_VERSION = $(shell $(LUA) -e 'print(_VERSION:match("%d%.%d"))')
LUAROCKS = luarocks-$(LUA_VERSION)
LUAROCKS = luarocks --lua-version=$(LUA_VERSION)
LUA_PATH_MAKE = $(shell $(LUAROCKS) path --lr-path);./?.lua;./?/init.lua
LUA_CPATH_MAKE = $(shell $(LUAROCKS) path --lr-cpath);./?.so
@ -25,12 +25,6 @@ compile:
$(LUA) bin/moonc -p bin/moon.moon >> bin/moon
echo "-- vim: set filetype=lua:" >> bin/moon
compile_system:
moonc moon/ moonscript/
echo "#!/usr/bin/env lua" > bin/moon
moonc -p bin/moon.moon >> bin/moon
echo "-- vim: set filetype=lua:" >> bin/moon
watch:
moonc moon/ moonscript/ && moonc -w moon/ moonscript/

3
bin/moonc Executable file → Normal file
View File

@ -6,9 +6,11 @@ local lfs = require "lfs"
local parser = argparse()
parser:flag("-l --lint", "Perform a lint on the file instead of compiling")
parser:flag("-v --version", "Print version")
parser:flag("-w --watch", "Watch file/directory for updates")
parser:option("--transform", "Transform syntax tree with module")
parser:mutex(
parser:option("-t --output-to", "Specify where to place compiled files"),
parser:option("-o", "Write output to file"),
@ -17,6 +19,7 @@ parser:mutex(
parser:flag("-b", "Write parse and compile time instead of code(to stdout)"),
parser:flag("-X", "Write line rewrite map instead of code (to stdout)")
)
parser:flag("-",
"Read from standard in, print to standard out (Must be only argument)")

View File

@ -102,7 +102,11 @@ dump = function(what)
lines = _accum_0
end
seen[what] = false
return "{\n" .. concat(lines) .. (" "):rep((depth - 1) * 4) .. "}\n"
local class_name
if what.__class then
class_name = "<" .. tostring(what.__class.__name) .. ">"
end
return tostring(class_name or "") .. "{\n" .. concat(lines) .. (" "):rep((depth - 1) * 4) .. "}\n"
else
return tostring(what) .. "\n"
end

View File

@ -70,7 +70,10 @@ dump = (what) ->
seen[what] = false
"{\n" .. concat(lines) .. (" ")\rep((depth - 1)*4) .. "}\n"
class_name = if what.__class
"<#{what.__class.__name}>"
"#{class_name or ""}{\n" .. concat(lines) .. (" ")\rep((depth - 1)*4) .. "}\n"
else
tostring(what).."\n"