mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-27 16:49:31 +00:00
Changed a few things
* Integrated # and ~ decorators into the expression system. Created associated operators. * # and ~ decorators only affect their current line. That's more useful... * Fix our priority system to evaluate left-to-right instead of right-to-left (if there was a reason why I did it this way initially, I don't remember it so ¯\_(ツ)_/¯) * a lotta internal changes Various other small adjustments, see the diff of REFERENCE.md for details.
This commit is contained in:
parent
14d348bad9
commit
f2e74c94c9
31 changed files with 894 additions and 343 deletions
|
|
@ -79,7 +79,7 @@ if args.help then
|
|||
print("")
|
||||
print("For script or game mode:")
|
||||
print(" --lang code: load a language file")
|
||||
print(" --save: print VM state at the end of the script")
|
||||
print(" --save: print save data at the end of the script")
|
||||
os.exit()
|
||||
end
|
||||
|
||||
|
|
|
|||
35
test/tests/choice with decorators.ans
Normal file
35
test/tests/choice with decorators.ans
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
> a ~ 1
|
||||
-> a
|
||||
> b
|
||||
-> b
|
||||
~ choose(1)
|
||||
|
||||
> a ~ 1
|
||||
-> a
|
||||
> b
|
||||
-> b
|
||||
~ choose(2)
|
||||
|
||||
> a ~ 0
|
||||
-> a
|
||||
> b
|
||||
-> b
|
||||
~ choose(1)
|
||||
|
||||
> a
|
||||
-> a
|
||||
> b # 25
|
||||
-> b
|
||||
~ choose(2)
|
||||
|
||||
> a ~ 0 # 12
|
||||
-> a
|
||||
> b # 3
|
||||
-> b
|
||||
~ choose(1)
|
||||
|
||||
> a ~ 1 # 12
|
||||
-> a
|
||||
> b # 3
|
||||
-> b
|
||||
~ choose(1)
|
||||
132
test/tests/choice with decorators.lua
Normal file
132
test/tests/choice with decorators.lua
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
local _={}
|
||||
_[67]={3}
|
||||
_[66]={12}
|
||||
_[65]={3}
|
||||
_[64]={25}
|
||||
_[63]={}
|
||||
_[62]={}
|
||||
_[61]={}
|
||||
_[60]={}
|
||||
_[59]={}
|
||||
_[58]={}
|
||||
_[57]={}
|
||||
_[56]={text="b",tags=_[67]}
|
||||
_[55]={text="a",tags=_[66]}
|
||||
_[54]={}
|
||||
_[53]={text="b",tags=_[65]}
|
||||
_[52]={}
|
||||
_[51]={text="b",tags=_[64]}
|
||||
_[50]={text="a",tags=_[63]}
|
||||
_[49]={}
|
||||
_[48]={text="b",tags=_[62]}
|
||||
_[47]={}
|
||||
_[46]={text="b",tags=_[61]}
|
||||
_[45]={text="a",tags=_[60]}
|
||||
_[44]={}
|
||||
_[43]={text="b",tags=_[59]}
|
||||
_[42]={text="a",tags=_[58]}
|
||||
_[41]={text="-> a",tags=_[57]}
|
||||
_[40]={_[56]}
|
||||
_[39]={_[55]}
|
||||
_[38]={text="-> b",tags=_[54]}
|
||||
_[37]={_[53]}
|
||||
_[36]={text="-> b",tags=_[52]}
|
||||
_[35]={_[51]}
|
||||
_[34]={_[50]}
|
||||
_[33]={text="-> b",tags=_[49]}
|
||||
_[32]={_[48]}
|
||||
_[31]={text="-> b",tags=_[47]}
|
||||
_[30]={_[46]}
|
||||
_[29]={_[45]}
|
||||
_[28]={text="-> a",tags=_[44]}
|
||||
_[27]={_[43]}
|
||||
_[26]={_[42]}
|
||||
_[25]={_[41]}
|
||||
_[24]={_[39],_[40]}
|
||||
_[23]={_[38]}
|
||||
_[22]={_[37]}
|
||||
_[21]={_[36]}
|
||||
_[20]={_[34],_[35]}
|
||||
_[19]={_[33]}
|
||||
_[18]={_[32]}
|
||||
_[17]={_[31]}
|
||||
_[16]={_[29],_[30]}
|
||||
_[15]={_[28]}
|
||||
_[14]={_[26],_[27]}
|
||||
_[13]={"return"}
|
||||
_[12]={"text",_[25]}
|
||||
_[11]={"choice",_[24]}
|
||||
_[10]={"text",_[23]}
|
||||
_[9]={"choice",_[22]}
|
||||
_[8]={"text",_[21]}
|
||||
_[7]={"choice",_[20]}
|
||||
_[6]={"text",_[19]}
|
||||
_[5]={"choice",_[18]}
|
||||
_[4]={"text",_[17]}
|
||||
_[3]={"choice",_[16]}
|
||||
_[2]={"text",_[15]}
|
||||
_[1]={"choice",_[14]}
|
||||
return {_[1],_[2],_[3],_[4],_[5],_[6],_[7],_[8],_[9],_[10],_[11],_[12],_[13]}
|
||||
--[[
|
||||
{ "choice", { { {
|
||||
tags = {},
|
||||
text = "a"
|
||||
} }, { {
|
||||
tags = {},
|
||||
text = "b"
|
||||
} } } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "-> a"
|
||||
} } }
|
||||
{ "choice", { { {
|
||||
tags = {},
|
||||
text = "a"
|
||||
} }, { {
|
||||
tags = {},
|
||||
text = "b"
|
||||
} } } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "-> b"
|
||||
} } }
|
||||
{ "choice", { { {
|
||||
tags = {},
|
||||
text = "b"
|
||||
} } } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "-> b"
|
||||
} } }
|
||||
{ "choice", { { {
|
||||
tags = {},
|
||||
text = "a"
|
||||
} }, { {
|
||||
tags = { 25 },
|
||||
text = "b"
|
||||
} } } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "-> b"
|
||||
} } }
|
||||
{ "choice", { { {
|
||||
tags = { 3 },
|
||||
text = "b"
|
||||
} } } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "-> b"
|
||||
} } }
|
||||
{ "choice", { { {
|
||||
tags = { 12 },
|
||||
text = "a"
|
||||
} }, { {
|
||||
tags = { 3 },
|
||||
text = "b"
|
||||
} } } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "-> a"
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
ko ~ 0
|
||||
ok ~ 1
|
||||
ok bis ~
|
||||
ok bis ~ 1
|
||||
6
test/tests/condition operator.ans
Normal file
6
test/tests/condition operator.ans
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
$ f
|
||||
b
|
||||
|
||||
a {f ~ 5} c
|
||||
|
||||
a {f ~ 0} c
|
||||
35
test/tests/condition operator.lua
Normal file
35
test/tests/condition operator.lua
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
local _={}
|
||||
_[13]={}
|
||||
_[12]={}
|
||||
_[11]={}
|
||||
_[10]={tags=_[13],text="c"}
|
||||
_[9]={tags=_[13],text="a "}
|
||||
_[8]={tags=_[11],text=" c"}
|
||||
_[7]={tags=_[12],text="b"}
|
||||
_[6]={tags=_[11],text="a "}
|
||||
_[5]={_[9],_[10]}
|
||||
_[4]={_[6],_[7],_[8]}
|
||||
_[3]={"return"}
|
||||
_[2]={"text",_[5]}
|
||||
_[1]={"text",_[4]}
|
||||
return {_[1],_[2],_[3]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
tags = <1>{},
|
||||
text = "a "
|
||||
}, {
|
||||
tags = {},
|
||||
text = "b"
|
||||
}, {
|
||||
tags = <table 1>,
|
||||
text = " c"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = <1>{},
|
||||
text = "a "
|
||||
}, {
|
||||
tags = <table 1>,
|
||||
text = "c"
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
3
test/tests/remove duplicate spaces.ans
Normal file
3
test/tests/remove duplicate spaces.ans
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
a
|
||||
b
|
||||
{" "}c
|
||||
28
test/tests/remove duplicate spaces.lua
Normal file
28
test/tests/remove duplicate spaces.lua
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
local _={}
|
||||
_[10]={}
|
||||
_[9]={}
|
||||
_[8]={}
|
||||
_[7]={text="c",tags=_[10]}
|
||||
_[6]={text="",tags=_[10]}
|
||||
_[5]={text="b ",tags=_[9]}
|
||||
_[4]={text="a ",tags=_[8]}
|
||||
_[3]={_[4],_[5],_[6],_[7]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "a "
|
||||
}, {
|
||||
tags = {},
|
||||
text = "b "
|
||||
}, {
|
||||
tags = <1>{},
|
||||
text = ""
|
||||
}, {
|
||||
tags = <table 1>,
|
||||
text = "c"
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
5
test/tests/remove trailing spaces.ans
Normal file
5
test/tests/remove trailing spaces.ans
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
a
|
||||
|
||||
b
|
||||
|
||||
{" "}c
|
||||
34
test/tests/remove trailing spaces.lua
Normal file
34
test/tests/remove trailing spaces.lua
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
local _={}
|
||||
_[14]={}
|
||||
_[13]={}
|
||||
_[12]={}
|
||||
_[11]={tags=_[14],text="c"}
|
||||
_[10]={tags=_[14],text=" "}
|
||||
_[9]={tags=_[13],text="b"}
|
||||
_[8]={tags=_[12],text="a"}
|
||||
_[7]={_[10],_[11]}
|
||||
_[6]={_[9]}
|
||||
_[5]={_[8]}
|
||||
_[4]={"return"}
|
||||
_[3]={"text",_[7]}
|
||||
_[2]={"text",_[6]}
|
||||
_[1]={"text",_[5]}
|
||||
return {_[1],_[2],_[3],_[4]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "a"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "b"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = <1>{},
|
||||
text = " "
|
||||
}, {
|
||||
tags = <table 1>,
|
||||
text = "c"
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
$ f
|
||||
# "a":"a"
|
||||
a
|
||||
~ 1 # "b":"b"
|
||||
§ p
|
||||
b # "c":"c"
|
||||
~ 1 # "x":"x"
|
||||
# "b":"b"
|
||||
§ p
|
||||
b # "c":"c"
|
||||
|
||||
c
|
||||
c
|
||||
|
||||
d
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ expression {"{"a"}"}
|
|||
|
||||
quote {"\""}
|
||||
|
||||
other codes {"\n"} {"\\"} {"\t"}
|
||||
other codes {"\n"} {"\\"} {"\t"} \{braces}
|
||||
|
||||
{"escaping expressions {"a"+"bc"} and stuff \\ and quotes \""}
|
||||
{"escaping expressions {"a"+"bc"} and \{stuff} \\ and quotes \""}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,22 @@
|
|||
local _={}
|
||||
_[25]={}
|
||||
_[24]={}
|
||||
_[23]={}
|
||||
_[22]={}
|
||||
_[21]={}
|
||||
_[20]={tags=_[24],text="escaping expressions abc and stuff \\ and quotes \""}
|
||||
_[19]={tags=_[23],text="\9"}
|
||||
_[18]={tags=_[23],text=" "}
|
||||
_[17]={tags=_[23],text="\\"}
|
||||
_[16]={tags=_[23],text=" "}
|
||||
_[15]={tags=_[23],text="\n"}
|
||||
_[14]={tags=_[23],text="other codes "}
|
||||
_[13]={tags=_[22],text="\""}
|
||||
_[12]={tags=_[22],text="quote "}
|
||||
_[11]={tags=_[21],text="a"}
|
||||
_[10]={tags=_[21],text="expression "}
|
||||
_[9]={_[20]}
|
||||
_[8]={_[14],_[15],_[16],_[17],_[18],_[19]}
|
||||
_[21]={text="escaping expressions abc and {stuff} \\ and quotes \"",tags=_[25]}
|
||||
_[20]={text=" {braces}",tags=_[24]}
|
||||
_[19]={text="\9",tags=_[24]}
|
||||
_[18]={text=" ",tags=_[24]}
|
||||
_[17]={text="\\",tags=_[24]}
|
||||
_[16]={text=" ",tags=_[24]}
|
||||
_[15]={text="\n",tags=_[24]}
|
||||
_[14]={text="other codes ",tags=_[24]}
|
||||
_[13]={text="\"",tags=_[23]}
|
||||
_[12]={text="quote ",tags=_[23]}
|
||||
_[11]={text="a",tags=_[22]}
|
||||
_[10]={text="expression ",tags=_[22]}
|
||||
_[9]={_[21]}
|
||||
_[8]={_[14],_[15],_[16],_[17],_[18],_[19],_[20]}
|
||||
_[7]={_[12],_[13]}
|
||||
_[6]={_[10],_[11]}
|
||||
_[5]={"return"}
|
||||
|
|
@ -57,10 +58,13 @@ return {_[1],_[2],_[3],_[4],_[5]}
|
|||
}, {
|
||||
tags = <table 1>,
|
||||
text = "\t"
|
||||
}, {
|
||||
tags = <table 1>,
|
||||
text = " {braces}"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = 'escaping expressions abc and stuff \\ and quotes "'
|
||||
text = 'escaping expressions abc and {stuff} \\ and quotes "'
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
12
test/tests/subtext.ans
Normal file
12
test/tests/subtext.ans
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
$ button
|
||||
A # 2:2
|
||||
|
||||
Press
|
||||
A # 5
|
||||
to jump.
|
||||
|
||||
Press [A#5] to jump.
|
||||
|
||||
Press [{button}#1] to jump.
|
||||
|
||||
Press [-[button#3:3]-#1] to jump.
|
||||
86
test/tests/subtext.lua
Normal file
86
test/tests/subtext.lua
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
local _={}
|
||||
_[33]={1,[3]=3}
|
||||
_[32]={1}
|
||||
_[31]={}
|
||||
_[30]={1,2}
|
||||
_[29]={}
|
||||
_[28]={5}
|
||||
_[27]={}
|
||||
_[26]={}
|
||||
_[25]={5}
|
||||
_[24]={}
|
||||
_[23]={tags=_[31],text=" to jump."}
|
||||
_[22]={tags=_[32],text="-"}
|
||||
_[21]={tags=_[33],text="button"}
|
||||
_[20]={tags=_[32],text="-"}
|
||||
_[19]={tags=_[31],text="Press "}
|
||||
_[18]={tags=_[29],text="to jump."}
|
||||
_[17]={tags=_[30],text="A "}
|
||||
_[16]={tags=_[29],text="Press "}
|
||||
_[15]={tags=_[27],text=" to jump."}
|
||||
_[14]={tags=_[28],text="A"}
|
||||
_[13]={tags=_[27],text="Press "}
|
||||
_[12]={tags=_[26],text="to jump."}
|
||||
_[11]={tags=_[25],text="A "}
|
||||
_[10]={tags=_[24],text="Press "}
|
||||
_[9]={_[19],_[20],_[21],_[22],_[23]}
|
||||
_[8]={_[16],_[17],_[18]}
|
||||
_[7]={_[13],_[14],_[15]}
|
||||
_[6]={_[10],_[11],_[12]}
|
||||
_[5]={"return"}
|
||||
_[4]={"text",_[9]}
|
||||
_[3]={"text",_[8]}
|
||||
_[2]={"text",_[7]}
|
||||
_[1]={"text",_[6]}
|
||||
return {_[1],_[2],_[3],_[4],_[5]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "Press "
|
||||
}, {
|
||||
tags = { 5 },
|
||||
text = "A "
|
||||
}, {
|
||||
tags = {},
|
||||
text = "to jump."
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = <1>{},
|
||||
text = "Press "
|
||||
}, {
|
||||
tags = { 5 },
|
||||
text = "A"
|
||||
}, {
|
||||
tags = <table 1>,
|
||||
text = " to jump."
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = <1>{},
|
||||
text = "Press "
|
||||
}, {
|
||||
tags = { 1, 2 },
|
||||
text = "A "
|
||||
}, {
|
||||
tags = <table 1>,
|
||||
text = "to jump."
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = <1>{},
|
||||
text = "Press "
|
||||
}, {
|
||||
tags = <2>{ 1 },
|
||||
text = "-"
|
||||
}, {
|
||||
tags = { 1,
|
||||
[3] = 3
|
||||
},
|
||||
text = "button"
|
||||
}, {
|
||||
tags = <table 2>,
|
||||
text = "-"
|
||||
}, {
|
||||
tags = <table 1>,
|
||||
text = " to jump."
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
# 1
|
||||
foo
|
||||
~ 1 #
|
||||
bar
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
local _={}
|
||||
_[7]={1}
|
||||
_[6]={1}
|
||||
_[5]={tags=_[7],text="bar"}
|
||||
_[4]={tags=_[6],text="foo"}
|
||||
_[3]={_[4],_[5]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
tags = { 1 },
|
||||
text = "foo"
|
||||
}, {
|
||||
tags = { 1 },
|
||||
text = "bar"
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
# 1
|
||||
foo
|
||||
~ 1 # "a": [2,3]
|
||||
bar
|
||||
~ 1 # "b": [1,2]
|
||||
bar ~ 1 # "a": [2,3]
|
||||
|
|
|
|||
7
test/tests/tag operator.ans
Normal file
7
test/tests/tag operator.ans
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
$ f
|
||||
b
|
||||
|
||||
a {f # 5} c
|
||||
|
||||
# 2:2
|
||||
a {f # 5} c
|
||||
42
test/tests/tag operator.lua
Normal file
42
test/tests/tag operator.lua
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
local _={}
|
||||
_[15]={5,2}
|
||||
_[14]={[2]=2}
|
||||
_[13]={5}
|
||||
_[12]={}
|
||||
_[11]={tags=_[14],text=" c"}
|
||||
_[10]={tags=_[15],text="b"}
|
||||
_[9]={tags=_[14],text="a "}
|
||||
_[8]={tags=_[12],text=" c"}
|
||||
_[7]={tags=_[13],text="b"}
|
||||
_[6]={tags=_[12],text="a "}
|
||||
_[5]={_[9],_[10],_[11]}
|
||||
_[4]={_[6],_[7],_[8]}
|
||||
_[3]={"return"}
|
||||
_[2]={"text",_[5]}
|
||||
_[1]={"text",_[4]}
|
||||
return {_[1],_[2],_[3]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
tags = <1>{},
|
||||
text = "a "
|
||||
}, {
|
||||
tags = { 5 },
|
||||
text = "b"
|
||||
}, {
|
||||
tags = <table 1>,
|
||||
text = " c"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = <1>{
|
||||
[2] = 2
|
||||
},
|
||||
text = "a "
|
||||
}, {
|
||||
tags = { 5, 2 },
|
||||
text = "b"
|
||||
}, {
|
||||
tags = <table 1>,
|
||||
text = " c"
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
7
test/tests/text escaping.ans
Normal file
7
test/tests/text escaping.ans
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
expression \{a}
|
||||
|
||||
quote \"
|
||||
|
||||
other codes \n \\ \t
|
||||
|
||||
decorators \# tag \~ condition \$ fn
|
||||
38
test/tests/text escaping.lua
Normal file
38
test/tests/text escaping.lua
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
local _={}
|
||||
_[17]={}
|
||||
_[16]={}
|
||||
_[15]={}
|
||||
_[14]={}
|
||||
_[13]={tags=_[17],text="decorators # tag ~ condition $ fn"}
|
||||
_[12]={tags=_[16],text="other codes \n \\ \9"}
|
||||
_[11]={tags=_[15],text="quote \""}
|
||||
_[10]={tags=_[14],text="expression {a}"}
|
||||
_[9]={_[13]}
|
||||
_[8]={_[12]}
|
||||
_[7]={_[11]}
|
||||
_[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 = "expression {a}"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = 'quote "'
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "other codes \n \\ \t"
|
||||
} } }
|
||||
{ "text", { {
|
||||
tags = {},
|
||||
text = "decorators # tag ~ condition $ fn"
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
Loading…
Add table
Add a link
Reference in a new issue