Sync
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
require("nellie.parser")
|
||||
|
||||
function Bind(scope,abstract,callback)
|
||||
for _,expression in pairs(Parse(abstract)) do
|
||||
for _,expression in pairs(Parse(abstract).items) do
|
||||
assert_meta(Expression)(expression)
|
||||
scope:insert(Binding(
|
||||
expression,
|
||||
@@ -21,7 +21,7 @@ end
|
||||
function Do(scope,expression,chain,name)
|
||||
local latest
|
||||
for index,item in pairs(expression.items) do
|
||||
latest = Run(scope,item,chain,"do: "+tostring(index))
|
||||
latest = Run(scope,item,chain,"do: "..tostring(index))
|
||||
end
|
||||
return latest
|
||||
end
|
||||
@@ -283,23 +283,24 @@ Bind(ns,"let ((named (name)) be (value))",function(s,e,c) end)
|
||||
Bind(ns,"new table",function(s,e,c) return {} end)
|
||||
]]
|
||||
|
||||
Bind(ns,"(closed)",function(s,e,c) return Run(s,e.closed,c,"(...)") end)
|
||||
Bind(ns,"text (text)",function(s,e,c) return e.text:text() end)
|
||||
Bind(ns,"(closed)",function(s,e,c) print(e.closed) return Run(s,e.closed,c,"(...)") end)
|
||||
Bind(ns,"log (text)",function(s,e,c) log(Run(s,e.text,c,"print: text")) end)
|
||||
Bind(ns,"this scope",function(s,e,c) return s end)
|
||||
Bind(ns,"new scope",function(s,e,c) return Scope() end) -- TODO: chains?!!?
|
||||
Bind(ns,"index (table) with (key)",function(s,e,c) return Run(s,e,c,"") end)
|
||||
Bind(ns,[[
|
||||
(input) means do (output);
|
||||
(input) in (input_scope) means do (output);
|
||||
(input) means (output);
|
||||
(input) in (input_scope) means (output);
|
||||
(input) means do (output) in (output_scope);
|
||||
(input) in (input_scope) means do (output) in (output_scope)
|
||||
]],function(s,e,c1) -- A substitution
|
||||
local input_scope = s
|
||||
if e.input_scope then input_scope = Run(s,e.input_scope,c1,"means: input scope") end
|
||||
local output_scope = s
|
||||
if e.output_scope then output_scope = Run(s,e.output_scope,c2,"means: output scope") end
|
||||
Bind(e.input_scope,e.input,function(s,e,c2)
|
||||
return Do(e.output_scope,e.output,c2) -- TODO: chains?!
|
||||
(input) in (input_scope) means (output) in (output_scope)
|
||||
]],function(s1,e1,c1) -- A substitution
|
||||
local input_scope = s1
|
||||
if e1.input_scope then input_scope = Run(s1,e1.input_scope,c1,"means: input scope") end
|
||||
local output_scope = s1
|
||||
if e1.output_scope then output_scope = Run(s1,e1.output_scope,c1,"means: output scope") end
|
||||
Bind(input_scope,e1.input,function(s2,e2,c2)
|
||||
return Do(output_scope,e1.output,c2) -- TODO: chains?!
|
||||
end)
|
||||
end)
|
||||
Bind(ns,"do (stuff) in (scope); do (stuff)",function(s,e,c)
|
||||
@@ -311,7 +312,8 @@ Bind(ns,"new table",function(s,e,c) return {} end)
|
||||
local Hpath = "nellie/helper.nel"
|
||||
local Hchain = Chain("in internal: "..Hpath)
|
||||
local success,result = Hchain:call(function(chain)
|
||||
Run(NelliScope,Parse(read(Hpath),Hpath,chain),chain)
|
||||
print(Parse(read(Hpath),Hpath,chain))
|
||||
Do(NelliScope,Parse(read(Hpath),Hpath,chain),chain)
|
||||
end)
|
||||
|
||||
--[[ Documentation:
|
||||
|
||||
Reference in New Issue
Block a user