From e2909fa834f52be0b7c4af21b641c4f2c042dde8 Mon Sep 17 00:00:00 2001 From: heavpoot Date: Fri, 29 Jan 2021 19:31:43 +0000 Subject: [PATCH 1/2] Fix bugs or something --- src/xlib/03_heavlisp.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/xlib/03_heavlisp.lua b/src/xlib/03_heavlisp.lua index 7eafc6f..6d069d6 100644 --- a/src/xlib/03_heavlisp.lua +++ b/src/xlib/03_heavlisp.lua @@ -1,3 +1,5 @@ +if not unpack then unpack = table.unpack end +local pprint = require("pprint") function deepclone(t) local res={} for i,v in ipairs(t) do @@ -173,7 +175,8 @@ function into_ast(tokens) local tmp=p() if (tmp==nil) or tmp==false or tokens[bk][1]=="EOF" then if tokens[bk][1]~="EOF" then - error("[HL] line "..tokens[bk].line..": some syntax error occured.") + print("line "..tokens[bk].line..": some syntax error occured.") + os.exit(1) end ptr=bk break @@ -265,7 +268,8 @@ function interpret(ast,imports) end end local function throwerror(reason) - error("[HL] line "..cline..": "..reason) + print("line "..cline..": "..reason) + os.exit(1) end local function get(k) local t=top() @@ -298,6 +302,7 @@ function interpret(ast,imports) ["number"]="number", ["boolean"]="bool", ["table"]="list", + ["function"]="function", })[type(v)],value=v}) end end @@ -363,7 +368,7 @@ function interpret(ast,imports) if x and x.type=="list" then local res={type="list",value={}} for i,v in pairs(x.value) do - table.insert(res.value,i) + table.insert(res.value,to(i)) end return res end @@ -419,7 +424,7 @@ function interpret(ast,imports) tmp[#tmp+1]="(function)" end end - print(#args>0 and unpack(tmp) or "nil") + print(unpack(tmp)) return {type="bool",value=true} end, ["type"]=function(x) @@ -574,4 +579,4 @@ end local function run(x,lua) return interpret(into_ast(tokenize(x)),lua) end -return {run=run, interpret=interpret, into_ast=into_ast, tokenize=tokenize} \ No newline at end of file +return {run=run} \ No newline at end of file -- 2.47.0 From 0c6dbe8edd6815d48c9ea912ebb9c7673269d0b0 Mon Sep 17 00:00:00 2001 From: heavpoot Date: Fri, 29 Jan 2021 19:32:24 +0000 Subject: [PATCH 2/2] Update 'src/xlib/03_heavlisp.lua' --- src/xlib/03_heavlisp.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/src/xlib/03_heavlisp.lua b/src/xlib/03_heavlisp.lua index 6d069d6..29b4138 100644 --- a/src/xlib/03_heavlisp.lua +++ b/src/xlib/03_heavlisp.lua @@ -1,5 +1,4 @@ if not unpack then unpack = table.unpack end -local pprint = require("pprint") function deepclone(t) local res={} for i,v in ipairs(t) do -- 2.47.0