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:
parent
4b139019c9
commit
64bc85741a
86 changed files with 2096 additions and 1012 deletions
67
test/run.lua
67
test/run.lua
|
|
@ -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)
|
||||
|
|
|
|||
11
test/tests/binary operator overload.ans
Normal file
11
test/tests/binary operator overload.ans
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
$ -(a, b)
|
||||
@"generic minus"
|
||||
|
||||
$ -(a::string, b::string)
|
||||
@a + " minus " + b
|
||||
|
||||
{2-5}
|
||||
|
||||
{"heh"-"lol"}
|
||||
|
||||
{[]-[]}
|
||||
30
test/tests/binary operator overload.lua
Normal file
30
test/tests/binary operator overload.lua
Normal 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" }
|
||||
]]--
|
||||
|
|
@ -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]}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
$ bar
|
||||
:5 var
|
||||
:var=5
|
||||
|
||||
~ var := 2
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
:5 a
|
||||
:a = 5
|
||||
|
||||
~ a == 2
|
||||
ko
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
:5 a
|
||||
:a = 5
|
||||
|
||||
~ a == 5
|
||||
ok
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
:5 a
|
||||
:a = 5
|
||||
|
||||
~ a == 2
|
||||
ko
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
:5 a
|
||||
:a = 5
|
||||
|
||||
~ a == 2
|
||||
ko
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
:5 a
|
||||
:a = 5
|
||||
|
||||
~ a == 2
|
||||
ko
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
:5 a
|
||||
:a = 5
|
||||
|
||||
~ a == 5
|
||||
ok
|
||||
|
|
|
|||
11
test/tests/custom text formatting.ans
Normal file
11
test/tests/custom text formatting.ans
Normal 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")}"
|
||||
14
test/tests/custom text formatting.lua
Normal file
14
test/tests/custom text formatting.lua
Normal 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" }
|
||||
]]--
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
$ a
|
||||
|
||||
:2 a
|
||||
:a = 2
|
||||
|
|
|
|||
|
|
@ -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' }
|
||||
]]--
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
:2 a
|
||||
:a = 2
|
||||
|
||||
$ a
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
:5 a
|
||||
:a = 5
|
||||
|
||||
:2 a
|
||||
:a = 2
|
||||
|
||||
a: {a}
|
||||
|
|
|
|||
|
|
@ -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' }
|
||||
]]--
|
||||
|
|
@ -1 +1 @@
|
|||
:5 a
|
||||
:a = 5
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
||||
|
|
|
|||
|
|
@ -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" }
|
||||
]]--
|
||||
22
test/tests/function assignement.ans
Normal file
22
test/tests/function assignement.ans
Normal 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)}
|
||||
46
test/tests/function assignement.lua
Normal file
46
test/tests/function assignement.lua
Normal 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" }
|
||||
]]--
|
||||
|
|
@ -2,4 +2,4 @@ $ f(a, b)
|
|||
|
||||
$ f(x)
|
||||
|
||||
$ f(u, v)
|
||||
$ f(a, b)
|
||||
6
test/tests/function conflict.lua
Normal file
6
test/tests/function conflict.lua
Normal 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" }
|
||||
]]--
|
||||
17
test/tests/function custom type dispatch error.ans
Normal file
17
test/tests/function custom type dispatch error.ans
Normal 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)
|
||||
30
test/tests/function custom type dispatch error.lua
Normal file
30
test/tests/function custom type dispatch error.lua
Normal 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" }
|
||||
]]--
|
||||
15
test/tests/function custom type dispatch.ans
Normal file
15
test/tests/function custom type dispatch.ans
Normal 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)
|
||||
30
test/tests/function custom type dispatch.lua
Normal file
30
test/tests/function custom type dispatch.lua
Normal 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" }
|
||||
]]--
|
||||
|
|
@ -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]}
|
||||
|
|
|
|||
9
test/tests/function name dispatch.ans
Normal file
9
test/tests/function name dispatch.ans
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
$ fn(x)
|
||||
x
|
||||
|
||||
$ fn(a)
|
||||
a
|
||||
|
||||
~ fn(a=5)
|
||||
|
||||
~ fn(x=5)
|
||||
22
test/tests/function name dispatch.lua
Normal file
22
test/tests/function name dispatch.lua
Normal 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" }
|
||||
]]--
|
||||
5
test/tests/function no conflict.ans
Normal file
5
test/tests/function no conflict.ans
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
$ f(a, b)
|
||||
|
||||
$ f(x)
|
||||
|
||||
$ f(u, v)
|
||||
6
test/tests/function no conflict.lua
Normal file
6
test/tests/function no conflict.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
local _={}
|
||||
_[1]={"return"}
|
||||
return {_[1]}
|
||||
--[[
|
||||
{ "return" }
|
||||
]]--
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
$ a
|
||||
:5 b
|
||||
:b = 5
|
||||
|
||||
a: {b}
|
||||
|
|
|
|||
|
|
@ -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' }
|
||||
]]--
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
$ a
|
||||
:5 b
|
||||
:b = 5
|
||||
|
||||
a: {a.b}
|
||||
|
|
|
|||
12
test/tests/function selection.ans
Normal file
12
test/tests/function selection.ans
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
$ a(x::number)
|
||||
@x + 2
|
||||
|
||||
$ x
|
||||
$ a(x::string)
|
||||
@x + "heh"
|
||||
|
||||
{a("plop")}
|
||||
|
||||
{a(2)}
|
||||
|
||||
~ x
|
||||
22
test/tests/function selection.lua
Normal file
22
test/tests/function selection.lua
Normal 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" }
|
||||
]]--
|
||||
10
test/tests/function separate variable from variants.ans
Normal file
10
test/tests/function separate variable from variants.ans
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
$ f
|
||||
:a = 2
|
||||
|
||||
$ f(x)
|
||||
:a = 5
|
||||
|
||||
$ f(b)
|
||||
:a = 10
|
||||
|
||||
{f.a} = 2
|
||||
14
test/tests/function separate variable from variants.lua
Normal file
14
test/tests/function separate variable from variants.lua
Normal 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" }
|
||||
]]--
|
||||
7
test/tests/function type dispatch ambigous.ans
Normal file
7
test/tests/function type dispatch ambigous.ans
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
$ fn(x::number)
|
||||
x
|
||||
|
||||
$ fn(a::number)
|
||||
a
|
||||
|
||||
~ fn(5)
|
||||
6
test/tests/function type dispatch ambigous.lua
Normal file
6
test/tests/function type dispatch ambigous.lua
Normal 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' }
|
||||
]]--
|
||||
26
test/tests/function type dispatch with default.ans
Normal file
26
test/tests/function type dispatch with default.ans
Normal 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)}
|
||||
73
test/tests/function type dispatch with default.lua
Normal file
73
test/tests/function type dispatch with default.lua
Normal 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" }
|
||||
]]--
|
||||
9
test/tests/function type dispatch.ans
Normal file
9
test/tests/function type dispatch.ans
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
$ fn(x::number)
|
||||
x
|
||||
|
||||
$ fn(a::string)
|
||||
a
|
||||
|
||||
~ fn("s")
|
||||
|
||||
~ fn(5)
|
||||
22
test/tests/function type dispatch.lua
Normal file
22
test/tests/function type dispatch.lua
Normal 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" }
|
||||
]]--
|
||||
|
|
@ -3,7 +3,7 @@ $ oh
|
|||
in interrupt: {bar.var}
|
||||
no
|
||||
$ bar
|
||||
:5 var
|
||||
:var = 5
|
||||
|
||||
~ var := 2
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ $ leave
|
|||
$ oh
|
||||
no
|
||||
$ bar
|
||||
:5 var
|
||||
:var = 5
|
||||
|
||||
~ var := 2
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
$ bar
|
||||
:5 var
|
||||
:var = 5
|
||||
|
||||
~ var := 2
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
$ bar
|
||||
:5 var
|
||||
:var = 5
|
||||
|
||||
~ var := 2
|
||||
|
||||
|
|
|
|||
23
test/tests/lazy boolean operators.ans
Normal file
23
test/tests/lazy boolean operators.ans
Normal 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
|
||||
130
test/tests/lazy boolean operators.lua
Normal file
130
test/tests/lazy boolean operators.lua
Normal 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" }
|
||||
]]--
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
:[1,2] x
|
||||
:x = [1,2]
|
||||
|
||||
{x}
|
||||
|
||||
|
|
|
|||
|
|
@ -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]}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
$ f(l...)
|
||||
~ l.len
|
||||
:0 a
|
||||
:a = 0
|
||||
~ a := l(1)
|
||||
~ l.remove(1)
|
||||
@a + f(l=l)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={tags=_[5],data="15"}
|
||||
_[4]={data="15",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -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]}
|
||||
|
|
|
|||
|
|
@ -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]}
|
||||
|
|
|
|||
|
|
@ -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]}
|
||||
|
|
|
|||
|
|
@ -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]}
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
7
test/tests/string escaping.ans
Normal file
7
test/tests/string escaping.ans
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
expression {"{"a"}"}
|
||||
|
||||
quote {"\""}
|
||||
|
||||
other codes {"\n"} {"\\"} {"\t"}
|
||||
|
||||
{"escaping expressions {"a"+"bc"} and stuff \\ and quotes \""}
|
||||
38
test/tests/string escaping.lua
Normal file
38
test/tests/string escaping.lua
Normal 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" }
|
||||
]]--
|
||||
|
|
@ -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" }
|
||||
]]--
|
||||
|
|
@ -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" }
|
||||
]]--
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
:5 a
|
||||
:a = 5
|
||||
|
||||
a: {a}
|
||||
|
|
|
|||
11
test/tests/unary operator overload.ans
Normal file
11
test/tests/unary operator overload.ans
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
$ -(f)
|
||||
@"generic minus"
|
||||
|
||||
$ -(f::string)
|
||||
@"minus "+f
|
||||
|
||||
{-5}
|
||||
|
||||
{-"lol"}
|
||||
|
||||
{-[]}
|
||||
30
test/tests/unary operator overload.lua
Normal file
30
test/tests/unary operator overload.lua
Normal 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" }
|
||||
]]--
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
:42 a : b
|
||||
:a : b = 42
|
||||
|
||||
{a} = {b}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue