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

Rename overloaded operators (add underscores)

* add suffix unary operators
* add _! operator
* _._ and _&_ operator overloading
* allow calling function references with _! and access variables with _._
* rename . method operator to !
* various cleaning & improvements

Documentation will follow at some point.
This commit is contained in:
Étienne Fildadut 2021-12-06 01:45:19 +01:00
parent d5b1a9f225
commit 9bd9759115
16 changed files with 350 additions and 178 deletions

View file

@ -1,7 +1,7 @@
$ -(a, b)
$ _-_(a, b)
@"generic minus"
$ -(a::string, b::string)
$ _-_(a::string, b::string)
@a + " minus " + b
{2-5}

View file

@ -0,0 +1,7 @@
:c = 1
{c}
~ c += 2
{c}

View file

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

View file

@ -4,19 +4,19 @@
1,2: {l}
~ l.insert(3)
~ l!insert(3)
1,2,3: {l}
§ a
~ l.insert(4)
~ l!insert(4)
1,2,3,4: {l}
§ b
~ l.insert(5)
~ l!insert(5)
1,2,3,4,5: {l}

View file

@ -0,0 +1,13 @@
$ fn
@1
$ add(x)
@x+2
:c = &fn
{c!}
{fn!add}
{c!!add}

View file

@ -0,0 +1,30 @@
local _={}
_[13]={}
_[12]={}
_[11]={}
_[10]={text="3",tags=_[13]}
_[9]={text="3",tags=_[12]}
_[8]={text="1",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", { {
tags = {},
text = "1"
} } }
{ "text", { {
tags = {},
text = "3"
} } }
{ "text", { {
tags = {},
text = "3"
} } }
{ "return" }
]]--

View file

@ -1,6 +1,6 @@
$ f(a)
{a}
~ "ok".f
~ "ok"!f
~ "ok".f()
~ "ok"!f()

View file

@ -1,4 +1,4 @@
$ f(a, b)
{a}{b}
~ "o".f("k")
~ "o"!f("k")

View file

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

View file

@ -1,7 +1,7 @@
$ -(f)
$ -_(f)
@"generic minus"
$ -(f::string)
$ -_(f::string)
@"minus "+f
{-5}