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

Implicitly call references like functions

This commit is contained in:
Étienne Fildadut 2022-09-10 17:58:34 +09:00
parent 95462391e3
commit 1263c32572
9 changed files with 505 additions and 73 deletions

View file

@ -4,6 +4,8 @@ $ f
:x = &f
{&x.a}
{x.a}
{x.a!}

View file

@ -1,14 +1,18 @@
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]}
_[13]={}
_[12]={}
_[11]={}
_[10]={tags=_[13],text="12"}
_[9]={tags=_[12],text="12"}
_[8]={tags=_[11],text="&function reference dot operator function.f.a"}
_[7]={_[10]}
_[6]={_[9]}
_[5]={_[8]}
_[4]={"return"}
_[3]={"text",_[7]}
_[2]={"text",_[6]}
_[1]={"text",_[5]}
return {_[1],_[2],_[3],_[4]}
--[[
{ "text", { {
tags = {},
@ -18,5 +22,9 @@ return {_[1],_[2],_[3]}
tags = {},
text = "12"
} } }
{ "text", { {
tags = {},
text = "12"
} } }
{ "return" }
]]--

View file

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

View file

@ -0,0 +1,61 @@
Function with argument:
$ f(x)
{&f}
Function without argument:
$ a
lol
$ b
hihi
a: {a}
&a: {&a}
:ref = &a
&ref: {&ref}
&&&ref: {&&&ref}
ref: {ref}
ref.b: {ref.b}
ref.b!: {ref.b!}
ref.b(): {ref.b()}
&ref.b: {&ref.b}
&ref.b!: {&ref.b!}
&ref.b(): {&ref.b()}
&ref!: {&ref!}
Objects:
% A
$ b
KK
@1
&A: {&A}
:ref A = &A
ref A: {ref A}
&ref A: {&ref A}
A.b: {A.b}
&A.b: {&A.b}
\(&A).b: {(&A).b}
&(&A).b: {&(&A).b}

View file

@ -0,0 +1,285 @@
local _={}
_[131]={}
_[130]={}
_[129]={}
_[128]={}
_[127]={}
_[126]={}
_[125]={}
_[124]={}
_[123]={}
_[122]={}
_[121]={}
_[120]={}
_[119]={}
_[118]={}
_[117]={}
_[116]={}
_[115]={}
_[114]={}
_[113]={}
_[112]={}
_[111]={}
_[110]={}
_[109]={}
_[108]={}
_[107]={}
_[106]={}
_[105]={}
_[104]={}
_[103]={}
_[102]={}
_[101]={}
_[100]={}
_[99]={}
_[98]={}
_[97]={}
_[96]={}
_[95]={}
_[94]={}
_[93]={}
_[92]={}
_[91]={}
_[90]={}
_[89]={tags=_[131],text="&implicit call of references.A.b"}
_[88]={tags=_[130],text="&(&A).b: "}
_[87]={tags=_[129],text="KK"}
_[86]={tags=_[128],text="(&A).b: "}
_[85]={tags=_[127],text="&implicit call of references.A.b"}
_[84]={tags=_[126],text="&A.b: "}
_[83]={tags=_[125],text="KK"}
_[82]={tags=_[124],text="A.b: "}
_[81]={tags=_[123],text="&implicit call of references.A"}
_[80]={tags=_[122],text="&ref A: "}
_[79]={tags=_[121],text="1"}
_[78]={tags=_[120],text="ref A: "}
_[77]={tags=_[119],text="&implicit call of references.A"}
_[76]={tags=_[118],text="&A: "}
_[75]={tags=_[117],text="Objects:"}
_[74]={tags=_[116],text="lol"}
_[73]={tags=_[115],text="&ref!: "}
_[72]={tags=_[114],text="hihi"}
_[71]={tags=_[113],text="&ref.b(): "}
_[70]={tags=_[112],text="hihi"}
_[69]={tags=_[111],text="&ref.b!: "}
_[68]={tags=_[110],text="&implicit call of references.a.b"}
_[67]={tags=_[109],text="&ref.b: "}
_[66]={tags=_[108],text="hihi"}
_[65]={tags=_[107],text="ref.b(): "}
_[64]={tags=_[106],text="hihi"}
_[63]={tags=_[105],text="ref.b!: "}
_[62]={tags=_[104],text="hihi"}
_[61]={tags=_[103],text="ref.b: "}
_[60]={tags=_[102],text="lol"}
_[59]={tags=_[101],text="ref: "}
_[58]={tags=_[100],text="&implicit call of references.a"}
_[57]={tags=_[99],text="&&&ref: "}
_[56]={tags=_[98],text="&implicit call of references.a"}
_[55]={tags=_[97],text="&ref: "}
_[54]={tags=_[96],text="&implicit call of references.a"}
_[53]={tags=_[95],text="&a: "}
_[52]={tags=_[94],text="lol"}
_[51]={tags=_[93],text="a: "}
_[50]={tags=_[92],text="Function without argument:"}
_[49]={tags=_[91],text="&implicit call of references.f"}
_[48]={tags=_[90],text="Function with argument:"}
_[47]={_[88],_[89]}
_[46]={_[86],_[87]}
_[45]={_[84],_[85]}
_[44]={_[82],_[83]}
_[43]={_[80],_[81]}
_[42]={_[78],_[79]}
_[41]={_[76],_[77]}
_[40]={_[75]}
_[39]={_[73],_[74]}
_[38]={_[71],_[72]}
_[37]={_[69],_[70]}
_[36]={_[67],_[68]}
_[35]={_[65],_[66]}
_[34]={_[63],_[64]}
_[33]={_[61],_[62]}
_[32]={_[59],_[60]}
_[31]={_[57],_[58]}
_[30]={_[55],_[56]}
_[29]={_[53],_[54]}
_[28]={_[51],_[52]}
_[27]={_[50]}
_[26]={_[49]}
_[25]={_[48]}
_[24]={"return"}
_[23]={"text",_[47]}
_[22]={"text",_[46]}
_[21]={"text",_[45]}
_[20]={"text",_[44]}
_[19]={"text",_[43]}
_[18]={"text",_[42]}
_[17]={"text",_[41]}
_[16]={"text",_[40]}
_[15]={"text",_[39]}
_[14]={"text",_[38]}
_[13]={"text",_[37]}
_[12]={"text",_[36]}
_[11]={"text",_[35]}
_[10]={"text",_[34]}
_[9]={"text",_[33]}
_[8]={"text",_[32]}
_[7]={"text",_[31]}
_[6]={"text",_[30]}
_[5]={"text",_[29]}
_[4]={"text",_[28]}
_[3]={"text",_[27]}
_[2]={"text",_[26]}
_[1]={"text",_[25]}
return {_[1],_[2],_[3],_[4],_[5],_[6],_[7],_[8],_[9],_[10],_[11],_[12],_[13],_[14],_[15],_[16],_[17],_[18],_[19],_[20],_[21],_[22],_[23],_[24]}
--[[
{ "text", { {
tags = {},
text = "Function with argument:"
} } }
{ "text", { {
tags = {},
text = "&implicit call of references.f"
} } }
{ "text", { {
tags = {},
text = "Function without argument:"
} } }
{ "text", { {
tags = {},
text = "a: "
}, {
tags = {},
text = "lol"
} } }
{ "text", { {
tags = {},
text = "&a: "
}, {
tags = {},
text = "&implicit call of references.a"
} } }
{ "text", { {
tags = {},
text = "&ref: "
}, {
tags = {},
text = "&implicit call of references.a"
} } }
{ "text", { {
tags = {},
text = "&&&ref: "
}, {
tags = {},
text = "&implicit call of references.a"
} } }
{ "text", { {
tags = {},
text = "ref: "
}, {
tags = {},
text = "lol"
} } }
{ "text", { {
tags = {},
text = "ref.b: "
}, {
tags = {},
text = "hihi"
} } }
{ "text", { {
tags = {},
text = "ref.b!: "
}, {
tags = {},
text = "hihi"
} } }
{ "text", { {
tags = {},
text = "ref.b(): "
}, {
tags = {},
text = "hihi"
} } }
{ "text", { {
tags = {},
text = "&ref.b: "
}, {
tags = {},
text = "&implicit call of references.a.b"
} } }
{ "text", { {
tags = {},
text = "&ref.b!: "
}, {
tags = {},
text = "hihi"
} } }
{ "text", { {
tags = {},
text = "&ref.b(): "
}, {
tags = {},
text = "hihi"
} } }
{ "text", { {
tags = {},
text = "&ref!: "
}, {
tags = {},
text = "lol"
} } }
{ "text", { {
tags = {},
text = "Objects:"
} } }
{ "text", { {
tags = {},
text = "&A: "
}, {
tags = {},
text = "&implicit call of references.A"
} } }
{ "text", { {
tags = {},
text = "ref A: "
}, {
tags = {},
text = "1"
} } }
{ "text", { {
tags = {},
text = "&ref A: "
}, {
tags = {},
text = "&implicit call of references.A"
} } }
{ "text", { {
tags = {},
text = "A.b: "
}, {
tags = {},
text = "KK"
} } }
{ "text", { {
tags = {},
text = "&A.b: "
}, {
tags = {},
text = "&implicit call of references.A.b"
} } }
{ "text", { {
tags = {},
text = "(&A).b: "
}, {
tags = {},
text = "KK"
} } }
{ "text", { {
tags = {},
text = "&(&A).b: "
}, {
tags = {},
text = "&implicit call of references.A.b"
} } }
{ "return" }
]]--