Renaming.

This commit is contained in:
2026-03-03 14:22:18 +00:00
parent b89e015170
commit d7ca3739aa
9 changed files with 13 additions and 15 deletions

View File

@@ -1,3 +1,4 @@
-- Prototype for nel
require("interpreter") require("interpreter")
function Bind(scope,abstract,callback) function Bind(scope,abstract,callback)
@@ -19,6 +20,7 @@ end
NelliScope = Scope() NelliScope = Scope()
local ns = NelliScope local ns = NelliScope
--[[
-- Replace all :text() occurrences with ones in 'exp_map' -- Replace all :text() occurrences with ones in 'exp_map'
local function substitute(target,exp_map) local function substitute(target,exp_map)
local text = target:text() local text = target:text()
@@ -64,7 +66,7 @@ local function Bexpands(s,e,c)
--[[error(string.format( --[[error(string.format(
"nel: Abstract parameter \"%s\" not in 'quotes'.", "nel: Abstract parameter \"%s\" not in 'quotes'.",
text text
))]] ))]]--[[
else else
table.insert(bound,text) table.insert(bound,text)
end end
@@ -78,8 +80,8 @@ local function Bexpands(s,e,c)
local expanded = substitute(e.expression,map) local expanded = substitute(e.expression,map)
return Run(_s,expanded,_c,"means: "..tostring(expanded)) return Run(_s,expanded,_c,"means: "..tostring(expanded))
end) end)
end end]]
Bind(ns,"(abstract) means (expression)",Bexpands) --[[Bind(ns,"(abstract) means (expression)",Bexpands)
local function Bevaluate(s,e,c) local function Bevaluate(s,e,c)
return Binding(e.abstract,function(_s,_e,_c) return Binding(e.abstract,function(_s,_e,_c)
local scope = Scope() local scope = Scope()
@@ -259,27 +261,20 @@ Bind(ns,"evaluate (text) in (scope)",function(s,e,c)
local scope = Run(s,e.scope,c,"evaluate: scope") local scope = Run(s,e.scope,c,"evaluate: scope")
return Run(s,interpret(Run(scope,e.text,c,"include: source")),c,"include: result") return Run(s,interpret(Run(scope,e.text,c,"include: source")),c,"include: result")
end) end)
Bind(ns,"print (text)",function(s,e,c)
log(Run(s,e.text,c,"print: text"))
end)
Bind(ns,"text (literal)",function(s,e,c) Bind(ns,"text (literal)",function(s,e,c)
return e.literal:text() return e.literal:text()
end) end)
Bind(ns,"return (expression)",function(s,e,c) Bind(ns,"return (expression)",function(s,e,c)
return Run(s,e.expression,c,"return: result") return Run(s,e.expression,c,"return: result")
end)
Bind(ns,"(macro) means (expansion)",function(s,e,c)
end)
Bind(ns,"(identifier) is (value)",function(s,e,c)
end)
Bind(ns,"(expression) becomes (result)",function(s,e,c)
end) end)
Bind(ns,"let (binding) in (scope)",function(s,e,c) Bind(ns,"let (binding) in (scope)",function(s,e,c)
end) end)
]]
Bind(ns,"print (text)",function(s,e,c)
log(Run(s,e.text,c,"print: text"))
end)
local Hpath = "nel/helper.nel" local Hpath = "nel/helper.nel"
local Hchain = Chain("in internal: "..Hpath) local Hchain = Chain("in internal: "..Hpath)
@@ -288,6 +283,8 @@ local success,result = Hchain:call(function(chain)
end) end)
--[[ Documentation: --[[ Documentation:
(log (text)) -> Log text to the output stream (print?)
(a new scope) -> Becomes a created new scope (a new scope) -> Becomes a created new scope
(this scope) -> Becomes the current scope (this scope) -> Becomes the current scope

0
test Normal file
View File

0
tests/print.nel Normal file
View File

1
tests/test.lua Normal file
View File

@@ -0,0 +1 @@
require("")