forked from osmarks/potatOS
		
	Fix bugs or something
This commit is contained in:
		| @@ -1,3 +1,5 @@ | |||||||
|  | if not unpack then unpack = table.unpack end | ||||||
|  | local pprint = require("pprint") | ||||||
| function deepclone(t) | function deepclone(t) | ||||||
| 	local res={} | 	local res={} | ||||||
| 	for i,v in ipairs(t) do | 	for i,v in ipairs(t) do | ||||||
| @@ -173,7 +175,8 @@ function into_ast(tokens) | |||||||
| 				local tmp=p() | 				local tmp=p() | ||||||
| 				if (tmp==nil) or tmp==false or tokens[bk][1]=="EOF" then | 				if (tmp==nil) or tmp==false or tokens[bk][1]=="EOF" then | ||||||
| 					if 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 | 					end | ||||||
| 					ptr=bk | 					ptr=bk | ||||||
| 					break | 					break | ||||||
| @@ -265,7 +268,8 @@ function interpret(ast,imports) | |||||||
| 		end | 		end | ||||||
| 	end | 	end | ||||||
| 	local function throwerror(reason) | 	local function throwerror(reason) | ||||||
| 		error("[HL] line "..cline..":  "..reason) | 		print("line "..cline..":  "..reason) | ||||||
|  | 		os.exit(1) | ||||||
| 	end | 	end | ||||||
| 	local function get(k) | 	local function get(k) | ||||||
| 		local t=top() | 		local t=top() | ||||||
| @@ -298,6 +302,7 @@ function interpret(ast,imports) | |||||||
| 					["number"]="number", | 					["number"]="number", | ||||||
| 					["boolean"]="bool", | 					["boolean"]="bool", | ||||||
| 					["table"]="list", | 					["table"]="list", | ||||||
|  | 					["function"]="function", | ||||||
| 				})[type(v)],value=v}) | 				})[type(v)],value=v}) | ||||||
| 			end | 			end | ||||||
| 		end | 		end | ||||||
| @@ -363,7 +368,7 @@ function interpret(ast,imports) | |||||||
| 			if x and x.type=="list" then | 			if x and x.type=="list" then | ||||||
| 				local res={type="list",value={}} | 				local res={type="list",value={}} | ||||||
| 				for i,v in pairs(x.value) do | 				for i,v in pairs(x.value) do | ||||||
| 					table.insert(res.value,i) | 					table.insert(res.value,to(i)) | ||||||
| 				end | 				end | ||||||
| 				return res | 				return res | ||||||
| 			end | 			end | ||||||
| @@ -419,7 +424,7 @@ function interpret(ast,imports) | |||||||
| 					tmp[#tmp+1]="(function)" | 					tmp[#tmp+1]="(function)" | ||||||
| 				end | 				end | ||||||
| 			end | 			end | ||||||
| 			print(#args>0 and unpack(tmp) or "nil") | 			print(unpack(tmp)) | ||||||
| 			return {type="bool",value=true} | 			return {type="bool",value=true} | ||||||
| 		end, | 		end, | ||||||
| 		["type"]=function(x) | 		["type"]=function(x) | ||||||
| @@ -574,4 +579,4 @@ end | |||||||
| local function run(x,lua) | local function run(x,lua) | ||||||
| 	return interpret(into_ast(tokenize(x)),lua) | 	return interpret(into_ast(tokenize(x)),lua) | ||||||
| end | end | ||||||
| return {run=run, interpret=interpret, into_ast=into_ast, tokenize=tokenize} | return {run=run} | ||||||
		Reference in New Issue
	
	Block a user