mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-28 00:59:31 +00:00
Add maps; remove map emulation functionality from list; function and tags now internally use maps instead of lists
This commit is contained in:
parent
bac5cdde01
commit
95462391e3
20 changed files with 699 additions and 139 deletions
|
|
@ -1,7 +1,7 @@
|
|||
:person = "personne"
|
||||
|
||||
$ Person(name, age)
|
||||
@[name=name, age=age]::person
|
||||
@{name=name, age=age}::person
|
||||
|
||||
:abject = Person("Darmanin", 38)
|
||||
|
||||
|
|
|
|||
|
|
@ -6,15 +6,16 @@
|
|||
|
||||
{x}
|
||||
|
||||
{x("foo") := "a"}
|
||||
{x(2) := 5}
|
||||
|
||||
{x}
|
||||
|
||||
{x("bar") := "b"}
|
||||
{x(-1) := 12}
|
||||
|
||||
{x}
|
||||
|
||||
{x("foo") := "c"}
|
||||
{x(3) := 99}
|
||||
|
||||
{x}
|
||||
|
||||
{x(5) := 0}
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ _[32]={}
|
|||
_[31]={}
|
||||
_[30]={}
|
||||
_[29]={}
|
||||
_[28]={tags=_[37],text="[3, 2, foo=c, bar=b]"}
|
||||
_[27]={tags=_[36],text="c"}
|
||||
_[26]={tags=_[35],text="[3, 2, foo=a, bar=b]"}
|
||||
_[25]={tags=_[34],text="b"}
|
||||
_[24]={tags=_[33],text="[3, 2, foo=a]"}
|
||||
_[23]={tags=_[32],text="a"}
|
||||
_[28]={tags=_[37],text="[3, 12, 99]"}
|
||||
_[27]={tags=_[36],text="99"}
|
||||
_[26]={tags=_[35],text="[3, 12]"}
|
||||
_[25]={tags=_[34],text="12"}
|
||||
_[24]={tags=_[33],text="[3, 5]"}
|
||||
_[23]={tags=_[32],text="5"}
|
||||
_[22]={tags=_[31],text="[3, 2]"}
|
||||
_[21]={tags=_[30],text="3"}
|
||||
_[20]={tags=_[29],text="[1, 2]"}
|
||||
|
|
@ -26,7 +26,7 @@ _[14]={_[23]}
|
|||
_[13]={_[22]}
|
||||
_[12]={_[21]}
|
||||
_[11]={_[20]}
|
||||
_[10]={"return"}
|
||||
_[10]={"error","list assignment index out of bounds; in Lua function \"()\"; at test/tests/list assignement.ans:21"}
|
||||
_[9]={"text",_[19]}
|
||||
_[8]={"text",_[18]}
|
||||
_[7]={"text",_[17]}
|
||||
|
|
@ -52,27 +52,27 @@ return {_[1],_[2],_[3],_[4],_[5],_[6],_[7],_[8],_[9],_[10]}
|
|||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "a"
|
||||
text = "5"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "[3, 2, foo=a]"
|
||||
text = "[3, 5]"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "b"
|
||||
text = "12"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "[3, 2, foo=a, bar=b]"
|
||||
text = "[3, 12]"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "c"
|
||||
text = "99"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "[3, 2, foo=c, bar=b]"
|
||||
text = "[3, 12, 99]"
|
||||
} } }
|
||||
{ "return" }
|
||||
{ "error", 'list assignment index out of bounds; in Lua function "()"; at test/tests/list assignement.ans:21' }
|
||||
]]--
|
||||
11
test/tests/list index.ans
Normal file
11
test/tests/list index.ans
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
:x = [1,2,3]
|
||||
|
||||
{x}
|
||||
|
||||
{x(1)} == {x(-3)}
|
||||
|
||||
{x(2)} == {x(-2)}
|
||||
|
||||
{x(3)} == {x(-1)}
|
||||
|
||||
{x(-4)}
|
||||
68
test/tests/list index.lua
Normal file
68
test/tests/list index.lua
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
local _={}
|
||||
_[29]={}
|
||||
_[28]={}
|
||||
_[27]={}
|
||||
_[26]={}
|
||||
_[25]={}
|
||||
_[24]={}
|
||||
_[23]={}
|
||||
_[22]={}
|
||||
_[21]={}
|
||||
_[20]={}
|
||||
_[19]={text="3",tags=_[29]}
|
||||
_[18]={text=" == ",tags=_[28]}
|
||||
_[17]={text="3",tags=_[27]}
|
||||
_[16]={text="2",tags=_[26]}
|
||||
_[15]={text=" == ",tags=_[25]}
|
||||
_[14]={text="2",tags=_[24]}
|
||||
_[13]={text="1",tags=_[23]}
|
||||
_[12]={text=" == ",tags=_[22]}
|
||||
_[11]={text="1",tags=_[21]}
|
||||
_[10]={text="[1, 2, 3]",tags=_[20]}
|
||||
_[9]={_[17],_[18],_[19]}
|
||||
_[8]={_[14],_[15],_[16]}
|
||||
_[7]={_[11],_[12],_[13]}
|
||||
_[6]={_[10]}
|
||||
_[5]={"error","list index out of bounds; in Lua function \"()\"; at test/tests/list index.ans:11"}
|
||||
_[4]={"text",_[9]}
|
||||
_[3]={"text",_[8]}
|
||||
_[2]={"text",_[7]}
|
||||
_[1]={"text",_[6]}
|
||||
return {_[1],_[2],_[3],_[4],_[5]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "[1, 2, 3]"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "1"
|
||||
}, {
|
||||
tags = {},
|
||||
text = " == "
|
||||
}, {
|
||||
tags = {},
|
||||
text = "1"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "2"
|
||||
}, {
|
||||
tags = {},
|
||||
text = " == "
|
||||
}, {
|
||||
tags = {},
|
||||
text = "2"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "3"
|
||||
}, {
|
||||
tags = {},
|
||||
text = " == "
|
||||
}, {
|
||||
tags = {},
|
||||
text = "3"
|
||||
} } }
|
||||
{ "error", 'list index out of bounds; in Lua function "()"; at test/tests/list index.ans:11' }
|
||||
]]--
|
||||
20
test/tests/map assignement.ans
Normal file
20
test/tests/map assignement.ans
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
:x = {1,2}
|
||||
|
||||
{x}
|
||||
|
||||
{x(1) := 3}
|
||||
|
||||
{x}
|
||||
|
||||
{x("foo") := "a"}
|
||||
|
||||
{x}
|
||||
|
||||
{x("bar") := "b"}
|
||||
|
||||
{x}
|
||||
|
||||
{x("foo") := "c"}
|
||||
|
||||
{x}
|
||||
|
||||
78
test/tests/map assignement.lua
Normal file
78
test/tests/map assignement.lua
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
local _={}
|
||||
_[37]={}
|
||||
_[36]={}
|
||||
_[35]={}
|
||||
_[34]={}
|
||||
_[33]={}
|
||||
_[32]={}
|
||||
_[31]={}
|
||||
_[30]={}
|
||||
_[29]={}
|
||||
_[28]={text="{1=3, 2=2, bar=b, foo=c}",tags=_[37]}
|
||||
_[27]={text="c",tags=_[36]}
|
||||
_[26]={text="{1=3, 2=2, bar=b, foo=a}",tags=_[35]}
|
||||
_[25]={text="b",tags=_[34]}
|
||||
_[24]={text="{1=3, 2=2, foo=a}",tags=_[33]}
|
||||
_[23]={text="a",tags=_[32]}
|
||||
_[22]={text="{1=3, 2=2}",tags=_[31]}
|
||||
_[21]={text="3",tags=_[30]}
|
||||
_[20]={text="{1=1, 2=2}",tags=_[29]}
|
||||
_[19]={_[28]}
|
||||
_[18]={_[27]}
|
||||
_[17]={_[26]}
|
||||
_[16]={_[25]}
|
||||
_[15]={_[24]}
|
||||
_[14]={_[23]}
|
||||
_[13]={_[22]}
|
||||
_[12]={_[21]}
|
||||
_[11]={_[20]}
|
||||
_[10]={"return"}
|
||||
_[9]={"text",_[19]}
|
||||
_[8]={"text",_[18]}
|
||||
_[7]={"text",_[17]}
|
||||
_[6]={"text",_[16]}
|
||||
_[5]={"text",_[15]}
|
||||
_[4]={"text",_[14]}
|
||||
_[3]={"text",_[13]}
|
||||
_[2]={"text",_[12]}
|
||||
_[1]={"text",_[11]}
|
||||
return {_[1],_[2],_[3],_[4],_[5],_[6],_[7],_[8],_[9],_[10]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "{1=1, 2=2}"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "3"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "{1=3, 2=2}"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "a"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "{1=3, 2=2, foo=a}"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "b"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "{1=3, 2=2, bar=b, foo=a}"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "c"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "{1=3, 2=2, bar=b, foo=c}"
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
29
test/tests/map index accross checkpoints.ans
Normal file
29
test/tests/map index accross checkpoints.ans
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
:x = {4}
|
||||
|
||||
x={x}
|
||||
|
||||
:a = {1,2,3,(x)=4}
|
||||
|
||||
:c = a
|
||||
|
||||
1={a==c}
|
||||
|
||||
a(x)={a(x)}
|
||||
|
||||
§ ch a
|
||||
|
||||
a(x)={a(x)}
|
||||
|
||||
§ ch b
|
||||
|
||||
~ x(2) := 3
|
||||
|
||||
a(x)={a(x)}
|
||||
|
||||
§ ch c
|
||||
|
||||
a(x)={a(x)}
|
||||
|
||||
~ x:={4}
|
||||
|
||||
no={a(x)}
|
||||
92
test/tests/map index accross checkpoints.lua
Normal file
92
test/tests/map index accross checkpoints.lua
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
local _={}
|
||||
_[41]={}
|
||||
_[40]={}
|
||||
_[39]={}
|
||||
_[38]={}
|
||||
_[37]={}
|
||||
_[36]={}
|
||||
_[35]={}
|
||||
_[34]={}
|
||||
_[33]={}
|
||||
_[32]={}
|
||||
_[31]={}
|
||||
_[30]={}
|
||||
_[29]={}
|
||||
_[28]={tags=_[41],text="no="}
|
||||
_[27]={tags=_[40],text="4"}
|
||||
_[26]={tags=_[39],text="a(x)="}
|
||||
_[25]={tags=_[38],text="4"}
|
||||
_[24]={tags=_[37],text="a(x)="}
|
||||
_[23]={tags=_[36],text="4"}
|
||||
_[22]={tags=_[35],text="a(x)="}
|
||||
_[21]={tags=_[34],text="4"}
|
||||
_[20]={tags=_[33],text="a(x)="}
|
||||
_[19]={tags=_[32],text="1"}
|
||||
_[18]={tags=_[31],text="1="}
|
||||
_[17]={tags=_[30],text="{1=4}"}
|
||||
_[16]={tags=_[29],text="x="}
|
||||
_[15]={_[28]}
|
||||
_[14]={_[26],_[27]}
|
||||
_[13]={_[24],_[25]}
|
||||
_[12]={_[22],_[23]}
|
||||
_[11]={_[20],_[21]}
|
||||
_[10]={_[18],_[19]}
|
||||
_[9]={_[16],_[17]}
|
||||
_[8]={"return"}
|
||||
_[7]={"text",_[15]}
|
||||
_[6]={"text",_[14]}
|
||||
_[5]={"text",_[13]}
|
||||
_[4]={"text",_[12]}
|
||||
_[3]={"text",_[11]}
|
||||
_[2]={"text",_[10]}
|
||||
_[1]={"text",_[9]}
|
||||
return {_[1],_[2],_[3],_[4],_[5],_[6],_[7],_[8]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "x="
|
||||
}, {
|
||||
tags = {},
|
||||
text = "{1=4}"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "1="
|
||||
}, {
|
||||
tags = {},
|
||||
text = "1"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "a(x)="
|
||||
}, {
|
||||
tags = {},
|
||||
text = "4"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "a(x)="
|
||||
}, {
|
||||
tags = {},
|
||||
text = "4"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "a(x)="
|
||||
}, {
|
||||
tags = {},
|
||||
text = "4"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "a(x)="
|
||||
}, {
|
||||
tags = {},
|
||||
text = "4"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "no="
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
7
test/tests/map index.ans
Normal file
7
test/tests/map index.ans
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
:t = {ahah=23,k=23,12}
|
||||
|
||||
{t} == \{3=12, ahah=23, k=23}
|
||||
|
||||
{t(3)} == 12
|
||||
|
||||
{t("ahah")} == 23
|
||||
45
test/tests/map index.lua
Normal file
45
test/tests/map index.lua
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
local _={}
|
||||
_[19]={}
|
||||
_[18]={}
|
||||
_[17]={}
|
||||
_[16]={}
|
||||
_[15]={}
|
||||
_[14]={}
|
||||
_[13]={tags=_[19],text=" == 23"}
|
||||
_[12]={tags=_[18],text="23"}
|
||||
_[11]={tags=_[17],text=" == 12"}
|
||||
_[10]={tags=_[16],text="12"}
|
||||
_[9]={tags=_[15],text=" == {3=12, ahah=23, k=23}"}
|
||||
_[8]={tags=_[14],text="{3=12, ahah=23, k=23}"}
|
||||
_[7]={_[12],_[13]}
|
||||
_[6]={_[10],_[11]}
|
||||
_[5]={_[8],_[9]}
|
||||
_[4]={"return"}
|
||||
_[3]={"text",_[7]}
|
||||
_[2]={"text",_[6]}
|
||||
_[1]={"text",_[5]}
|
||||
return {_[1],_[2],_[3],_[4]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "{3=12, ahah=23, k=23}"
|
||||
}, {
|
||||
tags = {},
|
||||
text = " == {3=12, ahah=23, k=23}"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "12"
|
||||
}, {
|
||||
tags = {},
|
||||
text = " == 12"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "23"
|
||||
}, {
|
||||
tags = {},
|
||||
text = " == 23"
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
Loading…
Add table
Add a link
Reference in a new issue