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

Add object type, dot operator can return function references

This commit is contained in:
Étienne Fildadut 2022-06-09 17:07:58 +09:00
parent 69b9e17020
commit 47f95fc04a
18 changed files with 599 additions and 49 deletions

View file

@ -0,0 +1,9 @@
$ f
$ a
@12
:x = &f
{x.a}
{x.a!}

View file

@ -0,0 +1,22 @@
local _={}
_[9]={}
_[8]={}
_[7]={tags=_[9],text="12"}
_[6]={tags=_[8],text="&function reference dot operator function.f.a"}
_[5]={_[7]}
_[4]={_[6]}
_[3]={"return"}
_[2]={"text",_[5]}
_[1]={"text",_[4]}
return {_[1],_[2],_[3]}
--[[
{ "text", { {
tags = {},
text = "&function reference dot operator function.f.a"
} } }
{ "text", { {
tags = {},
text = "12"
} } }
{ "return" }
]]--

View file

@ -0,0 +1,15 @@
% class
:a:b = "foo"
:c = "bar"
$ new(o::&class, x)
~ o.c := x
@o
:o = class
:p = class!new("hoho")
{o}, {p}
{o.c} == {class.c}
{p.c} != {class.c}

View file

@ -0,0 +1,57 @@
local _={}
_[23]={}
_[22]={}
_[21]={}
_[20]={}
_[19]={}
_[18]={}
_[17]={}
_[16]={}
_[15]={}
_[14]={tags=_[23],text="bar"}
_[13]={tags=_[22],text=" != "}
_[12]={tags=_[21],text="hoho"}
_[11]={tags=_[20],text="bar"}
_[10]={tags=_[19],text=" == "}
_[9]={tags=_[18],text="bar"}
_[8]={tags=_[17],text="%object constructor.class::&object constructor.class"}
_[7]={tags=_[16],text=", "}
_[6]={tags=_[15],text="%object constructor.class::&object constructor.class"}
_[5]={_[9],_[10],_[11],_[12],_[13],_[14]}
_[4]={_[6],_[7],_[8]}
_[3]={"return"}
_[2]={"text",_[5]}
_[1]={"text",_[4]}
return {_[1],_[2],_[3]}
--[[
{ "text", { {
tags = {},
text = "%object constructor.class::&object constructor.class"
}, {
tags = {},
text = ", "
}, {
tags = {},
text = "%object constructor.class::&object constructor.class"
} } }
{ "text", { {
tags = {},
text = "bar"
}, {
tags = {},
text = " == "
}, {
tags = {},
text = "bar"
}, {
tags = {},
text = "hoho"
}, {
tags = {},
text = " != "
}, {
tags = {},
text = "bar"
} } }
{ "return" }
]]--

View file

@ -0,0 +1,26 @@
% class
:a:b = "foo"
:c = "bar"
:o = class
:p = class
{o}, {p}
{o.a} == {class.a}
{o.b} == {class.b}
{p.a} == {class.a}
{p.b} == {class.b}
~ o.b := "haha"
{o.a} != {class.a}
{o.b} != {class.b}
{p.a} == {class.a}
{p.b} == {class.b}
{o.c} == {class.c}
{p.c} == {class.c}

View file

@ -0,0 +1,192 @@
local _={}
_[81]={}
_[80]={}
_[79]={}
_[78]={}
_[77]={}
_[76]={}
_[75]={}
_[74]={}
_[73]={}
_[72]={}
_[71]={}
_[70]={}
_[69]={}
_[68]={}
_[67]={}
_[66]={}
_[65]={}
_[64]={}
_[63]={}
_[62]={}
_[61]={}
_[60]={}
_[59]={}
_[58]={}
_[57]={}
_[56]={}
_[55]={}
_[54]={}
_[53]={}
_[52]={}
_[51]={}
_[50]={}
_[49]={}
_[48]={tags=_[81],text="bar"}
_[47]={tags=_[80],text=" == "}
_[46]={tags=_[79],text="bar"}
_[45]={tags=_[78],text="bar"}
_[44]={tags=_[77],text=" == "}
_[43]={tags=_[76],text="bar"}
_[42]={tags=_[75],text="foo"}
_[41]={tags=_[74],text=" == "}
_[40]={tags=_[73],text="foo"}
_[39]={tags=_[72],text="foo"}
_[38]={tags=_[71],text=" == "}
_[37]={tags=_[70],text="foo"}
_[36]={tags=_[69],text="foo"}
_[35]={tags=_[68],text=" != "}
_[34]={tags=_[67],text="haha"}
_[33]={tags=_[66],text="foo"}
_[32]={tags=_[65],text=" != "}
_[31]={tags=_[64],text="haha"}
_[30]={tags=_[63],text="foo"}
_[29]={tags=_[62],text=" == "}
_[28]={tags=_[61],text="foo"}
_[27]={tags=_[60],text="foo"}
_[26]={tags=_[59],text=" == "}
_[25]={tags=_[58],text="foo"}
_[24]={tags=_[57],text="foo"}
_[23]={tags=_[56],text=" == "}
_[22]={tags=_[55],text="foo"}
_[21]={tags=_[54],text="foo"}
_[20]={tags=_[53],text=" == "}
_[19]={tags=_[52],text="foo"}
_[18]={tags=_[51],text="%object several.class::&object several.class"}
_[17]={tags=_[50],text=", "}
_[16]={tags=_[49],text="%object several.class::&object several.class"}
_[15]={_[46],_[47],_[48]}
_[14]={_[43],_[44],_[45]}
_[13]={_[37],_[38],_[39],_[40],_[41],_[42]}
_[12]={_[31],_[32],_[33],_[34],_[35],_[36]}
_[11]={_[25],_[26],_[27],_[28],_[29],_[30]}
_[10]={_[19],_[20],_[21],_[22],_[23],_[24]}
_[9]={_[16],_[17],_[18]}
_[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 = "%object several.class::&object several.class"
}, {
tags = {},
text = ", "
}, {
tags = {},
text = "%object several.class::&object several.class"
} } }
{ "text", { {
tags = {},
text = "foo"
}, {
tags = {},
text = " == "
}, {
tags = {},
text = "foo"
}, {
tags = {},
text = "foo"
}, {
tags = {},
text = " == "
}, {
tags = {},
text = "foo"
} } }
{ "text", { {
tags = {},
text = "foo"
}, {
tags = {},
text = " == "
}, {
tags = {},
text = "foo"
}, {
tags = {},
text = "foo"
}, {
tags = {},
text = " == "
}, {
tags = {},
text = "foo"
} } }
{ "text", { {
tags = {},
text = "haha"
}, {
tags = {},
text = " != "
}, {
tags = {},
text = "foo"
}, {
tags = {},
text = "haha"
}, {
tags = {},
text = " != "
}, {
tags = {},
text = "foo"
} } }
{ "text", { {
tags = {},
text = "foo"
}, {
tags = {},
text = " == "
}, {
tags = {},
text = "foo"
}, {
tags = {},
text = "foo"
}, {
tags = {},
text = " == "
}, {
tags = {},
text = "foo"
} } }
{ "text", { {
tags = {},
text = "bar"
}, {
tags = {},
text = " == "
}, {
tags = {},
text = "bar"
} } }
{ "text", { {
tags = {},
text = "bar"
}, {
tags = {},
text = " == "
}, {
tags = {},
text = "bar"
} } }
{ "return" }
]]--

View file

@ -0,0 +1,17 @@
% class
:a:b = "foo"
:c = "bar"
:o = class
{o}
{o.a} == {class.a}
{o.b} == {class.b}
~ o.b := "haha"
{o.a} != {class.a}
{o.b} != {class.b}
{o.c} == {class.c}

View file

@ -0,0 +1,98 @@
local _={}
_[41]={}
_[40]={}
_[39]={}
_[38]={}
_[37]={}
_[36]={}
_[35]={}
_[34]={}
_[33]={}
_[32]={}
_[31]={}
_[30]={}
_[29]={}
_[28]={}
_[27]={}
_[26]={}
_[25]={tags=_[41],text="bar"}
_[24]={tags=_[40],text=" == "}
_[23]={tags=_[39],text="bar"}
_[22]={tags=_[38],text="foo"}
_[21]={tags=_[37],text=" != "}
_[20]={tags=_[36],text="haha"}
_[19]={tags=_[35],text="foo"}
_[18]={tags=_[34],text=" != "}
_[17]={tags=_[33],text="haha"}
_[16]={tags=_[32],text="foo"}
_[15]={tags=_[31],text=" == "}
_[14]={tags=_[30],text="foo"}
_[13]={tags=_[29],text="foo"}
_[12]={tags=_[28],text=" == "}
_[11]={tags=_[27],text="foo"}
_[10]={tags=_[26],text="%object simple.class::&object simple.class"}
_[9]={_[23],_[24],_[25]}
_[8]={_[17],_[18],_[19],_[20],_[21],_[22]}
_[7]={_[11],_[12],_[13],_[14],_[15],_[16]}
_[6]={_[10]}
_[5]={"return"}
_[4]={"text",_[9]}
_[3]={"text",_[8]}
_[2]={"text",_[7]}
_[1]={"text",_[6]}
return {_[1],_[2],_[3],_[4],_[5]}
--[[
{ "text", { {
tags = {},
text = "%object simple.class::&object simple.class"
} } }
{ "text", { {
tags = {},
text = "foo"
}, {
tags = {},
text = " == "
}, {
tags = {},
text = "foo"
}, {
tags = {},
text = "foo"
}, {
tags = {},
text = " == "
}, {
tags = {},
text = "foo"
} } }
{ "text", { {
tags = {},
text = "haha"
}, {
tags = {},
text = " != "
}, {
tags = {},
text = "foo"
}, {
tags = {},
text = "haha"
}, {
tags = {},
text = " != "
}, {
tags = {},
text = "foo"
} } }
{ "text", { {
tags = {},
text = "bar"
}, {
tags = {},
text = " == "
}, {
tags = {},
text = "bar"
} } }
{ "return" }
]]--