1
0
Fork 0
mirror of https://github.com/Reuh/anselme.git synced 2025-10-27 16:49:31 +00:00

Changed a few things

- Bumped to 0.15.0
- Add boot script
- Change variable definition syntax, using a = to distinguish more cleary between identifier and value
- Variables initial values are evaluated on first use instead of at parsing time
- Error on variable redefinition. Means you should make sure to load saves after your scripts.
- Improve string parsing, support for escape codes
- Remove support for number literals with empty decimal part (42. for 42.0) as there's no distinction in Anselme and it conflicts with .function call suffix
- Changed priority of : pair operator
- Add type type, and type annotations to variables and function parameters
- Change Lua function system to use regular Anselme functions
  - Defining a function from Lua is now way simpler and require providing a full Anselme function signature
- Change Anselme function system
  - Dynamic dispatch, based on arity, type annotation and parameter names. Will select the most specific function at runtime.
  - Define way to overload most operators
  - Allow custom type to text formatters
  - Allow assignment to custom functions
  - Index operator ( renamed to ()
  - Functions with parameters each have their own private namespace (scoping ersatz)
  - Internal: "custom"-mode operators now have their own expression AST type instead of cluttering the function system
- Remove static type checker as it is barely useful with new function system. May or may not rewrite one in the future.
- Improve error messages here and there
- Internal: cleaning
This commit is contained in:
Étienne Fildadut 2021-06-03 15:29:25 +02:00
parent 4b139019c9
commit 64bc85741a
86 changed files with 2096 additions and 1012 deletions

View file

@ -88,6 +88,8 @@ if args.script then
elseif t == "choice" then
print(format_text(d, "\n> "))
istate:choose(io.read())
elseif t == "error" then
print(t, d)
else
print(t, inspect(d))
end
@ -110,51 +112,38 @@ else
vm:setaliases("seen", "checkpoint", "reached")
vm:loadfunction {
-- custom event test
["wait"] = {
{
arity = 1, types = { "number" },
value = function(duration)
coroutine.yield("wait", duration)
end
}
["wait(time::number)"] = {
value = function(duration)
coroutine.yield("wait", duration)
end
},
-- run another function in parallel
["run"] = {
{
arity = 1, types = { "string" },
value = function(str)
local istate, e = anselme.running.vm:run(str, anselme.running:current_namespace())
if not istate then coroutine.yield("error", e) end
local event, data = istate:step()
coroutine.yield(event, data)
end
}
["run(name::string)"] = {
value = function(str)
local istate, e = anselme.running.vm:run(str, anselme.running:current_namespace())
if not istate then coroutine.yield("error", e) end
local event, data = istate:step()
coroutine.yield(event, data)
end
},
-- manual choice
choose = {
{
arity = 1, types = { "number" },
value = function(c)
anselme.running:choose(c)
end
}
["choose(choice::number)"] = {
value = function(c)
anselme.running:choose(c)
end
},
-- manual interrupt
interrupt = {
{
arity = 1, types = { "string" },
value = function(str)
anselme.running:interrupt(str)
coroutine.yield("wait", 0)
end
},
{
arity = 0,
value = function()
anselme.running:interrupt()
coroutine.yield("wait", 0)
end
}
["interrupt(name::string)"] = {
value = function(str)
anselme.running:interrupt(str)
coroutine.yield("wait", 0)
end
},
["interrupt()"] = {
value = function()
anselme.running:interrupt()
coroutine.yield("wait", 0)
end
}
}
local state, err = vm:loadfile(file, namespace)

View file

@ -0,0 +1,11 @@
$ -(a, b)
@"generic minus"
$ -(a::string, b::string)
@a + " minus " + b
{2-5}
{"heh"-"lol"}
{[]-[]}

View file

@ -0,0 +1,30 @@
local _={}
_[13]={}
_[12]={}
_[11]={}
_[10]={data="generic minus",tags=_[13]}
_[9]={data="heh minus lol",tags=_[12]}
_[8]={data="-3",tags=_[11]}
_[7]={_[10]}
_[6]={_[9]}
_[5]={_[8]}
_[4]={"return"}
_[3]={"text",_[7]}
_[2]={"text",_[6]}
_[1]={"text",_[5]}
return {_[1],_[2],_[3],_[4]}
--[[
{ "text", { {
data = "-3",
tags = {}
} } }
{ "text", { {
data = "heh minus lol",
tags = {}
} } }
{ "text", { {
data = "generic minus",
tags = {}
} } }
{ "return" }
]]--

View file

@ -4,14 +4,14 @@ _[25]={k="v"}
_[24]={42,k="v"}
_[23]={}
_[22]={42}
_[21]={tags=_[26],data="f"}
_[20]={tags=_[25],data="e"}
_[19]={tags=_[24],data="b"}
_[18]={tags=_[25],data="d"}
_[17]={tags=_[24],data="a"}
_[16]={tags=_[22],data="b"}
_[15]={tags=_[23],data="c"}
_[14]={tags=_[22],data="a"}
_[21]={data="f",tags=_[26]}
_[20]={data="e",tags=_[25]}
_[19]={data="b",tags=_[24]}
_[18]={data="d",tags=_[25]}
_[17]={data="a",tags=_[24]}
_[16]={data="b",tags=_[22]}
_[15]={data="c",tags=_[23]}
_[14]={data="a",tags=_[22]}
_[13]={_[21]}
_[12]={_[20]}
_[11]={_[19]}

View file

@ -1,5 +1,5 @@
$ bar
:5 var
:var=5
~ var := 2

View file

@ -1,4 +1,4 @@
:5 a
:a = 5
~ a == 2
ko

View file

@ -1,4 +1,4 @@
:5 a
:a = 5
~ a == 5
ok

View file

@ -1,4 +1,4 @@
:5 a
:a = 5
~ a == 2
ko

View file

@ -1,4 +1,4 @@
:5 a
:a = 5
~ a == 2
ko

View file

@ -1,4 +1,4 @@
:5 a
:a = 5
~ a == 2
ko

View file

@ -1,4 +1,4 @@
:5 a
:a = 5
~ a == 5
ok

View file

@ -0,0 +1,11 @@
:person = "personne"
$ Person(name, age)
@[name=name, age=age]::person
:abject = Person("Darmanin", 38)
{abject}
$ format(p::person)
@"Name: {p("name")}\nAge: {p("age")}"

View file

@ -0,0 +1,14 @@
local _={}
_[5]={}
_[4]={data="Name: Darmanin\nAge: 38",tags=_[5]}
_[3]={_[4]}
_[2]={"return"}
_[1]={"text",_[3]}
return {_[1],_[2]}
--[[
{ "text", { {
data = "Name: Darmanin\nAge: 38",
tags = {}
} } }
{ "return" }
]]--

View file

@ -1,3 +1,3 @@
$ a
:2 a
:a = 2

View file

@ -1,6 +1,6 @@
local _={}
_[1]={"error","trying to define variable define override function.a, but a function with the same name exists; at test/tests/define override function.ans:3"}
_[1]={"error","trying to define variable \"define override function.a\", but a function with the same name exists; at test/tests/define override function.ans:3"}
return {_[1]}
--[[
{ "error", "trying to define variable define override function.a, but a function with the same name exists; at test/tests/define override function.ans:3" }
{ "error", 'trying to define variable "define override function.a", but a function with the same name exists; at test/tests/define override function.ans:3' }
]]--

View file

@ -1,3 +1,3 @@
:2 a
:a = 2
$ a

View file

@ -1,5 +1,5 @@
:5 a
:a = 5
:2 a
:a = 2
a: {a}

View file

@ -1,14 +1,6 @@
local _={}
_[5]={}
_[4]={data="a: 5",tags=_[5]}
_[3]={_[4]}
_[2]={"return"}
_[1]={"text",_[3]}
return {_[1],_[2]}
_[1]={"error","trying to define variable \"define override.a\" but it is already defined; at test/tests/define override.ans:3"}
return {_[1]}
--[[
{ "text", { {
data = "a: 5",
tags = {}
} } }
{ "return" }
{ "error", 'trying to define variable "define override.a" but it is already defined; at test/tests/define override.ans:3' }
]]--

View file

@ -1 +1 @@
:5 a
:a = 5

View file

@ -1,12 +1,12 @@
:(1:2) a
:a = [1:2]
0 = {a == (5:2)}
0 = {a == [5:2]}
0 = {a == (1:3)}
0 = {a == [1:3]}
1 = {a == (1:2)}
1 = {a == [1:2]}
:[1,2,3] b
:b = [1,2,3]
0 = {b == a}

View file

@ -1,6 +0,0 @@
local _={}
_[1]={"error","trying to define function function arity conflict.f with arity [2;2], but another function with the same name and arity exist; at test/tests/function arity conflict.ans:5"}
return {_[1]}
--[[
{ "error", "trying to define function function arity conflict.f with arity [2;2], but another function with the same name and arity exist; at test/tests/function arity conflict.ans:5" }
]]--

View file

@ -0,0 +1,22 @@
:a = 5
$ f(p)
@a
$ f(p) := v
v={v}
~ a := v
$ f(p) := v::string
v2={v}
~ a := p
{f(a)}
~ f(3) := 50
{f(a)}
~ f(3) := "ok"
{f(a)}

View file

@ -0,0 +1,46 @@
local _={}
_[21]={}
_[20]={}
_[19]={}
_[18]={}
_[17]={}
_[16]={data="3",tags=_[21]}
_[15]={data="v2=ok",tags=_[20]}
_[14]={data="50",tags=_[19]}
_[13]={data="v=50",tags=_[18]}
_[12]={data="5",tags=_[17]}
_[11]={_[16]}
_[10]={_[15]}
_[9]={_[14]}
_[8]={_[13]}
_[7]={_[12]}
_[6]={"return"}
_[5]={"text",_[11]}
_[4]={"text",_[10]}
_[3]={"text",_[9]}
_[2]={"text",_[8]}
_[1]={"text",_[7]}
return {_[1],_[2],_[3],_[4],_[5],_[6]}
--[[
{ "text", { {
data = "5",
tags = {}
} } }
{ "text", { {
data = "v=50",
tags = {}
} } }
{ "text", { {
data = "50",
tags = {}
} } }
{ "text", { {
data = "v2=ok",
tags = {}
} } }
{ "text", { {
data = "3",
tags = {}
} } }
{ "return" }
]]--

View file

@ -2,4 +2,4 @@ $ f(a, b)
$ f(x)
$ f(u, v)
$ f(a, b)

View file

@ -0,0 +1,6 @@
local _={}
_[1]={"error","trying to define function function conflict.f(a, b) (at test/tests/function conflict.ans:5), but another function with same signature function conflict.f(a, b) (at test/tests/function conflict.ans:1) exists; at test/tests/function conflict.ans:5"}
return {_[1]}
--[[
{ "error", "trying to define function function conflict.f(a, b) (at test/tests/function conflict.ans:5), but another function with same signature function conflict.f(a, b) (at test/tests/function conflict.ans:1) exists; at test/tests/function conflict.ans:5" }
]]--

View file

@ -0,0 +1,17 @@
:name="name"::string
:french name="french"::name
:esperanto name="esperanto"::name
$ a(name::string)
{name} is english or generic
$ a(name:nom::french name)
{nom} is french
~ a("bob"::name)
~ a("pierre"::french name)
~ a("idk"::esperanto name)
~ a(5)

View file

@ -0,0 +1,30 @@
local _={}
_[13]={}
_[12]={}
_[11]={}
_[10]={data="idk::esperanto::name::string is english or generic",tags=_[13]}
_[9]={data="pierre::french::name::string is french",tags=_[12]}
_[8]={data="bob::name::string is english or generic",tags=_[11]}
_[7]={_[10]}
_[6]={_[9]}
_[5]={_[8]}
_[4]={"error","no compatible function found for call to a(number); potential candidates were:\n\9function custom type dispatch error.a(name::string) (at test/tests/function custom type dispatch error.ans:5): argument name is not of expected type string\n\9function custom type dispatch error.a(name:nom::french name) (at test/tests/function custom type dispatch error.ans:8): argument name is not of expected type french::name::string; at test/tests/function custom type dispatch error.ans:17"}
_[3]={"text",_[7]}
_[2]={"text",_[6]}
_[1]={"text",_[5]}
return {_[1],_[2],_[3],_[4]}
--[[
{ "text", { {
data = "bob::name::string is english or generic",
tags = {}
} } }
{ "text", { {
data = "pierre::french::name::string is french",
tags = {}
} } }
{ "text", { {
data = "idk::esperanto::name::string is english or generic",
tags = {}
} } }
{ "error", "no compatible function found for call to a(number); potential candidates were:\n\tfunction custom type dispatch error.a(name::string) (at test/tests/function custom type dispatch error.ans:5): argument name is not of expected type string\n\tfunction custom type dispatch error.a(name:nom::french name) (at test/tests/function custom type dispatch error.ans:8): argument name is not of expected type french::name::string; at test/tests/function custom type dispatch error.ans:17" }
]]--

View file

@ -0,0 +1,15 @@
:name="name"::string
:french name="french"::name
:esperanto name="esperanto"::name
$ a(name)
{name} is english or generic
$ a(name:nom::french name)
{nom} is french
~ a("bob"::name)
~ a("pierre"::french name)
~ a("idk"::esperanto name)

View file

@ -0,0 +1,30 @@
local _={}
_[13]={}
_[12]={}
_[11]={}
_[10]={data="idk::esperanto::name::string is english or generic",tags=_[13]}
_[9]={data="pierre::french::name::string is french",tags=_[12]}
_[8]={data="bob::name::string is english or generic",tags=_[11]}
_[7]={_[10]}
_[6]={_[9]}
_[5]={_[8]}
_[4]={"return"}
_[3]={"text",_[7]}
_[2]={"text",_[6]}
_[1]={"text",_[5]}
return {_[1],_[2],_[3],_[4]}
--[[
{ "text", { {
data = "bob::name::string is english or generic",
tags = {}
} } }
{ "text", { {
data = "pierre::french::name::string is french",
tags = {}
} } }
{ "text", { {
data = "idk::esperanto::name::string is english or generic",
tags = {}
} } }
{ "return" }
]]--

View file

@ -1,6 +1,6 @@
local _={}
_[5]={}
_[4]={tags=_[5],data="a.\240\159\145\129\239\184\143: 0"}
_[4]={data="a.\240\159\145\129\239\184\143: 0",tags=_[5]}
_[3]={_[4]}
_[2]={"return"}
_[1]={"text",_[3]}

View file

@ -0,0 +1,9 @@
$ fn(x)
x
$ fn(a)
a
~ fn(a=5)
~ fn(x=5)

View file

@ -0,0 +1,22 @@
local _={}
_[9]={}
_[8]={}
_[7]={data="x",tags=_[9]}
_[6]={data="a",tags=_[8]}
_[5]={_[7]}
_[4]={_[6]}
_[3]={"return"}
_[2]={"text",_[5]}
_[1]={"text",_[4]}
return {_[1],_[2],_[3]}
--[[
{ "text", { {
data = "a",
tags = {}
} } }
{ "text", { {
data = "x",
tags = {}
} } }
{ "return" }
]]--

View file

@ -0,0 +1,5 @@
$ f(a, b)
$ f(x)
$ f(u, v)

View file

@ -0,0 +1,6 @@
local _={}
_[1]={"return"}
return {_[1]}
--[[
{ "return" }
]]--

View file

@ -1,4 +1,4 @@
$ a
:5 b
:b = 5
a: {b}

View file

@ -1,6 +1,6 @@
local _={}
_[1]={"error","unknown identifier \"b\"; at test/tests/function scope wrong.ans:4"}
_[1]={"error","compatible function \"b\" variant not found; at test/tests/function scope wrong.ans:4"}
return {_[1]}
--[[
{ "error", 'unknown identifier "b"; at test/tests/function scope wrong.ans:4' }
{ "error", 'compatible function "b" variant not found; at test/tests/function scope wrong.ans:4' }
]]--

View file

@ -1,4 +1,4 @@
$ a
:5 b
:b = 5
a: {a.b}

View file

@ -0,0 +1,12 @@
$ a(x::number)
@x + 2
$ x
$ a(x::string)
@x + "heh"
{a("plop")}
{a(2)}
~ x

View file

@ -0,0 +1,22 @@
local _={}
_[9]={}
_[8]={}
_[7]={data="4",tags=_[9]}
_[6]={data="plopheh",tags=_[8]}
_[5]={_[7]}
_[4]={_[6]}
_[3]={"return"}
_[2]={"text",_[5]}
_[1]={"text",_[4]}
return {_[1],_[2],_[3]}
--[[
{ "text", { {
data = "plopheh",
tags = {}
} } }
{ "text", { {
data = "4",
tags = {}
} } }
{ "return" }
]]--

View file

@ -0,0 +1,10 @@
$ f
:a = 2
$ f(x)
:a = 5
$ f(b)
:a = 10
{f.a} = 2

View file

@ -0,0 +1,14 @@
local _={}
_[5]={}
_[4]={data="2 = 2",tags=_[5]}
_[3]={_[4]}
_[2]={"return"}
_[1]={"text",_[3]}
return {_[1],_[2]}
--[[
{ "text", { {
data = "2 = 2",
tags = {}
} } }
{ "return" }
]]--

View file

@ -0,0 +1,7 @@
$ fn(x::number)
x
$ fn(a::number)
a
~ fn(5)

View file

@ -0,0 +1,6 @@
local _={}
_[1]={"error","function call \"fn\" is ambigous; may be at least either:\n\9function type dispatch ambigous.fn(a::number) (at test/tests/function type dispatch ambigous.ans:4)\n\9function type dispatch ambigous.fn(x::number) (at test/tests/function type dispatch ambigous.ans:1); at test/tests/function type dispatch ambigous.ans:7"}
return {_[1]}
--[[
{ "error", 'function call "fn" is ambigous; may be at least either:\n\tfunction type dispatch ambigous.fn(a::number) (at test/tests/function type dispatch ambigous.ans:4)\n\tfunction type dispatch ambigous.fn(x::number) (at test/tests/function type dispatch ambigous.ans:1); at test/tests/function type dispatch ambigous.ans:7' }
]]--

View file

@ -0,0 +1,26 @@
$ fn(x::number)
x
$ fn(a="o"::string)
a
~ fn("s")
~ fn(5)
~ fn()
$ g(n="s", a=5::number)
@"gn"
$ g(n="s", a="lol"::string)
@"gs"
{g(n="k", a="l")}
{g(n="k", a=1)}
{g(n="k", "l")}
{g(n="k", 1)}
{g("k", "l")}
{g("k", 1)}
{g("k", a="l")}
{g("k", a=1)}

View file

@ -0,0 +1,73 @@
local _={}
_[31]={}
_[30]={}
_[29]={}
_[28]={}
_[27]={}
_[26]={}
_[25]={}
_[24]={}
_[23]={}
_[22]={}
_[21]={}
_[20]={data="gn",tags=_[31]}
_[19]={data="gs",tags=_[30]}
_[18]={data="gn",tags=_[29]}
_[17]={data="gs",tags=_[28]}
_[16]={data="gn",tags=_[27]}
_[15]={data="gs",tags=_[26]}
_[14]={data="gn",tags=_[25]}
_[13]={data="gs",tags=_[24]}
_[12]={data="a",tags=_[23]}
_[11]={data="x",tags=_[22]}
_[10]={data="a",tags=_[21]}
_[9]={_[13],_[14],_[15],_[16],_[17],_[18],_[19],_[20]}
_[8]={_[12]}
_[7]={_[11]}
_[6]={_[10]}
_[5]={"return"}
_[4]={"text",_[9]}
_[3]={"text",_[8]}
_[2]={"text",_[7]}
_[1]={"text",_[6]}
return {_[1],_[2],_[3],_[4],_[5]}
--[[
{ "text", { {
data = "a",
tags = {}
} } }
{ "text", { {
data = "x",
tags = {}
} } }
{ "text", { {
data = "a",
tags = {}
} } }
{ "text", { {
data = "gs",
tags = {}
}, {
data = "gn",
tags = {}
}, {
data = "gs",
tags = {}
}, {
data = "gn",
tags = {}
}, {
data = "gs",
tags = {}
}, {
data = "gn",
tags = {}
}, {
data = "gs",
tags = {}
}, {
data = "gn",
tags = {}
} } }
{ "return" }
]]--

View file

@ -0,0 +1,9 @@
$ fn(x::number)
x
$ fn(a::string)
a
~ fn("s")
~ fn(5)

View file

@ -0,0 +1,22 @@
local _={}
_[9]={}
_[8]={}
_[7]={data="x",tags=_[9]}
_[6]={data="a",tags=_[8]}
_[5]={_[7]}
_[4]={_[6]}
_[3]={"return"}
_[2]={"text",_[5]}
_[1]={"text",_[4]}
return {_[1],_[2],_[3]}
--[[
{ "text", { {
data = "a",
tags = {}
} } }
{ "text", { {
data = "x",
tags = {}
} } }
{ "return" }
]]--

View file

@ -3,7 +3,7 @@ $ oh
in interrupt: {bar.var}
no
$ bar
:5 var
:var = 5
~ var := 2

View file

@ -4,7 +4,7 @@ $ leave
$ oh
no
$ bar
:5 var
:var = 5
~ var := 2

View file

@ -1,5 +1,5 @@
$ bar
:5 var
:var = 5
~ var := 2

View file

@ -1,5 +1,5 @@
$ bar
:5 var
:var = 5
~ var := 2

View file

@ -0,0 +1,23 @@
$ a
a
@1
$ b
b
@0
{a & b} = a b 0
{b & a} = b 0
{a & a} = a a 1
{b & b} = b 0
{a | b} = a 1
{b | a} = b a 1
{a | a} = a 1
{b | b} = b b 0

View file

@ -0,0 +1,130 @@
local _={}
_[57]={}
_[56]={}
_[55]={}
_[54]={}
_[53]={}
_[52]={}
_[51]={}
_[50]={}
_[49]={}
_[48]={}
_[47]={}
_[46]={}
_[45]={}
_[44]={}
_[43]={}
_[42]={}
_[41]={}
_[40]={}
_[39]={}
_[38]={}
_[37]={data="0 = b b 0",tags=_[57]}
_[36]={data="b",tags=_[56]}
_[35]={data="b",tags=_[55]}
_[34]={data="1 = a 1",tags=_[54]}
_[33]={data="a",tags=_[53]}
_[32]={data="1 = b a 1",tags=_[52]}
_[31]={data="a",tags=_[51]}
_[30]={data="b",tags=_[50]}
_[29]={data="1 = a 1",tags=_[49]}
_[28]={data="a",tags=_[48]}
_[27]={data="0 = b 0",tags=_[47]}
_[26]={data="b",tags=_[46]}
_[25]={data="1 = a a 1",tags=_[45]}
_[24]={data="a",tags=_[44]}
_[23]={data="a",tags=_[43]}
_[22]={data="0 = b 0",tags=_[42]}
_[21]={data="b",tags=_[41]}
_[20]={data="0 = a b 0",tags=_[40]}
_[19]={data="b",tags=_[39]}
_[18]={data="a",tags=_[38]}
_[17]={_[35],_[36],_[37]}
_[16]={_[33],_[34]}
_[15]={_[30],_[31],_[32]}
_[14]={_[28],_[29]}
_[13]={_[26],_[27]}
_[12]={_[23],_[24],_[25]}
_[11]={_[21],_[22]}
_[10]={_[18],_[19],_[20]}
_[9]={"return"}
_[8]={"text",_[17]}
_[7]={"text",_[16]}
_[6]={"text",_[15]}
_[5]={"text",_[14]}
_[4]={"text",_[13]}
_[3]={"text",_[12]}
_[2]={"text",_[11]}
_[1]={"text",_[10]}
return {_[1],_[2],_[3],_[4],_[5],_[6],_[7],_[8],_[9]}
--[[
{ "text", { {
data = "a",
tags = {}
}, {
data = "b",
tags = {}
}, {
data = "0 = a b 0",
tags = {}
} } }
{ "text", { {
data = "b",
tags = {}
}, {
data = "0 = b 0",
tags = {}
} } }
{ "text", { {
data = "a",
tags = {}
}, {
data = "a",
tags = {}
}, {
data = "1 = a a 1",
tags = {}
} } }
{ "text", { {
data = "b",
tags = {}
}, {
data = "0 = b 0",
tags = {}
} } }
{ "text", { {
data = "a",
tags = {}
}, {
data = "1 = a 1",
tags = {}
} } }
{ "text", { {
data = "b",
tags = {}
}, {
data = "a",
tags = {}
}, {
data = "1 = b a 1",
tags = {}
} } }
{ "text", { {
data = "a",
tags = {}
}, {
data = "1 = a 1",
tags = {}
} } }
{ "text", { {
data = "b",
tags = {}
}, {
data = "b",
tags = {}
}, {
data = "0 = b b 0",
tags = {}
} } }
{ "return" }
]]--

View file

@ -1,4 +1,4 @@
:[1,2] x
:x = [1,2]
{x}

View file

@ -1,6 +1,6 @@
local _={}
_[5]={}
_[4]={tags=_[5],data="abc = abc = abc"}
_[4]={data="abc = abc = abc",tags=_[5]}
_[3]={_[4]}
_[2]={"return"}
_[1]={"text",_[3]}

View file

@ -1,6 +1,6 @@
$ f(l...)
~ l.len
:0 a
:a = 0
~ a := l(1)
~ l.remove(1)
@a + f(l=l)

View file

@ -1,6 +1,6 @@
local _={}
_[5]={}
_[4]={tags=_[5],data="15"}
_[4]={data="15",tags=_[5]}
_[3]={_[4]}
_[2]={"return"}
_[1]={"text",_[3]}

View file

@ -1,6 +1,6 @@
local _={}
_[5]={}
_[4]={tags=_[5],data="abc = abc = abc"}
_[4]={data="abc = abc = abc",tags=_[5]}
_[3]={_[4]}
_[2]={"return"}
_[1]={"text",_[3]}

View file

@ -1,6 +1,6 @@
local _={}
_[5]={}
_[4]={tags=_[5],data="ok = ok"}
_[4]={data="ok = ok",tags=_[5]}
_[3]={_[4]}
_[2]={"return"}
_[1]={"text",_[3]}

View file

@ -17,24 +17,24 @@ _[49]={}
_[48]={}
_[47]={}
_[46]={}
_[45]={tags=_[63],data="c"}
_[44]={tags=_[62],data="a"}
_[43]={tags=_[61],data="Force p checkpoint:"}
_[42]={tags=_[60],data="d"}
_[41]={tags=_[59],data="c"}
_[40]={tags=_[58],data="b"}
_[39]={tags=_[57],data="From q checkpoint again:"}
_[38]={tags=_[56],data="d"}
_[37]={tags=_[55],data="c"}
_[36]={tags=_[54],data="b"}
_[35]={tags=_[53],data="From q checkpoint:"}
_[34]={tags=_[52],data="d"}
_[33]={tags=_[51],data="c"}
_[32]={tags=_[50],data="a"}
_[31]={tags=_[49],data="From p checkpoint:"}
_[30]={tags=_[48],data="d"}
_[29]={tags=_[47],data="x"}
_[28]={tags=_[46],data="From start:"}
_[45]={data="c",tags=_[63]}
_[44]={data="a",tags=_[62]}
_[43]={data="Force p checkpoint:",tags=_[61]}
_[42]={data="d",tags=_[60]}
_[41]={data="c",tags=_[59]}
_[40]={data="b",tags=_[58]}
_[39]={data="From q checkpoint again:",tags=_[57]}
_[38]={data="d",tags=_[56]}
_[37]={data="c",tags=_[55]}
_[36]={data="b",tags=_[54]}
_[35]={data="From q checkpoint:",tags=_[53]}
_[34]={data="d",tags=_[52]}
_[33]={data="c",tags=_[51]}
_[32]={data="a",tags=_[50]}
_[31]={data="From p checkpoint:",tags=_[49]}
_[30]={data="d",tags=_[48]}
_[29]={data="x",tags=_[47]}
_[28]={data="From start:",tags=_[46]}
_[27]={_[45]}
_[26]={_[43],_[44]}
_[25]={_[42]}

View file

@ -2,18 +2,18 @@ local _={}
_[32]={}
_[31]={a="a"}
_[30]={a="a",b="b"}
_[29]={a="a",c="c",b="b"}
_[29]={a="a",b="b",c="c"}
_[28]={}
_[27]={a="a",b="b"}
_[26]={a="a"}
_[25]={tags=_[32],data="e"}
_[24]={tags=_[31],data="d"}
_[23]={tags=_[30],data="c"}
_[22]={tags=_[29],data="b"}
_[21]={tags=_[28],data="e"}
_[20]={tags=_[26],data="d"}
_[19]={tags=_[27],data="c"}
_[18]={tags=_[26],data="a"}
_[25]={data="e",tags=_[32]}
_[24]={data="d",tags=_[31]}
_[23]={data="c",tags=_[30]}
_[22]={data="b",tags=_[29]}
_[21]={data="e",tags=_[28]}
_[20]={data="d",tags=_[26]}
_[19]={data="c",tags=_[27]}
_[18]={data="a",tags=_[26]}
_[17]={_[25]}
_[16]={_[24]}
_[15]={_[23]}

View file

@ -1,7 +1,4 @@
local _={}
_[121]={}
_[120]={}
_[119]={}
_[118]={}
_[117]={}
_[116]={}
@ -34,15 +31,15 @@ _[90]={}
_[89]={}
_[88]={}
_[87]={}
_[86]={data="c",tags=_[121]}
_[85]={data="b",tags=_[120]}
_[84]={data="a",tags=_[119]}
_[83]={data="-> aa",tags=_[118]}
_[82]={data="ab",tags=_[117]}
_[81]={data="aa",tags=_[116]}
_[80]={data="-> aa",tags=_[115]}
_[79]={data="ab",tags=_[114]}
_[78]={data="aa",tags=_[113]}
_[86]={data="c",tags=_[118]}
_[85]={data="b",tags=_[117]}
_[84]={data="a",tags=_[116]}
_[83]={data="-> aa",tags=_[115]}
_[82]={data="ab",tags=_[114]}
_[81]={data="aa",tags=_[113]}
_[80]={data="-> aa",tags=_[112]}
_[79]={data="ab",tags=_[112]}
_[78]={data="aa",tags=_[112]}
_[77]={data="-> a",tags=_[112]}
_[76]={data="c",tags=_[111]}
_[75]={data="b",tags=_[110]}
@ -222,10 +219,10 @@ return {_[1],_[2],_[3],_[4],_[5],_[6],_[7],_[8],_[9],_[10],_[11],_[12],_[13],_[1
} } }
{ "choice", { {
data = "aa",
tags = {}
tags = <1>{}
}, {
data = "ab",
tags = {}
tags = <table 1>
} } }
{ "text", { {
data = "-> aa",

View file

@ -0,0 +1,7 @@
expression {"{"a"}"}
quote {"\""}
other codes {"\n"} {"\\"} {"\t"}
{"escaping expressions {"a"+"bc"} and stuff \\ and quotes \""}

View file

@ -0,0 +1,38 @@
local _={}
_[17]={}
_[16]={}
_[15]={}
_[14]={}
_[13]={data="escaping expressions abc and stuff \\ and quotes \"",tags=_[17]}
_[12]={data="other codes \n \\ \9",tags=_[16]}
_[11]={data="quote \"",tags=_[15]}
_[10]={data="expression a",tags=_[14]}
_[9]={_[13]}
_[8]={_[12]}
_[7]={_[11]}
_[6]={_[10]}
_[5]={"return"}
_[4]={"text",_[9]}
_[3]={"text",_[8]}
_[2]={"text",_[7]}
_[1]={"text",_[6]}
return {_[1],_[2],_[3],_[4],_[5]}
--[[
{ "text", { {
data = "expression a",
tags = {}
} } }
{ "text", { {
data = 'quote "',
tags = {}
} } }
{ "text", { {
data = "other codes \n \\ \t",
tags = {}
} } }
{ "text", { {
data = 'escaping expressions abc and stuff \\ and quotes "',
tags = {}
} } }
{ "return" }
]]--

View file

@ -1,6 +1,7 @@
local _={}
_[7]={1}
_[6]={1}
_[5]={data="bar",tags=_[6]}
_[5]={data="bar",tags=_[7]}
_[4]={data="foo",tags=_[6]}
_[3]={_[4],_[5]}
_[2]={"return"}
@ -9,10 +10,10 @@ return {_[1],_[2]}
--[[
{ "text", { {
data = "foo",
tags = <1>{ 1 }
tags = { 1 }
}, {
data = "bar",
tags = <table 1>
tags = { 1 }
} } }
{ "return" }
]]--

View file

@ -1,6 +1,7 @@
local _={}
_[7]={1}
_[6]={1}
_[5]={data="bar",tags=_[6]}
_[5]={data="bar",tags=_[7]}
_[4]={data="foo",tags=_[6]}
_[3]={_[4],_[5]}
_[2]={"return"}
@ -9,10 +10,10 @@ return {_[1],_[2]}
--[[
{ "text", { {
data = "foo",
tags = <1>{ 1 }
tags = { 1 }
}, {
data = "bar",
tags = <table 1>
tags = { 1 }
} } }
{ "return" }
]]--

View file

@ -1,3 +1,3 @@
:5 a
:a = 5
a: {a}

View file

@ -0,0 +1,11 @@
$ -(f)
@"generic minus"
$ -(f::string)
@"minus "+f
{-5}
{-"lol"}
{-[]}

View file

@ -0,0 +1,30 @@
local _={}
_[13]={}
_[12]={}
_[11]={}
_[10]={data="generic minus",tags=_[13]}
_[9]={data="minus lol",tags=_[12]}
_[8]={data="-5",tags=_[11]}
_[7]={_[10]}
_[6]={_[9]}
_[5]={_[8]}
_[4]={"return"}
_[3]={"text",_[7]}
_[2]={"text",_[6]}
_[1]={"text",_[5]}
return {_[1],_[2],_[3],_[4]}
--[[
{ "text", { {
data = "-5",
tags = {}
} } }
{ "text", { {
data = "minus lol",
tags = {}
} } }
{ "text", { {
data = "generic minus",
tags = {}
} } }
{ "return" }
]]--

View file

@ -1,3 +1,3 @@
:42 a : b
:a : b = 42
{a} = {b}