-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSexp.lua
More file actions
40 lines (31 loc) · 792 Bytes
/
Sexp.lua
File metadata and controls
40 lines (31 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require "import"
local function pkg_init(LispSexp)
LispSexp.Sexp = {}
LispSexp.MetaFunction = {}
LispSexp.Ident = {}
function LispSexp.make_sexp(car, cdr)
local rval = {car = car, cdr = cdr}
setmetatable(rval, LispSexp.Sexp)
return rval
end
function LispSexp.make_ident(str)
local rval = {ident = str}
setmetatable(rval, LispSexp.Ident)
return rval
end
function LispSexp.METAFUN(fun)
local rval = {fun = fun}
setmetatable(rval, LispSexp.MetaFunction)
return rval
end
function LispSexp.is_sexp(val)
return (getmetatable(val) == LispSexp.Sexp)
end
function LispSexp.is_ident(val)
return (getmetatable(val) == LispSexp.Ident)
end
function LispSexp.is_metafun(val)
return (getmetatable(val) == LispSexp.MetaFunction)
end
end
return pkg_init