diff --git a/anselme/state/calling_environment_manager.lua b/anselme/state/calling_environment_manager.lua new file mode 100644 index 0000000..a78289d --- /dev/null +++ b/anselme/state/calling_environment_manager.lua @@ -0,0 +1,38 @@ +local class = require("anselme.lib.class") + +local ast = require("anselme.ast") +local Identifier + +-- stack of resumable contexts +local calling_env_identifier, calling_env_symbol + +local calling_environment_manager = class { + init = false, + + push = function(self, state, calling_environment) + state.scope:push_partial(calling_env_identifier) + state.scope:define(calling_env_symbol, calling_environment) + end, + pop = function(self, state) + state.scope:pop() + end, + + get_level = function(self, state, level) + local env = state.scope:capture() + while level > 0 do + assert(env:defined(state, calling_env_identifier), "no calling function") + env = env:get(state, calling_env_identifier) + level = level - 1 + end + return env + end, +} + +package.loaded[...] = calling_environment_manager + +Identifier = ast.Identifier + +calling_env_identifier = Identifier:new("_calling_environment") +calling_env_symbol = calling_env_identifier:to_symbol() + +return calling_environment_manager diff --git a/test/results/constrained variable assignement.ans b/test/results/constrained variable assignement.ans index 8dd7d76..8944dc7 100644 --- a/test/results/constrained variable assignement.ans +++ b/test/results/constrained variable assignement.ans @@ -4,7 +4,7 @@ --- text --- | {}"" {}"type(\"kg\", 12)" {}"" | --- error --- -type check failure for weigh; 32 does not satisfy ($(x) type(x) == t) +type check failure for weigh; 32 does not satisfy $(x) type(x) == t ↳ from test/tests/constrained variable assignement.ans:9:7 in assignment: weigh = 32 ↳ from ? in block: :weigh::is("kg") = type(5, "kg")… --# saved #-- diff --git a/test/results/default attached block.ans b/test/results/default attached block.ans new file mode 100644 index 0000000..ad5d9b4 --- /dev/null +++ b/test/results/default attached block.ans @@ -0,0 +1,7 @@ +--# run #-- +--- text --- +| {}"ok" | +--- return --- +() +--# saved #-- +{"fn.checkpoint":false, "fn.run":1} \ No newline at end of file diff --git a/test/results/exported variable nested.ans b/test/results/exported variable nested.ans index 709f167..111e816 100644 --- a/test/results/exported variable nested.ans +++ b/test/results/exported variable nested.ans @@ -5,7 +5,7 @@ --- text --- | {}"" {}"42" {}"" | --- error --- -identifier "z" is undefined in branch 1228bcf1-5118-4955-10048-8fda790007be +identifier "z" is undefined in branch cf017f8a-7c86-4871-109af-6658231331e6 ↳ from test/tests/exported variable nested.ans:12:3 in identifier: z ↳ from test/tests/exported variable nested.ans:12:1 in text interpolation: | {z} | ↳ from test/tests/exported variable nested.ans:12:1 in translatable: | {z} | diff --git a/test/results/function args arity check fail.ans b/test/results/function args arity check fail.ans index bb3da2b..dea819f 100644 --- a/test/results/function args arity check fail.ans +++ b/test/results/function args arity check fail.ans @@ -1,6 +1,6 @@ --# run #-- --- error --- -can't call closure ($(a, b) _): expected 2 arguments, received 1 +can't call function $(a, b) _: expected 2 arguments, received 1 ↳ from test/tests/function args arity check fail.ans:4:2 in call: f("ok") ↳ from ? in block: :f = ($(a, b) _)… --# saved #-- diff --git a/test/results/function random.ans b/test/results/function random.ans index e40ffba..e23a436 100644 --- a/test/results/function random.ans +++ b/test/results/function random.ans @@ -2,14 +2,14 @@ --- text --- | {}"c" | --- text --- -| {}"a" | ---- text --- -| {}"c" | +| {}"b" | --- text --- | {}"a" | --- text --- | {}"b" | +--- text --- +| {}"b" | --- return --- () --# saved #-- -{"a.checkpoint":false, "a.run":2, "b.checkpoint":false, "b.run":1, "c.checkpoint":false, "c.run":2} \ No newline at end of file +{"a.checkpoint":false, "a.run":1, "b.checkpoint":false, "b.run":3, "c.checkpoint":false, "c.run":1} \ No newline at end of file diff --git a/test/results/function scope wrong.ans b/test/results/function scope wrong.ans index 9148a35..2e1173b 100644 --- a/test/results/function scope wrong.ans +++ b/test/results/function scope wrong.ans @@ -1,6 +1,6 @@ --# run #-- --- error --- -identifier "b" is undefined in branch 57b4c67d-b128-4b9a-11e39-0e6612f1210e +identifier "b" is undefined in branch cf017f8a-7c86-4871-109af-6658231331e6 ↳ from test/tests/function scope wrong.ans:4:7 in identifier: b ↳ from test/tests/function scope wrong.ans:4:1 in text interpolation: | a: {b} | ↳ from test/tests/function scope wrong.ans:4:1 in translatable: | a: {b} | diff --git a/test/results/litterals.ans b/test/results/litterals.ans index 3742c16..7c68328 100644 --- a/test/results/litterals.ans +++ b/test/results/litterals.ans @@ -34,8 +34,8 @@ | {}"" {}"\"d\":[]" {}"" | --- text --- | {}"function:" | -| {}"" {}"($() 12)" {}"" | -| {}"" {}"($(x) x)" {}"" | +| {}"" {}"$() 12" {}"" | +| {}"" {}"$(x) x" {}"" | --- return --- () --# saved #-- diff --git a/test/results/merge nested mutable error bis.ans b/test/results/merge nested mutable error bis.ans index d220f2e..13f9096 100644 --- a/test/results/merge nested mutable error bis.ans +++ b/test/results/merge nested mutable error bis.ans @@ -1,25 +1,21 @@ --# run #-- --- error --- -abort +abort ↳ from test/tests/merge nested mutable error bis.ans:14:7 in call: error("abort") ↳ from test/tests/merge nested mutable error bis.ans:3:1 in block: insert(a, b)… ↳ from test/tests/merge nested mutable error bis.ans:3:18 in call: _ ↳ from test/tests/merge nested mutable error bis.ans:3:17 in return boundary: _ - ↳ from test/tests/merge nested mutable error bis.ans:3:17 in return boundary: _ ↳ from script.ans:29:6 in call: fn! ↳ from script.ans:27:3 in block: resumed from = ()… - ↳ from script.ans:27:5 in call: _ - ↳ from script.ans:27:3 in call: ~_ - ↳ from script.ans:27:3 in partial scope: ~_… - ↳ from script.ans:23:2 in block: fn . "current checkpoint" ~… + ↳ from script.ans:27:7 in call: else! + ↳ from script.ans:27:3 in partial scope: else!… + ↳ from script.ans:23:2 in block: if(fn . "current checkpoint")… ↳ from script.ans:23:9 in call: _ ↳ from script.ans:23:7 in return boundary: _ - ↳ from script.ans:23:7 in return boundary: _ ↳ from script.ans:37:9 in call: value(s)! ↳ from script.ans:36:1 in block: value(s)! ↳ from script.ans:36:20 in call: _ ↳ from script.ans:36:1 in return boundary: _ - ↳ from script.ans:36:1 in return boundary: _ ↳ from test/tests/merge nested mutable error bis.ans:19:2 in call: f! ↳ from ? in block: :a = *[1]… --# post run check #-- diff --git a/test/results/merge nested mutable error.ans b/test/results/merge nested mutable error.ans index 4f6f7c6..1b3be88 100644 --- a/test/results/merge nested mutable error.ans +++ b/test/results/merge nested mutable error.ans @@ -1,25 +1,21 @@ --# run #-- --- error --- -abort +abort ↳ from test/tests/merge nested mutable error.ans:14:7 in call: error("abort") ↳ from test/tests/merge nested mutable error.ans:3:1 in block: insert(a, b)… ↳ from test/tests/merge nested mutable error.ans:3:18 in call: _ ↳ from test/tests/merge nested mutable error.ans:3:17 in return boundary: _ - ↳ from test/tests/merge nested mutable error.ans:3:17 in return boundary: _ ↳ from script.ans:29:6 in call: fn! ↳ from script.ans:27:3 in block: resumed from = ()… - ↳ from script.ans:27:5 in call: _ - ↳ from script.ans:27:3 in call: ~_ - ↳ from script.ans:27:3 in partial scope: ~_… - ↳ from script.ans:23:2 in block: fn . "current checkpoint" ~… + ↳ from script.ans:27:7 in call: else! + ↳ from script.ans:27:3 in partial scope: else!… + ↳ from script.ans:23:2 in block: if(fn . "current checkpoint")… ↳ from script.ans:23:9 in call: _ ↳ from script.ans:23:7 in return boundary: _ - ↳ from script.ans:23:7 in return boundary: _ ↳ from script.ans:37:9 in call: value(s)! ↳ from script.ans:36:1 in block: value(s)! ↳ from script.ans:36:20 in call: _ ↳ from script.ans:36:1 in return boundary: _ - ↳ from script.ans:36:1 in return boundary: _ ↳ from test/tests/merge nested mutable error.ans:19:2 in call: f! ↳ from ? in block: :a = *[1]… --# post run check #-- diff --git a/test/results/scope checkpoint mutable bis error.ans b/test/results/scope checkpoint mutable bis error.ans index fa4883d..867c4b9 100644 --- a/test/results/scope checkpoint mutable bis error.ans +++ b/test/results/scope checkpoint mutable bis error.ans @@ -14,21 +14,18 @@ --- text --- | {}"CHECK 2" | --- error --- -t +t ↳ from test/tests/scope checkpoint mutable bis error.ans:32:7 in call: error("t") ↳ from test/tests/scope checkpoint mutable bis error.ans:7:1 in block: insert(t, len(l) + 1)… ↳ from test/tests/scope checkpoint mutable bis error.ans:7:8 in call: _ ↳ from test/tests/scope checkpoint mutable bis error.ans:7:1 in return boundary: _ - ↳ from test/tests/scope checkpoint mutable bis error.ans:7:1 in return boundary: _ ↳ from test/tests/scope checkpoint mutable bis error.ans:19:4 in call: f(t) ↳ from test/tests/scope checkpoint mutable bis error.ans:15:2 in block: | REC |… - ↳ from test/tests/scope checkpoint mutable bis error.ans:15:10 in call: _ - ↳ from test/tests/scope checkpoint mutable bis error.ans:15:8 in call: n < 1 ~ _ - ↳ from test/tests/scope checkpoint mutable bis error.ans:15:2 in partial scope: n < 1 ~… + ↳ from test/tests/scope checkpoint mutable bis error.ans:15:4 in call: if(n < 1) + ↳ from test/tests/scope checkpoint mutable bis error.ans:15:2 in partial scope: if(n < 1)… ↳ from test/tests/scope checkpoint mutable bis error.ans:7:1 in block: insert(t, len(l) + 1)… ↳ from test/tests/scope checkpoint mutable bis error.ans:7:8 in call: _ ↳ from test/tests/scope checkpoint mutable bis error.ans:7:1 in return boundary: _ - ↳ from test/tests/scope checkpoint mutable bis error.ans:7:1 in return boundary: _ ↳ from test/tests/scope checkpoint mutable bis error.ans:41:2 in call: f(l) ↳ from ? in block: :x = *[99]… --# post run check #-- diff --git a/test/results/scope checkpoint mutable error.ans b/test/results/scope checkpoint mutable error.ans index 451c6fc..3b6de4d 100644 --- a/test/results/scope checkpoint mutable error.ans +++ b/test/results/scope checkpoint mutable error.ans @@ -10,21 +10,18 @@ --- text --- | {}"CHECK" | --- error --- -t +t ↳ from test/tests/scope checkpoint mutable error.ans:23:7 in call: error("t") ↳ from test/tests/scope checkpoint mutable error.ans:5:1 in block: insert(t, len(l) + 1)… ↳ from test/tests/scope checkpoint mutable error.ans:5:8 in call: _ ↳ from test/tests/scope checkpoint mutable error.ans:5:1 in return boundary: _ - ↳ from test/tests/scope checkpoint mutable error.ans:5:1 in return boundary: _ ↳ from test/tests/scope checkpoint mutable error.ans:17:4 in call: f(t) ↳ from test/tests/scope checkpoint mutable error.ans:13:2 in block: | REC |… - ↳ from test/tests/scope checkpoint mutable error.ans:13:10 in call: _ - ↳ from test/tests/scope checkpoint mutable error.ans:13:8 in call: n < 1 ~ _ - ↳ from test/tests/scope checkpoint mutable error.ans:13:2 in partial scope: n < 1 ~… + ↳ from test/tests/scope checkpoint mutable error.ans:13:4 in call: if(n < 1) + ↳ from test/tests/scope checkpoint mutable error.ans:13:2 in partial scope: if(n < 1)… ↳ from test/tests/scope checkpoint mutable error.ans:5:1 in block: insert(t, len(l) + 1)… ↳ from test/tests/scope checkpoint mutable error.ans:5:8 in call: _ ↳ from test/tests/scope checkpoint mutable error.ans:5:1 in return boundary: _ - ↳ from test/tests/scope checkpoint mutable error.ans:5:1 in return boundary: _ ↳ from test/tests/scope checkpoint mutable error.ans:32:2 in call: f(l) ↳ from ? in block: :l = *[1]… --# post run check #-- diff --git a/test/results/scope checkpoint mutable ter error.ans b/test/results/scope checkpoint mutable ter error.ans index 664f024..90ce1d0 100644 --- a/test/results/scope checkpoint mutable ter error.ans +++ b/test/results/scope checkpoint mutable ter error.ans @@ -14,21 +14,18 @@ --- text --- | {}"CHECK 2" | --- error --- -t +t ↳ from test/tests/scope checkpoint mutable ter error.ans:34:7 in call: error("t") ↳ from test/tests/scope checkpoint mutable ter error.ans:7:1 in block: insert(t, len(l) + 1)… ↳ from test/tests/scope checkpoint mutable ter error.ans:7:8 in call: _ ↳ from test/tests/scope checkpoint mutable ter error.ans:7:1 in return boundary: _ - ↳ from test/tests/scope checkpoint mutable ter error.ans:7:1 in return boundary: _ ↳ from test/tests/scope checkpoint mutable ter error.ans:19:4 in call: f(t) ↳ from test/tests/scope checkpoint mutable ter error.ans:15:2 in block: | REC |… - ↳ from test/tests/scope checkpoint mutable ter error.ans:15:10 in call: _ - ↳ from test/tests/scope checkpoint mutable ter error.ans:15:8 in call: n < 1 ~ _ - ↳ from test/tests/scope checkpoint mutable ter error.ans:15:2 in partial scope: n < 1 ~… + ↳ from test/tests/scope checkpoint mutable ter error.ans:15:4 in call: if(n < 1) + ↳ from test/tests/scope checkpoint mutable ter error.ans:15:2 in partial scope: if(n < 1)… ↳ from test/tests/scope checkpoint mutable ter error.ans:7:1 in block: insert(t, len(l) + 1)… ↳ from test/tests/scope checkpoint mutable ter error.ans:7:8 in call: _ ↳ from test/tests/scope checkpoint mutable ter error.ans:7:1 in return boundary: _ - ↳ from test/tests/scope checkpoint mutable ter error.ans:7:1 in return boundary: _ ↳ from test/tests/scope checkpoint mutable ter error.ans:43:2 in call: f(l) ↳ from ? in block: :x = *[99]… --# post run check #-- diff --git a/test/results/text buffer with tags.ans b/test/results/text buffer with tags.ans index 55fbbfa..e3ca5d1 100644 --- a/test/results/text buffer with tags.ans +++ b/test/results/text buffer with tags.ans @@ -2,6 +2,6 @@ --- text --- | {1:1}"lol" | --- return --- -@| {}"a " {1:2}"d" {}" " {1:3}"t" {}" b" | +| {}"a " {1:2}"d" {}" " {1:3}"t" {}" b" | --# saved #-- {} \ No newline at end of file diff --git a/test/results/text buffer.ans b/test/results/text buffer.ans index 7d7c971..2479a22 100644 --- a/test/results/text buffer.ans +++ b/test/results/text buffer.ans @@ -2,6 +2,6 @@ --- text --- | {}"lol" | --- return --- -@| {}"a " {}"d" {}" b" | +| {}"a " {}"d" {}" b" | --# saved #-- {} \ No newline at end of file diff --git a/test/results/while break.ans b/test/results/while break.ans new file mode 100644 index 0000000..c11c779 --- /dev/null +++ b/test/results/while break.ans @@ -0,0 +1,19 @@ +--# run #-- +--- text --- +| {}"" {}"0" {}"" | +--- text --- +| {}"" {}"1" {}"" | +--- text --- +| {}"" {}"2" {}"" | +--- text --- +| {}"" {}"3" {}"" | +--- text --- +| {}"" {}"4" {}"" | +--- text --- +| {}"" {}"5" {}"" | +--- text --- +| {}"ok" | +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/while continue.ans b/test/results/while continue.ans new file mode 100644 index 0000000..af2ec2d --- /dev/null +++ b/test/results/while continue.ans @@ -0,0 +1,17 @@ +--# run #-- +--- text --- +| {}"" {}"1" {}"" | +--- text --- +| {}"" {}"2" {}"" | +--- text --- +| {}"" {}"4" {}"" | +--- text --- +| {}"" {}"5" {}"" | +--- text --- +| {}"" {}"6" {}"" | +--- text --- +| {}"ok" | +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/while loop.ans b/test/results/while loop.ans index 7364855..b0a3fca 100644 --- a/test/results/while loop.ans +++ b/test/results/while loop.ans @@ -36,6 +36,6 @@ --- text --- | {}"" {}"5" {}"" | --- return --- -@() +() --# saved #-- {} \ No newline at end of file diff --git a/test/tests/binary operator overload.ans b/test/tests/binary operator overload.ans index fccf2b3..bc811a9 100644 --- a/test/tests/binary operator overload.ans +++ b/test/tests/binary operator overload.ans @@ -1,8 +1,8 @@ :$ a - b - @"generic minus" + return("generic minus") :$ a::string - b::string - @a + " minus " + b + return(a + " minus " + b) | {2-5} diff --git a/test/tests/choice line interpolation with choice event.ans b/test/tests/choice line interpolation with choice event.ans index 42066e6..17c3587 100644 --- a/test/tests/choice line interpolation with choice event.ans +++ b/test/tests/choice line interpolation with choice event.ans @@ -3,7 +3,7 @@ :$ jump button 1 # |A | Suprise choice! |> () - @"JOIN" + return("JOIN") | Press {jump button!} to jump. |> |ok diff --git a/test/tests/choice line interpolation with event flush.ans b/test/tests/choice line interpolation with event flush.ans index 0a04f2b..456f777 100644 --- a/test/tests/choice line interpolation with event flush.ans +++ b/test/tests/choice line interpolation with event flush.ans @@ -3,7 +3,7 @@ :$ jump button 1 # | a - @"SPLIT" + return("SPLIT") | Press {jump button!} to jump. |> | ok diff --git a/test/tests/choice line interpolation with text event.ans b/test/tests/choice line interpolation with text event.ans index 6db0452..39ffe5c 100644 --- a/test/tests/choice line interpolation with text event.ans +++ b/test/tests/choice line interpolation with text event.ans @@ -1,9 +1,9 @@ :$ jump button - @1 # | A + return(1 # | A) :$ move axis 1 # | left - @" joystick" + return(" joystick") | Press {jump button!} to jump. |> |ok diff --git a/test/tests/choice with decorators.ans b/test/tests/choice with decorators.ans index effccdc..bf5a286 100644 --- a/test/tests/choice with decorators.ans +++ b/test/tests/choice with decorators.ans @@ -1,16 +1,17 @@ -1 ~ | a |> - | -> a +if(1) + | a |> + | -> a | b |> | -> b :@choice = 1 -1 ~ | a |> +if(1, $| a |> _) | -> a | b |> | -> b choice = 2 -() ~ | a |> +if((), $| a |> _) | -> a | b |> | -> b @@ -22,13 +23,13 @@ choice = 1 | -> b choice = 2 -12 # () ~ | a |> +12 # if((), $| a |> _) | -> a 3 # | b |> | -> b choice = 1 -12 # 1 ~ | a |> +12 # if(1, $| a |> _) | -> a 3 # | b |> | -> b diff --git a/test/tests/condition decorator.ans b/test/tests/condition decorator.ans index e41d320..22a131f 100644 --- a/test/tests/condition decorator.ans +++ b/test/tests/condition decorator.ans @@ -1,3 +1,3 @@ -() ~ |ko -1 ~ |ok -1 ~ |ok bis \ No newline at end of file +if((), $|ko) +if(1, $|ok) +if(1, $|ok bis) \ No newline at end of file diff --git a/test/tests/condition else false.ans b/test/tests/condition else false.ans index 81acd23..f764f9a 100644 --- a/test/tests/condition else false.ans +++ b/test/tests/condition else false.ans @@ -1,6 +1,6 @@ :a = 5 -a == 2 ~ +if(a == 2) |ko -~ +else! |ok diff --git a/test/tests/condition else true.ans b/test/tests/condition else true.ans index ad257f4..92fcd8c 100644 --- a/test/tests/condition else true.ans +++ b/test/tests/condition else true.ans @@ -1,6 +1,6 @@ :a = 5 -a == 5 ~ +if(a == 5) |ok -~ +else! |ko diff --git a/test/tests/condition elseif false.ans b/test/tests/condition elseif false.ans index 4096e9a..7d225ad 100644 --- a/test/tests/condition elseif false.ans +++ b/test/tests/condition elseif false.ans @@ -1,8 +1,8 @@ :a = 5 -a == 2 ~ +if(a == 2) |ko -~ () ~ +else if(()) |ko -~ +else! |ok diff --git a/test/tests/condition elseif true.ans b/test/tests/condition elseif true.ans index f9ef26e..b3ee896 100644 --- a/test/tests/condition elseif true.ans +++ b/test/tests/condition elseif true.ans @@ -1,8 +1,8 @@ :a = 5 -a == 2 ~ +if(a == 2) |ko -~ 1 ~ +else if(1) |ok -~ +else! |ko diff --git a/test/tests/condition false.ans b/test/tests/condition false.ans index 8f06b16..105a78d 100644 --- a/test/tests/condition false.ans +++ b/test/tests/condition false.ans @@ -1,4 +1,4 @@ :a = 5 -a == 2 ~ +if(a == 2) |ko diff --git a/test/tests/condition operator.ans b/test/tests/condition operator.ans index 2a10c02..f85c81b 100644 --- a/test/tests/condition operator.ans +++ b/test/tests/condition operator.ans @@ -1,6 +1,6 @@ :$ f - @|b + return(|b) -|a {5 ~ f!} c +|a {if(5, f)} c -|a {() ~ f!} c +|a {if((), f)} c diff --git a/test/tests/condition true.ans b/test/tests/condition true.ans index 22b915d..89756e1 100644 --- a/test/tests/condition true.ans +++ b/test/tests/condition true.ans @@ -1,4 +1,4 @@ :a = 5 -a == 5 ~ +if(a == 5) |ok diff --git a/test/tests/custom text formatting.ans b/test/tests/custom text formatting.ans index 628b36e..ee5cf6b 100644 --- a/test/tests/custom text formatting.ans +++ b/test/tests/custom text formatting.ans @@ -2,10 +2,10 @@ :$ format(p::is(person)) p = p!value - @"Name: {p("name")}\nAge: {p("age")}" + return("Name: {p("name")}\nAge: {p("age")}") :$ Person(name, age) - @{"name":name, "age":age}!type(person) + return({"name":name, "age":age}!type(person)) :abject = Person("Darmanin", 38) diff --git a/test/tests/default attached block.ans b/test/tests/default attached block.ans new file mode 100644 index 0000000..1ad6f2f --- /dev/null +++ b/test/tests/default attached block.ans @@ -0,0 +1,4 @@ +:fn = "fn"!script + |ok + +fn! diff --git a/test/tests/function assignement.ans b/test/tests/function assignement.ans index 798475e..321ebca 100644 --- a/test/tests/function assignement.ans +++ b/test/tests/function assignement.ans @@ -1,7 +1,7 @@ :a = 5 :$ f(p) - @a + return(a) :$ f(p) = v |v={v} diff --git a/test/tests/function definition.ans b/test/tests/function definition.ans index 3f361e4..049713d 100644 --- a/test/tests/function definition.ans +++ b/test/tests/function definition.ans @@ -1,7 +1,7 @@ :f = $(x)x*x :$g(x) - @x*x + return(x*x) |{f(5)} = {g(5)} diff --git a/test/tests/function return exit function nested.ans b/test/tests/function return exit function nested.ans index c2b102e..271eebf 100644 --- a/test/tests/function return exit function nested.ans +++ b/test/tests/function return exit function nested.ans @@ -1,8 +1,8 @@ :$ hey :@$ foo - @2 - @3 - @5 + return(2) + return(3) + return(5) |u |{hey!} diff --git a/test/tests/function return exit function.ans b/test/tests/function return exit function.ans index 5e7ad2b..5056c1a 100644 --- a/test/tests/function return exit function.ans +++ b/test/tests/function return exit function.ans @@ -1,6 +1,6 @@ :$ hey - @5 + return(5) |a - @2 + return(2) |{hey!} \ No newline at end of file diff --git a/test/tests/function return nested.ans b/test/tests/function return nested.ans index 17bc913..9890884 100644 --- a/test/tests/function return nested.ans +++ b/test/tests/function return nested.ans @@ -1,7 +1,7 @@ :$ hey :@$ foo - @2 - @5 + return(2) + return(5) |{hey!} |{hey.foo!} \ No newline at end of file diff --git a/test/tests/function return.ans b/test/tests/function return.ans index 712461f..5e9fc6f 100644 --- a/test/tests/function return.ans +++ b/test/tests/function return.ans @@ -1,4 +1,4 @@ :$ hey - @5 + return(5) |{hey!} \ No newline at end of file diff --git a/test/tests/function scoped mutable.ans b/test/tests/function scoped mutable.ans index 1084243..0696b4d 100644 --- a/test/tests/function scoped mutable.ans +++ b/test/tests/function scoped mutable.ans @@ -11,7 +11,7 @@ |before recursion {c}: {a} - n < 5 ~ + if(n < 5) f(c+1) |after recursion {c}: {a} @@ -29,7 +29,7 @@ f! |before recursion {c}: {a} - n < 5 ~ + if(n < 5) g(c+1, a) |after recursion {c}: {a} diff --git a/test/tests/function scoped recursive.ans b/test/tests/function scoped recursive.ans index b5241ac..22cdc12 100644 --- a/test/tests/function scoped recursive.ans +++ b/test/tests/function scoped recursive.ans @@ -11,7 +11,7 @@ |before recursion {c}: {a} - n < 5 ~ + if(n < 5) f(c+1) |after recursion {c}: {a} diff --git a/test/tests/function selection.ans b/test/tests/function selection.ans index 4973f67..cd2ecb1 100644 --- a/test/tests/function selection.ans +++ b/test/tests/function selection.ans @@ -1,9 +1,9 @@ :$ a(x::number) - @x + 2 + return(x + 2) :$ x :$ a(x::string) - @x + "heh" + return(x + "heh") |{a("plop")} diff --git a/test/tests/function type dispatch with default.ans b/test/tests/function type dispatch with default.ans index b36e04f..3cca2c4 100644 --- a/test/tests/function type dispatch with default.ans +++ b/test/tests/function type dispatch with default.ans @@ -11,10 +11,10 @@ fn(5) fn() :$ g(n="s", a::number=5) - @"gn" + return("gn") :$ g(n="s", a::string="lol") - @"gs" + return("gs") |{g(n="k", a="l")} |{g(n="k", a=1)} diff --git a/test/tests/lazy boolean operators.ans b/test/tests/lazy boolean operators.ans index 631d361..23949bf 100644 --- a/test/tests/lazy boolean operators.ans +++ b/test/tests/lazy boolean operators.ans @@ -1,10 +1,10 @@ :$ a |a - @1 + return(1) :$ b |b - @() + return(()) |{a! & b!} = a b () diff --git a/test/tests/loop decorator.ans b/test/tests/loop decorator.ans index 1b3dcfb..9f7547f 100644 --- a/test/tests/loop decorator.ans +++ b/test/tests/loop decorator.ans @@ -1,5 +1,5 @@ :i = 0 -(i += 1; i <= 10) ~? (| {i}\n)! +while($()(i += 1; i <= 10), $| {i}\n |!) |{i} diff --git a/test/tests/named arguments.ans b/test/tests/named arguments.ans index c97cd42..03613bc 100644 --- a/test/tests/named arguments.ans +++ b/test/tests/named arguments.ans @@ -1,4 +1,4 @@ :$ f(a, b, c) - @a + b + c + return(a + b + c) |{f("a", "b", "c")} = {f(a="a", b="b", c="c")} = {f(c="c", a="a", b="b")} diff --git a/test/tests/nested conditions.ans b/test/tests/nested conditions.ans index 2174744..3478d0c 100644 --- a/test/tests/nested conditions.ans +++ b/test/tests/nested conditions.ans @@ -1,19 +1,19 @@ -1 ~ +if(1) |yes - () ~ + if(()) |no -~ +else! |nope - 1 ~ + if(1) |niet - () ~ + if(()) |still no -~ +else! |nein -() ~ +if(()) |nah -~ +else! |ye - ~ + else! |da diff --git a/test/tests/nested flush.ans b/test/tests/nested flush.ans index 087359d..9820bd8 100644 --- a/test/tests/nested flush.ans +++ b/test/tests/nested flush.ans @@ -1,18 +1,18 @@ -1 ~ +if(1) |a |b -1 ~ +if(1) |c |d -1 ~ +if(1) |e | f |> () :@choice = 1 -1 ~ +if(1) |g | h |> () diff --git a/test/tests/optional arguments.ans b/test/tests/optional arguments.ans index 9f78454..41ca0c9 100644 --- a/test/tests/optional arguments.ans +++ b/test/tests/optional arguments.ans @@ -1,4 +1,4 @@ :$ f(a, b, c="c") - @a + b + c + return(a + b + c) |{f("a", "b")} = {f("a", "b", "c")} = {f(b="b", a="a")} diff --git a/test/tests/resume from paragraph restore tags.ans b/test/tests/resume from paragraph restore tags.ans index e854f01..c7c16a0 100644 --- a/test/tests/resume from paragraph restore tags.ans +++ b/test/tests/resume from paragraph restore tags.ans @@ -1,7 +1,7 @@ -:f = "f"!script($_) +:f = "f"!script "a":"a" # |a - 1 ~ "x":"x" # + if(1, $()("x":"x" # _)) "b":"b" # #p!checkpoint($_) "c":"c"# |b diff --git a/test/tests/resume from paragraph with nested choice.ans b/test/tests/resume from paragraph with nested choice.ans index bee2729..ebec961 100644 --- a/test/tests/resume from paragraph with nested choice.ans +++ b/test/tests/resume from paragraph with nested choice.ans @@ -45,7 +45,7 @@ g! g!from(#p) :h = "h"!script($_) - 1 ~ + if(1) | a |> |-> a #p!checkpoint @@ -76,7 +76,7 @@ h!from(#p) |-> ab | b |> |-> b - 1 ~ + if(1) | c |> |-> c diff --git a/test/tests/resume from paragraph with nested condition.ans b/test/tests/resume from paragraph with nested condition.ans index 9cf1cce..ee429a4 100644 --- a/test/tests/resume from paragraph with nested condition.ans +++ b/test/tests/resume from paragraph with nested condition.ans @@ -1,8 +1,8 @@ :f = "f"!script($_) - 1 ~ + if(1) #p!checkpoint |x - ~ + else! |y f! @@ -10,10 +10,10 @@ f! f!from(#p) :g = "g"!script($_) - () ~ + if(()) #p!checkpoint |x - ~ + else! |y g! diff --git a/test/tests/return children.ans b/test/tests/return children.ans index 5e93338..fca9f2d 100644 --- a/test/tests/return children.ans +++ b/test/tests/return children.ans @@ -1,13 +1,13 @@ :$ fn :i=0 - @ + return(_) i=50 i | {fn!} = 50 :$ g - @ - @3 + return(_) + return(3) | {g!} = 3 diff --git a/test/tests/return in choice.ans b/test/tests/return in choice.ans index b2f4828..cf95753 100644 --- a/test/tests/return in choice.ans +++ b/test/tests/return in choice.ans @@ -1,10 +1,10 @@ :$ f | a |> | x - @1 + return(1) | y - @2 + return(2) -f! == 2 ~ +if(f! == 2) :@choice = 1 | Yes. diff --git a/test/tests/scope checkpoint mutable bis error.ans b/test/tests/scope checkpoint mutable bis error.ans index 978fbde..80b7ee3 100644 --- a/test/tests/scope checkpoint mutable bis error.ans +++ b/test/tests/scope checkpoint mutable bis error.ans @@ -12,7 +12,7 @@ |CHECK merge branch! - n < 1 ~ + if(n < 1) |REC n += 1 diff --git a/test/tests/scope checkpoint mutable bis.ans b/test/tests/scope checkpoint mutable bis.ans index 92d48c7..7f0c80c 100644 --- a/test/tests/scope checkpoint mutable bis.ans +++ b/test/tests/scope checkpoint mutable bis.ans @@ -12,7 +12,7 @@ |CHECK merge branch! - n < 1 ~ + if(n < 1) |REC n += 1 diff --git a/test/tests/scope checkpoint mutable error.ans b/test/tests/scope checkpoint mutable error.ans index 5e24d48..2767655 100644 --- a/test/tests/scope checkpoint mutable error.ans +++ b/test/tests/scope checkpoint mutable error.ans @@ -10,7 +10,7 @@ |CHECK merge branch! - n < 1 ~ + if(n < 1) |REC n += 1 diff --git a/test/tests/scope checkpoint mutable ter error.ans b/test/tests/scope checkpoint mutable ter error.ans index 2e379d0..b2fd7a3 100644 --- a/test/tests/scope checkpoint mutable ter error.ans +++ b/test/tests/scope checkpoint mutable ter error.ans @@ -12,7 +12,7 @@ |CHECK merge branch! - n < 1 ~ + if(n < 1) |REC n += 1 diff --git a/test/tests/scope checkpoint mutable ter.ans b/test/tests/scope checkpoint mutable ter.ans index 77d7e41..df448d6 100644 --- a/test/tests/scope checkpoint mutable ter.ans +++ b/test/tests/scope checkpoint mutable ter.ans @@ -12,7 +12,7 @@ |CHECK merge branch! - n < 1 ~ + if(n < 1) |REC n += 1 diff --git a/test/tests/scope checkpoint mutable.ans b/test/tests/scope checkpoint mutable.ans index 788697c..c537c46 100644 --- a/test/tests/scope checkpoint mutable.ans +++ b/test/tests/scope checkpoint mutable.ans @@ -10,7 +10,7 @@ |CHECK merge branch! - n < 1 ~ + if(n < 1) |REC n += 1 diff --git a/test/tests/tag decorator nested.ans b/test/tests/tag decorator nested.ans index 6800183..ada213a 100644 --- a/test/tests/tag decorator nested.ans +++ b/test/tests/tag decorator nested.ans @@ -1,4 +1,4 @@ 1 # |foo - 1 ~ "b":[1,2] # - 1 ~ "a":[2,3] # | bar + if(1, $()("b":[1,2] # _)) + if(1, $()("a":[2,3] # | bar)) diff --git a/test/tests/tag operator.ans b/test/tests/tag operator.ans index 5dada34..ff1e3f0 100644 --- a/test/tests/tag operator.ans +++ b/test/tests/tag operator.ans @@ -1,5 +1,5 @@ :$ f - @"b" + return("b") |a {5 # |{f!}} c diff --git a/test/tests/text buffer with tags.ans b/test/tests/text buffer with tags.ans index 4fce653..cf2400f 100644 --- a/test/tests/text buffer with tags.ans +++ b/test/tests/text buffer with tags.ans @@ -1,8 +1,8 @@ :$ f 1 # | lol - @2 # |d + return(2 # |d) :a = |a {f!} {3#|t} b -@a +return(a) diff --git a/test/tests/text buffer.ans b/test/tests/text buffer.ans index 22cbdb3..c225d4c 100644 --- a/test/tests/text buffer.ans +++ b/test/tests/text buffer.ans @@ -1,8 +1,8 @@ :$ f |lol - @|d + return(|d) :a = |a {f!} b -@a +return(a) diff --git a/test/tests/text line interpolation with choice event.ans b/test/tests/text line interpolation with choice event.ans index 24b9642..5e95110 100644 --- a/test/tests/text line interpolation with choice event.ans +++ b/test/tests/text line interpolation with choice event.ans @@ -9,7 +9,7 @@ 1 # | left | Surprise choice! |> | ok2 - @" joystick" + return(" joystick") | Press {jump button!} to jump. diff --git a/test/tests/text line interpolation with event flush.ans b/test/tests/text line interpolation with event flush.ans index 62ff092..1296a10 100644 --- a/test/tests/text line interpolation with event flush.ans +++ b/test/tests/text line interpolation with event flush.ans @@ -1,12 +1,12 @@ :$ jump button 1 # | A - @ + return! :$ move axis 1 # | left - @" joystick" + return(" joystick") | Press {jump button!} to jump. diff --git a/test/tests/text line interpolation with text event.ans b/test/tests/text line interpolation with text event.ans index 47f408c..d7dd431 100644 --- a/test/tests/text line interpolation with text event.ans +++ b/test/tests/text line interpolation with text event.ans @@ -1,9 +1,9 @@ :$ jump button - @1 # | A + return(1 # | A) :$ move axis 2 # | left - @" joystick" + return(" joystick") | Press {jump button!} to jump. diff --git a/test/tests/unary operator overload.ans b/test/tests/unary operator overload.ans index 6a87fcc..7f97052 100644 --- a/test/tests/unary operator overload.ans +++ b/test/tests/unary operator overload.ans @@ -1,8 +1,8 @@ :$ -f - @"generic minus" + return("generic minus") :$ -f::string - @"minus "+f + return("minus "+f) |{-5} diff --git a/test/tests/unseen line.ans b/test/tests/unseen line.ans index b5ed38a..9f45ee1 100644 --- a/test/tests/unseen line.ans +++ b/test/tests/unseen line.ans @@ -1,6 +1,6 @@ : x = "x"!script($_) |a - run == 0 ~ |seen only once + if(run == 0, $|seen only once) |b x! diff --git a/test/tests/while break.ans b/test/tests/while break.ans new file mode 100644 index 0000000..6ca39ec --- /dev/null +++ b/test/tests/while break.ans @@ -0,0 +1,10 @@ +:i = 0 +while($i <= 10) + | {i} + + if(i == 5) + break! + + i += 1 + +|ok \ No newline at end of file diff --git a/test/tests/while continue.ans b/test/tests/while continue.ans new file mode 100644 index 0000000..6449f29 --- /dev/null +++ b/test/tests/while continue.ans @@ -0,0 +1,10 @@ +:i = 0 +while($i <= 5) + i += 1 + + if(i == 3) + continue! + + | {i} + +|ok \ No newline at end of file diff --git a/test/tests/while loop else.ans b/test/tests/while loop else.ans index 536d413..93f282b 100644 --- a/test/tests/while loop else.ans +++ b/test/tests/while loop else.ans @@ -2,18 +2,18 @@ | Start with i={i}: -i < 5 ~? +while($i < 5) | {i} i += 1 -~ +else! | Loop not ran. | Start with i={i}: -i < 5 ~? +while($i < 5) | {i} i += 1 -~ +else! | Loop not ran. \ No newline at end of file diff --git a/test/tests/while loop.ans b/test/tests/while loop.ans index cf283a6..2da5c23 100644 --- a/test/tests/while loop.ans +++ b/test/tests/while loop.ans @@ -1,5 +1,5 @@ :i = 0 -i <= 10 ~? +while($i <= 10) | {i} i += 1 @@ -7,10 +7,10 @@ i <= 10 ~? | return in loop: i = 0 -i <= 10 ~? +while($i <= 10) | {i} - i == 5 ~ - @() + if(i == 5) + return! i += 1