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

Add while loop line and operator

This commit is contained in:
Étienne Fildadut 2021-12-12 17:07:50 +01:00
parent f5382d2912
commit 48cabbf4c0
14 changed files with 500 additions and 61 deletions

View file

@ -0,0 +1,5 @@
:i = 0
{i}\n~? (i += 1; i <= 10)
{i}

View file

@ -0,0 +1,117 @@
local _={}
_[47]={}
_[46]={}
_[45]={}
_[44]={}
_[43]={}
_[42]={}
_[41]={}
_[40]={}
_[39]={}
_[38]={}
_[37]={}
_[36]={}
_[35]={}
_[34]={}
_[33]={}
_[32]={}
_[31]={}
_[30]={}
_[29]={}
_[28]={}
_[27]={}
_[26]={text="11",tags=_[47]}
_[25]={text="\n",tags=_[46]}
_[24]={text="10",tags=_[45]}
_[23]={text="\n",tags=_[44]}
_[22]={text="9",tags=_[43]}
_[21]={text="\n",tags=_[42]}
_[20]={text="8",tags=_[41]}
_[19]={text="\n",tags=_[40]}
_[18]={text="7",tags=_[39]}
_[17]={text="\n",tags=_[38]}
_[16]={text="6",tags=_[37]}
_[15]={text="\n",tags=_[36]}
_[14]={text="5",tags=_[35]}
_[13]={text="\n",tags=_[34]}
_[12]={text="4",tags=_[33]}
_[11]={text="\n",tags=_[32]}
_[10]={text="3",tags=_[31]}
_[9]={text="\n",tags=_[30]}
_[8]={text="2",tags=_[29]}
_[7]={text="\n",tags=_[28]}
_[6]={text="1",tags=_[27]}
_[5]={_[26]}
_[4]={_[6],_[7],_[8],_[9],_[10],_[11],_[12],_[13],_[14],_[15],_[16],_[17],_[18],_[19],_[20],_[21],_[22],_[23],_[24],_[25]}
_[3]={"return"}
_[2]={"text",_[5]}
_[1]={"text",_[4]}
return {_[1],_[2],_[3]}
--[[
{ "text", { {
tags = {},
text = "1"
}, {
tags = {},
text = "\n"
}, {
tags = {},
text = "2"
}, {
tags = {},
text = "\n"
}, {
tags = {},
text = "3"
}, {
tags = {},
text = "\n"
}, {
tags = {},
text = "4"
}, {
tags = {},
text = "\n"
}, {
tags = {},
text = "5"
}, {
tags = {},
text = "\n"
}, {
tags = {},
text = "6"
}, {
tags = {},
text = "\n"
}, {
tags = {},
text = "7"
}, {
tags = {},
text = "\n"
}, {
tags = {},
text = "8"
}, {
tags = {},
text = "\n"
}, {
tags = {},
text = "9"
}, {
tags = {},
text = "\n"
}, {
tags = {},
text = "10"
}, {
tags = {},
text = "\n"
} } }
{ "text", { {
tags = {},
text = "11"
} } }
{ "return" }
]]--

View file

@ -0,0 +1,19 @@
:i = 1
Start with i={i}:
~? i < 5
{i}
~ i += 1
~~
Loop not ran.
Start with i={i}:
~? i < 5
{i}
~ i += 1
~~
Loop not ran.

View file

@ -0,0 +1,82 @@
local _={}
_[37]={}
_[36]={}
_[35]={}
_[34]={}
_[33]={}
_[32]={}
_[31]={}
_[30]={}
_[29]={}
_[28]={}
_[27]={}
_[26]={text="Loop not ran.",tags=_[37]}
_[25]={text=":",tags=_[36]}
_[24]={text="5",tags=_[35]}
_[23]={text="Start with i=",tags=_[34]}
_[22]={text="4",tags=_[33]}
_[21]={text="3",tags=_[32]}
_[20]={text="2",tags=_[31]}
_[19]={text="1",tags=_[30]}
_[18]={text=":",tags=_[29]}
_[17]={text="1",tags=_[28]}
_[16]={text="Start with i=",tags=_[27]}
_[15]={_[26]}
_[14]={_[23],_[24],_[25]}
_[13]={_[22]}
_[12]={_[21]}
_[11]={_[20]}
_[10]={_[19]}
_[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 = "Start with i="
}, {
tags = {},
text = "1"
}, {
tags = {},
text = ":"
} } }
{ "text", { {
tags = {},
text = "1"
} } }
{ "text", { {
tags = {},
text = "2"
} } }
{ "text", { {
tags = {},
text = "3"
} } }
{ "text", { {
tags = {},
text = "4"
} } }
{ "text", { {
tags = {},
text = "Start with i="
}, {
tags = {},
text = "5"
}, {
tags = {},
text = ":"
} } }
{ "text", { {
tags = {},
text = "Loop not ran."
} } }
{ "return" }
]]--

16
test/tests/while loop.ans Normal file
View file

@ -0,0 +1,16 @@
:i = 0
~? i <= 10
{i}
~ i += 1
return in loop:
~ i := 0
~? i <= 10
{i}
~ i == 5
@
~ i += 1

150
test/tests/while loop.lua Normal file
View file

@ -0,0 +1,150 @@
local _={}
_[73]={}
_[72]={}
_[71]={}
_[70]={}
_[69]={}
_[68]={}
_[67]={}
_[66]={}
_[65]={}
_[64]={}
_[63]={}
_[62]={}
_[61]={}
_[60]={}
_[59]={}
_[58]={}
_[57]={}
_[56]={}
_[55]={text="5",tags=_[73]}
_[54]={text="4",tags=_[72]}
_[53]={text="3",tags=_[71]}
_[52]={text="2",tags=_[70]}
_[51]={text="1",tags=_[69]}
_[50]={text="0",tags=_[68]}
_[49]={text="return in loop:",tags=_[67]}
_[48]={text="10",tags=_[66]}
_[47]={text="9",tags=_[65]}
_[46]={text="8",tags=_[64]}
_[45]={text="7",tags=_[63]}
_[44]={text="6",tags=_[62]}
_[43]={text="5",tags=_[61]}
_[42]={text="4",tags=_[60]}
_[41]={text="3",tags=_[59]}
_[40]={text="2",tags=_[58]}
_[39]={text="1",tags=_[57]}
_[38]={text="0",tags=_[56]}
_[37]={_[55]}
_[36]={_[54]}
_[35]={_[53]}
_[34]={_[52]}
_[33]={_[51]}
_[32]={_[50]}
_[31]={_[49]}
_[30]={_[48]}
_[29]={_[47]}
_[28]={_[46]}
_[27]={_[45]}
_[26]={_[44]}
_[25]={_[43]}
_[24]={_[42]}
_[23]={_[41]}
_[22]={_[40]}
_[21]={_[39]}
_[20]={_[38]}
_[19]={"return"}
_[18]={"text",_[37]}
_[17]={"text",_[36]}
_[16]={"text",_[35]}
_[15]={"text",_[34]}
_[14]={"text",_[33]}
_[13]={"text",_[32]}
_[12]={"text",_[31]}
_[11]={"text",_[30]}
_[10]={"text",_[29]}
_[9]={"text",_[28]}
_[8]={"text",_[27]}
_[7]={"text",_[26]}
_[6]={"text",_[25]}
_[5]={"text",_[24]}
_[4]={"text",_[23]}
_[3]={"text",_[22]}
_[2]={"text",_[21]}
_[1]={"text",_[20]}
return {_[1],_[2],_[3],_[4],_[5],_[6],_[7],_[8],_[9],_[10],_[11],_[12],_[13],_[14],_[15],_[16],_[17],_[18],_[19]}
--[[
{ "text", { {
tags = {},
text = "0"
} } }
{ "text", { {
tags = {},
text = "1"
} } }
{ "text", { {
tags = {},
text = "2"
} } }
{ "text", { {
tags = {},
text = "3"
} } }
{ "text", { {
tags = {},
text = "4"
} } }
{ "text", { {
tags = {},
text = "5"
} } }
{ "text", { {
tags = {},
text = "6"
} } }
{ "text", { {
tags = {},
text = "7"
} } }
{ "text", { {
tags = {},
text = "8"
} } }
{ "text", { {
tags = {},
text = "9"
} } }
{ "text", { {
tags = {},
text = "10"
} } }
{ "text", { {
tags = {},
text = "return in loop:"
} } }
{ "text", { {
tags = {},
text = "0"
} } }
{ "text", { {
tags = {},
text = "1"
} } }
{ "text", { {
tags = {},
text = "2"
} } }
{ "text", { {
tags = {},
text = "3"
} } }
{ "text", { {
tags = {},
text = "4"
} } }
{ "text", { {
tags = {},
text = "5"
} } }
{ "return" }
]]--