Removing archive.

This commit is contained in:
2026-02-27 16:46:43 +00:00
parent d600fc7232
commit 7edad0c5bb
12 changed files with 2 additions and 788 deletions

View File

@@ -1,327 +0,0 @@
require("interpret")
function B(scope,abstract,callback)
scope:insert(
Binding(
interpret(abstract),
callback
)
)
end
function R(scope,expression,chain,name)
name = name or "?"
assert_meta(Expression)(expression,"Arg 'expression' #2: %s")
assert_meta(Chain)(chain,"Arg 'chain' #3: %s")
local chain = Chain(expression:link(name)):from(chain)
return scope:run(expression,chain,scope)
end
NelliScope = Scope()
local ns = NelliScope
B(ns,"print (text)",function(s,e,c)
log(R(s,e.text,c,"print: text"))
end)
B(ns,"text (literal)",function(s,e,c)
return e.literal:text()
end)
-- Replace all :text() occurrences with ones in 'exp_map'
local function substitute(target,exp_map)
local text = target:text()
if text then -- Replace the parameter
local map = exp_map[text]
if map then
return Expression({map})
else
return target
end
else
local new = Expression()
for sub in iterate(target.items) do
local t = type_of(sub)
if t == "string" then
new:insert(sub)
elseif t == Expression then
new:insert(substitute(sub,exp_map))
end
end
return new
end
end
-- Iterate over all :text() occurrences
local function traverse(expression,callback)
for sub in iterate(expression.items) do
if type_of("sub") == Expression then
traverse(sub,callback)
else
callback(sub)
end
end
end
local function Bmeans(s,e,c)
local scope
if e.scope then
scope = R(s,e.scope,c,"means: using: scope: %s")
end
local bound = {}
for sub in iterate(e.abstract.items) do
local t = type_of(sub)
if t == Expression then
local text = sub:text()
if not text:match("'.+'") then
--[[error(string.format(
"nel: Abstract parameter \"%s\" not in 'quotes'.",
text
))]]
else
table.insert(bound,text)
end
end
end
return Binding(e.abstract,function(_s,_e,_c)
local map = {}
for binding in iterate(bound) do
map[binding] = _e[binding]
end
local expanded = substitute(e.expression,map)
return R(scope or _s,expanded,_c,"means: "..tostring(expanded))
end)
end
B(ns,"(abstract) means (expression) using (scope)",Bmeans)
local function Bdo(s,e,c)
local scope
if e.scope then
scope = R(s,e.scope,c,"do: scope")
else
scope = Scope()
scope.parent = s
end
local res
for item in iterate(e.expressions.items) do
if type_of(item) ~= Expression then
error(
string.format(
"Unexpected words '%s' in 'do' expression.",
tostring(item)
)
)
end
res = R(scope,item,c,"do: line")
end
return res
end
B(ns,"do (expressions)",Bdo)
B(ns,"do (expression) in (scope)",function(s,e,c)
local scope = R(s,e.scope,c,"do: scope")
assert_meta(Scope)(scope,"nel: (do: scope): %s")
R(scope,e.expression,c,"do: expression")
end)
B(ns,"error (text)",function(s,e,c)
error("nel: "..R(s,e.text,c,"error: message"))
end)
B(ns,"if (predicate) then (expression)",function(s,e,c)
if R(s,e.predicate,c,"if: predicate") then
return R(s,e.expression,c,"if: result")
end
end)
B(ns,"true",function(s,e,c) return true end)
B(ns,"false",function(s,e,c) return false end)
B(ns,"constant (constant) = (expression)",function(s,e,c)
local value = R(s,e.expression,c,"constant: expression")
e.constant:text()
s:insert(
Binding(e.constant,function(s,e,c)
return value
end)
)
end)
B(ns,"format (string) with (terms)",function(s,e,c)
local items = {}
for expression in iterate(e.terms.items) do
table.insert(items,R(s,expression),c,"format: term")
end
return string.format(
R(s,e.string,c,"format: string"),
table.unpack(items)
)
end)
B(ns,"while (predicate) (expression)",function(s,e,c)
while R(s,e.predicate,c,"while: predicate") do
R(s,e.expression,c,"while: loop")
end
end)
B(ns,"repeat (expression) while (predicate)",function(s,e,c)
while true do
R(s,e.expression,c,"repeat: expression")
if not R(s,e.predicate,c,"repeat: predicate") then
break
end
end
end)
B(ns,"repeat (expression) until (predicate)",function(s,e,c)
while true do
R(s,e.expression,c,"repeat: expression")
if R(s,e.predicate,c,"repeat: predicate") then
break
end
end
end)
B(ns,"new table",function(s,e,c)
return {}
end)
B(ns,"(index) of (table)",function(s,e,c)
return (R(s,e.table,"of: index"))[R(s,e.index,c,"of: table")]
end)
B(ns,"set (index) of (table) to (item)",function(s,e,c)
R(s,e.table,c,"of-to: index")[R(s,e.index,c,"of-to: table")] = s:run(e.item,c,"of-to: item")
end)
B(ns,"remove (index) of (table)",function(s,e,c)
(R(s,e.table,"remove: table"))[R(s,e.index,c,"remove: index")] = nil
end)
B(ns,"nothing",function(s,e,c)
return nil
end)
--[[ Note
A macro executes in the same scope of the callee.
A defintion executes in the scope it was defined.
I would argue that macros are more unpredictable!
However, they allow for some very clean code.
--]]
B(ns,"here",function(s,e,c)
return s
end)
B(ns,"return (object)",function(s,e,c)
return R(s,e.object,c,"return: object")
end)
B(ns,"this scope",function(s,e,c)
return s
end)
B(ns,"in scope (scope) (expressions)",function(s,e,c)
return R(R(s,e.scope,c,"in scope: scope"),e.scope,c,"in scope: expression")
end)
local function Bdef(s,e,c)
if e.scope then
s = R(s,e.scope,c,"define: scope")
end
s:insert(Binding(e.abstract,function(_s,_e,_c)
local scope = Scope()
scope.parent = s
for identifier,expression in pairs(_e) do
scope:insert(
Binding(
Expression({identifier}),
R(_s,expression,_c,string.format(
"define: param: \"%s\"",
identifier
))
)
)
end
return R(scope,e.expression,_c,string.format(
"define: expression:\n\t\t%s\n\t",
table.concat(c:flatten(),"\n\t")
))
end))
end
B(ns,"define (abstract) as (expression)",Bdef)
B(ns,"define (abstract) as (expression) in (scope)",Bdef)
-- Create a constant binding
B(ns,"(abstract) is (expression)",function(s,e,c)
local result = R(s,e.expression,c,"be: expression")
return Binding(e.abstract,result)
end)
-- Insert a binding into the current scope
B(ns,"here (bindings)",function(s,e,c)
for meaning in e.binding:iterate() do
for sub in e.binding:iterate() do
local t = type_of(sub)
if t ~= Expression then
print(t,getmetatable(t))
error(string.format(
"nel: (here: bindings): %s%s\n\t%s",
"Expected subexpressions only got: ",
tostring(sub),
"Note: Are you using '{...}' style brackets?"
))
else
local bind = R(s,sub,c,"here: binding")
assert_meta(Binding)(bind,"nel: (here: binding): %s")
s:insert(bind)
end
end
end
end)
-- Insert a binding into a scope
B(ns,"in (scope) let (binding)",function(s,e,c)
assert_meta(Binding)(e.binding,"nel: (here: binding): %s")
assert_meta(Scope)(e.scope,"nel: (here: scope): %s")
R(s,e.scope,c,"let: scope"):insert(R(s,e.binding,c,"let: binding"))
end)
B(ns,[[
define (abstract)
as (expression)
in (scope)
using (parameter_scope)
]],Bdef)
local List = class("List")
function List:new(...)
self.items = {...}
end
B(ns,"new list",function(s,e,c)
return List()
end)
B(ns,"insert (item) into (list)",function(s,e,c)
table.insert(R(s,e.list).items,R(s,e.item),c,c)
end)
B(ns,"insert (item) into (list) at (index)",function(s,e,c)
table.insert(s:evaulate(e.list).items,R(s,e.index),R(s,item),c,c)
end)
B(ns,"remove (needle) from (haystack)",function(s,e,c)
local tab = R(s,e.haystack,c)
table.remove(tab,table.find(tab,R(s,e.needle)),c)
end)
B(ns,"remove from (haystack) at (index)",function(s,e,c)
table.remove(R(s,e.list),R(s,e.index),c,c)
end)
-- Create a scope parented to the current scope as an object
B(ns,"new scope here",function(s,e,c)
local scope = Scope
scope.parent = s
return scope
end)
-- Create a scope with nothing in it as an object (weird)
B(ns,"new scope",function(s,e,c)
return Scope()
end)
-- Read a file in the current directly, more for compiling
B(ns,"read (path)",function(s,e,c)
return read(R(s,e.path,c,"read: path"))
end)
-- Take some text and interpret it into an expression
B(ns,"include (text)",function(s,e,c)
return R(s,interpret(R(s,e.text,c,"include: source")),c,"include: result")
end)
interpret([[
here {
(here ('name') is ('value'))
means
(here {
('name') is ('value')
});
(here ('abstract') means ('expression'))
means
(here {
('abstract') means ('expression')
});
(here ('abstract') means ('expression') using ('scope'))
means
(here {
('abstract') means ('expression')
} using ('scope'))
}
]])
return ns

View File

@@ -1,13 +0,0 @@
I am thinking for the syntax in nel.
How can we have multiple arguments for something?
It feels rather stupid allowing this really.
It's not very clear, a list is a list in any case.
So maybe we really should just have another
substatement, and forget about powering up
the abstracts, for now? ...?
Well then... in that case.
We only need to make sure scoping works.
Which means, scopes inherit from eachother,
and applying congruent bindings causes an error.
I think.

View File

@@ -1,159 +0,0 @@
taking expressions and parsing them later down?
that seems slightly stupid.
really, an expression is sort of a tree that
hasn't been dealt with yet.
is it really wise to keep passing them down as
just that expression?
otherwise it would have to be evaluated in the later
scope.
it makes more sense to sort of evaluate things
as we go along.
at the very least, every expression will always end
up being 'something'.
it just means that we need to execute different
expressions in different contexts
i guess.
so 'meaning' becomes slightly more interesting here.
i guess this would be where the macros fit.
we could use a macro, which literally replaces
a particular expression with another one, somehow, or
maybe pass in some other sort of context to evaluate
these things under. but that would evaluate everything
that way.
it would be nice if we could somehow refer to an
expression as what it is expressed as, but also
what it will be.
i mean: let (render (elements)) mean (... do stuff ...)
is great and all because i can now do:
render (
box()
)
but then how about
let (view) mean (box())
and then render(view)
that clearly does not work, but absolutely should be
valid nel code.
with equal pertinence, on the other hand we have:
let (sum) mean (math (5 + 2))
where math ()...
hold on. i think i know why this is actually confusing
me. it also connects quite well with how source code
works.
'mean' means 'copy the expression in place'
somehow preserving the scope.
but
'be' means 'the literal value we want'
which is, definitely rather odd. very odd.
how is each one useful in their own right?
i think, my issue is that im really struggling
to see the direct separation between what we have
defined in nel and what the compiled bits should be!
code {
(number) means (int)
let (x) is a (number)
let (y) is a (number)
let (sum) is a (number), is (x + y)
}
i mean its weird. very weird.
since the 'let' bits should really be interpreted by
the 'code' expression to represent some local variables
in source code!
but then the 'means' bit quite literally breaks that idea
in two because that isn't source code at all it's just
doing its own thing really.
we ideally want 'means' to be available everywhere?
are there any situations where it is bad?
and again, what about macros?
so maybe back to html as a weird example
ui {
box()
}
i think i get it now.
when you use 'means' you are creating a new binding in
the scope that forces NEL to create a 'value' which
is more a wrapper (or even a trap!) that calls that
particular expression again in the parent scope.
this IS that macro, and i think it is quite deadly.
which makes me wonder, is this a good idea to have
around? well, i'm not sure!
in a lot of cases, this is actually very nice, because
we can literally just functionally expand our ENTIRE
program out as we please without any function overhead.
note that this is bad for maintainability and code bloat.
we also still have the power of a general routine, so this
isn't all doom and gloom really.
how weird.
i think i am sort of ok knowing this now, even though
i am now very much more confused than even before.
however, this turns out to be very nice.
so:
(doeth (code)) means (do (code))
right, crap. effectively here that entire idea doesn't
really hold water simply because i need the candid
expression to be able to execute the nellie effectively.
that's not entirely great is it now.
'means' and 'do' operations themselves work over abstract
nel anyways. this sum foolery indeed.
so effectively, abstract nel doesnt like abstract nel,
yes yes yes that makes complete sense actually.
because with doubly abstract nel we cannot just say
(action) means (print (text (fart)))
and then literally
do {
action;
action;
action;
}
or even worse have some sort of multiplicative expression.
it's just not feasible you see!
however, i now think i have a sort of idea.
you see, with bindings, we can have values
i have been thinking for a while and i am not sure if
i can easily find some sort of solution to all of this.
it's quite concerning really.
do {}
represents a list of expressions, how can we define this,
just in pure NEL, to execute each statement.
because, and i need to keep saying it, NEL should compile
NEL, no?
if EVERYTHING is written in NEL, then i surely should be
allowed to write nel that can interpret expressions this
way. it just feels incredibly stupid to not be able to.
like what?
all while being simple to understand. completely insane.
COMPLETELY, insane.
unless... just about unless.
all expressions were functions.
that promised to give back an expression.
i realise now that my mind is very very weak.
there is something missing from it. it's not about all the
puzzles. it seems definition is trivial to everything.
but this algorithm seems to me like a knot.
its not a knot, i know there is a very clean solution,
i just cant see it right now.
i need to actually break things down into what i want first
so i can see things as clearly as i possibly can

View File

@@ -1,19 +0,0 @@
// My name is 'pal'
/* Some sorcery for a query? */
// There is an object which is me
// There is an object 'pal' (how pronounce?)
// I guess a 'written as' branch
/* Notes:
Queries can create queries (are they called 'queries'?)
They specify a general scenario.
Can they have constants? Are those constants branches?
*/
// wtf ^
/* From DMLR
there was self referencing logic.
quantifiers over general objects
*/

View File

@@ -1,23 +0,0 @@
do {
let {
( here (abstract) expands to (expression) )
expands to
( let { (abstract) expands to (expression) } in (this scope) );
(here (abstract) evaluates to (expression))
expands to
(let {(abstract) evaluates to (expression)} in (this scope));
( here (abstract) is equal to (expression) )
expands to
( let {(abstract) is equal to (expression)} in (this scope) );
(module (the path))
expands to
(do {
here (the scope) is (a new scope);
evaluate (read file (the path)) in (the scope);
return (the scope);
});
};
}

View File

@@ -1,14 +0,0 @@
do {
// Scope for the language that we will write in NEL
here (I scope) is (new scope); // I -> NEL Intermediate Code
// Compile (...) should return the compiled text
here (compile ('code'))
expands to
(do {'code'} in (I scope));
// Definitions for things in the I scope
let {
} in (I scope)
}

View File

@@ -1,3 +0,0 @@
do {
} in ((module ("nel/translator/main.nel"))

View File

@@ -1,14 +0,0 @@
do {
here (lang scope) is (new scope);
let {
here ( call (identifier) (values) ) evaluates to (
here (source) is
)
here ( text (literal) ) evaluates to ( text (literal) )
here ( print (values) ) expands to ( call (print) (values) )
} in (lang scope)
here (compile (code))
expands to
(do (code) in (lang scope));
}

View File

@@ -1,6 +0,0 @@
do {
here ((fart) means (print "fart"));
fart;
fart;
fart;
}

View File

@@ -1,205 +0,0 @@
let SessionLoad = 1
let s:so_save = &g:so | let s:siso_save = &g:siso | setg so=0 siso=0 | setl so=-1 siso=-1
let v:this_session=expand("<sfile>:p")
silent only
silent tabonly
cd ~/Programming/nel/1
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
let s:wipebuf = bufnr('%')
endif
let s:shortmess_save = &shortmess
if &shortmess =~ 'A'
set shortmess=aoOA
else
set shortmess=aoO
endif
badd +167 main.lua
badd +27 parse.lua
badd +0 term://~/Programming/nel/1//1946:/usr/bin/zsh
badd +0 interpret.lua
badd +0 test.nel
badd +191 helper.lua
argglobal
%argdel
$argadd ~/Programming/nel/1
edit parse.lua
let s:save_splitbelow = &splitbelow
let s:save_splitright = &splitright
set splitbelow splitright
wincmd _ | wincmd |
vsplit
1wincmd h
wincmd _ | wincmd |
split
1wincmd k
wincmd _ | wincmd |
vsplit
1wincmd h
wincmd w
wincmd w
wincmd w
wincmd _ | wincmd |
split
1wincmd k
wincmd w
let &splitbelow = s:save_splitbelow
let &splitright = s:save_splitright
wincmd t
let s:save_winminheight = &winminheight
let s:save_winminwidth = &winminwidth
set winminheight=0
set winheight=1
set winminwidth=0
set winwidth=1
exe '1resize ' . ((&lines * 24 + 19) / 39)
exe 'vert 1resize ' . ((&columns * 60 + 90) / 181)
exe '2resize ' . ((&lines * 24 + 19) / 39)
exe 'vert 2resize ' . ((&columns * 60 + 90) / 181)
exe '3resize ' . ((&lines * 12 + 19) / 39)
exe 'vert 3resize ' . ((&columns * 121 + 90) / 181)
exe '4resize ' . ((&lines * 24 + 19) / 39)
exe 'vert 4resize ' . ((&columns * 59 + 90) / 181)
exe '5resize ' . ((&lines * 12 + 19) / 39)
exe 'vert 5resize ' . ((&columns * 59 + 90) / 181)
argglobal
setlocal foldmethod=manual
setlocal foldexpr=v:lua.vim.treesitter.foldexpr()
setlocal foldmarker={{{,}}}
setlocal foldignore=#
setlocal foldlevel=0
setlocal foldminlines=1
setlocal foldnestmax=20
setlocal foldenable
silent! normal! zE
let &fdl = &fdl
let s:l = 267 - ((8 * winheight(0) + 12) / 24)
if s:l < 1 | let s:l = 1 | endif
keepjumps exe s:l
normal! zt
keepjumps 267
normal! 019|
lcd ~/Programming/nel/1
wincmd w
argglobal
if bufexists(fnamemodify("~/Programming/nel/1/interpret.lua", ":p")) | buffer ~/Programming/nel/1/interpret.lua | else | edit ~/Programming/nel/1/interpret.lua | endif
if &buftype ==# 'terminal'
silent file ~/Programming/nel/1/interpret.lua
endif
balt ~/Programming/nel/1/parse.lua
setlocal foldmethod=manual
setlocal foldexpr=v:lua.vim.treesitter.foldexpr()
setlocal foldmarker={{{,}}}
setlocal foldignore=#
setlocal foldlevel=0
setlocal foldminlines=1
setlocal foldnestmax=20
setlocal foldenable
silent! normal! zE
let &fdl = &fdl
let s:l = 58 - ((15 * winheight(0) + 12) / 24)
if s:l < 1 | let s:l = 1 | endif
keepjumps exe s:l
normal! zt
keepjumps 58
normal! 034|
lcd ~/Programming/nel/1
wincmd w
argglobal
if bufexists(fnamemodify("term://~/Programming/nel/1//1946:/usr/bin/zsh", ":p")) | buffer term://~/Programming/nel/1//1946:/usr/bin/zsh | else | edit term://~/Programming/nel/1//1946:/usr/bin/zsh | endif
if &buftype ==# 'terminal'
silent file term://~/Programming/nel/1//1946:/usr/bin/zsh
endif
balt ~/Programming/nel/1/parse.lua
setlocal foldmethod=manual
setlocal foldexpr=0
setlocal foldmarker={{{,}}}
setlocal foldignore=#
setlocal foldlevel=0
setlocal foldminlines=1
setlocal foldnestmax=20
setlocal foldenable
let s:l = 947 - ((11 * winheight(0) + 6) / 12)
if s:l < 1 | let s:l = 1 | endif
keepjumps exe s:l
normal! zt
keepjumps 947
normal! 040|
lcd ~/Programming/nel/1
wincmd w
argglobal
if bufexists(fnamemodify("~/Programming/nel/1/main.lua", ":p")) | buffer ~/Programming/nel/1/main.lua | else | edit ~/Programming/nel/1/main.lua | endif
if &buftype ==# 'terminal'
silent file ~/Programming/nel/1/main.lua
endif
balt ~/Programming/nel/1/helper.lua
setlocal foldmethod=manual
setlocal foldexpr=v:lua.vim.treesitter.foldexpr()
setlocal foldmarker={{{,}}}
setlocal foldignore=#
setlocal foldlevel=0
setlocal foldminlines=1
setlocal foldnestmax=20
setlocal foldenable
silent! normal! zE
let &fdl = &fdl
let s:l = 178 - ((21 * winheight(0) + 12) / 24)
if s:l < 1 | let s:l = 1 | endif
keepjumps exe s:l
normal! zt
keepjumps 178
normal! 012|
lcd ~/Programming/nel/1
wincmd w
argglobal
if bufexists(fnamemodify("~/Programming/nel/1/test.nel", ":p")) | buffer ~/Programming/nel/1/test.nel | else | edit ~/Programming/nel/1/test.nel | endif
if &buftype ==# 'terminal'
silent file ~/Programming/nel/1/test.nel
endif
balt ~/Programming/nel/1/main.lua
setlocal foldmethod=manual
setlocal foldexpr=0
setlocal foldmarker={{{,}}}
setlocal foldignore=#
setlocal foldlevel=0
setlocal foldminlines=1
setlocal foldnestmax=20
setlocal foldenable
silent! normal! zE
let &fdl = &fdl
let s:l = 5 - ((4 * winheight(0) + 6) / 12)
if s:l < 1 | let s:l = 1 | endif
keepjumps exe s:l
normal! zt
keepjumps 5
normal! 0
lcd ~/Programming/nel/1
wincmd w
3wincmd w
exe '1resize ' . ((&lines * 24 + 19) / 39)
exe 'vert 1resize ' . ((&columns * 60 + 90) / 181)
exe '2resize ' . ((&lines * 24 + 19) / 39)
exe 'vert 2resize ' . ((&columns * 60 + 90) / 181)
exe '3resize ' . ((&lines * 12 + 19) / 39)
exe 'vert 3resize ' . ((&columns * 121 + 90) / 181)
exe '4resize ' . ((&lines * 24 + 19) / 39)
exe 'vert 4resize ' . ((&columns * 59 + 90) / 181)
exe '5resize ' . ((&lines * 12 + 19) / 39)
exe 'vert 5resize ' . ((&columns * 59 + 90) / 181)
tabnext 1
if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0 && getbufvar(s:wipebuf, '&buftype') isnot# 'terminal'
silent exe 'bwipe ' . s:wipebuf
endif
unlet! s:wipebuf
set winheight=1 winwidth=20
let &shortmess = s:shortmess_save
let &winminheight = s:save_winminheight
let &winminwidth = s:save_winminwidth
let s:sx = expand("<sfile>:p:r")."x.vim"
if filereadable(s:sx)
exe "source " . fnameescape(s:sx)
endif
let &g:so = s:so_save | let &g:siso = s:siso_save
set hlsearch
doautoall SessionLoadPost
unlet SessionLoad
" vim: set ft=vim :

View File

@@ -1,3 +0,0 @@
do {
print "wsg";
}