mirror of
https://github.com/Reuh/candran.git
synced 2025-10-27 17:59:30 +00:00
* Added @ self alias * Added short anonymous functions declaration * Made assignment operators works in every direction, except up, down, behind and below, because this would be hard to visualize. * Moved files around. * Error rewriting. * Discover the amazing can commandline tool, which includes a fantastic° REPL and program running abilities. * Added functions which plagiarize Lua. * Added 0.1.0 to the version number. * If you still love pineapple flavored bread, don't hesitate to show your feelings. Also, the tests are out of date. Sad. °: not really.
43 lines
975 B
Lua
43 lines
975 B
Lua
#!/bin/lua
|
|
local candran = require("candran")
|
|
local cmdline = require("lib.cmdline")
|
|
|
|
local args = cmdline(arg)
|
|
|
|
if args.help or args.h then
|
|
print("Candran interpreter version "..candran.VERSION.." by Reuh")
|
|
print("Usage: "..arg[0].." [target=<target>] [options] filename")
|
|
return
|
|
end
|
|
|
|
if #args >= 1 then
|
|
candran.dofile(args[1], args)
|
|
else -- REPL
|
|
print("Candran " .. candran.VERSION)
|
|
candran.setup()
|
|
while true do
|
|
io.write("> ")
|
|
local line = io.read()
|
|
if line:match("^=") then
|
|
line = line:gsub("^=", "return tostring(") .. ")"
|
|
end
|
|
|
|
local p = dofile("lib/lua-parser/parser.lua")
|
|
local d = dofile("lib/lua-parser/pp.lua")
|
|
print(p.parse(line))
|
|
print(d.dump(p.parse(line)))
|
|
print(require"compiler.lua53"(p.parse(line)))
|
|
|
|
local t = { pcall(candran.load, line, "stdin") }
|
|
if t[1] == false then
|
|
print(t[2])
|
|
else
|
|
t = { pcall(t[2]) }
|
|
if t[1] == false then
|
|
print(t[2])
|
|
elseif #t > 1 then
|
|
print(unpack(t, 2))
|
|
end
|
|
end
|
|
end
|
|
end
|