From ec18d2e61125a5415a5c525b16458cff5d5ac905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Reuh=20Fildadut?= Date: Sun, 4 Apr 2021 19:36:42 +0200 Subject: [PATCH] Recursively check equality for lists and pairs, improve function redefinition error message --- interpreter/expression.lua | 3 + parser/preparser.lua | 2 +- stdlib/functions.lua | 51 ++++++++++++-- test/tests/choice block.lua | 12 ++-- test/tests/choice function.lua | 10 +-- test/tests/choice simple.lua | 6 +- test/tests/commit.lua | 8 +-- test/tests/condition decorator.lua | 4 +- test/tests/condition else false.lua | 2 +- test/tests/condition else true.lua | 2 +- test/tests/condition elseif false.lua | 2 +- test/tests/condition elseif true.lua | 2 +- test/tests/condition true.lua | 2 +- test/tests/custom event.lua | 4 +- test/tests/define override.lua | 2 +- test/tests/equality operator.ans | 19 +++++ test/tests/equality operator.lua | 70 +++++++++++++++++++ test/tests/function arg vararg.lua | 4 +- test/tests/function arg.lua | 2 +- test/tests/function args vararg empty.lua | 4 +- test/tests/function args vararg.lua | 4 +- test/tests/function args.lua | 2 +- test/tests/function arity conflict.lua | 4 +- test/tests/function cycle.lua | 10 +-- test/tests/function next.lua | 10 +-- test/tests/function random.lua | 16 ++--- test/tests/function return nested.lua | 4 +- test/tests/function return.lua | 2 +- test/tests/function scope.lua | 2 +- test/tests/function ufcs arg.ans | 2 + test/tests/function ufcs arg.lua | 20 ++++-- test/tests/function ufcs args.lua | 2 +- test/tests/function vararg empty.lua | 2 +- test/tests/function vararg.lua | 2 +- test/tests/function.lua | 2 +- .../interrupt callback nested paragraph.lua | 6 +- test/tests/interrupt callback nested.lua | 4 +- test/tests/interrupt callback.lua | 4 +- test/tests/interrupt no callback.lua | 2 +- ...aragraph decorator scope explicit call.lua | 4 +- ...aragraph decorator scope implicit call.lua | 4 +- test/tests/paragraph decorator scope.lua | 2 +- test/tests/paragraph run force.lua | 16 ++--- test/tests/paragraph run from.lua | 18 ++--- test/tests/paragraph run.lua | 18 ++--- test/tests/paragraph.lua | 2 +- test/tests/tag decorator empty.lua | 4 +- test/tests/tag decorator nested.lua | 4 +- test/tests/tag decorator.lua | 4 +- test/tests/tag empty.lua | 4 +- test/tests/tag.lua | 4 +- test/tests/text beak.lua | 22 ------ test/tests/text block.lua | 4 +- test/tests/{text beak.ans => text break.ans} | 0 test/tests/text break.lua | 25 ++++--- test/tests/text format.lua | 2 +- test/tests/text.lua | 2 +- test/tests/unseen line.lua | 10 +-- 58 files changed, 288 insertions(+), 172 deletions(-) create mode 100644 test/tests/equality operator.ans create mode 100644 test/tests/equality operator.lua delete mode 100644 test/tests/text beak.lua rename test/tests/{text beak.ans => text break.ans} (100%) diff --git a/interpreter/expression.lua b/interpreter/expression.lua index 7b24771..f94956c 100644 --- a/interpreter/expression.lua +++ b/interpreter/expression.lua @@ -110,11 +110,14 @@ local function eval(state, exp) flush_state(state) if r then return r, e + -- resume function from paragraph elseif not exp.explicit_call then r, e = run(state, fn.value.parent_block, true, fn.value.parent_position+1) else r = { type = "nil", value = nil } end + -- paragraph decorators: run single line or resume from it. + -- checkpoint & seen variables will be updated from the interpreter usual paragraph-reaching code. elseif exp.explicit_call then r, e = run(state, fn.value.parent_block, false, fn.value.parent_position, fn.value.parent_position) else diff --git a/parser/preparser.lua b/parser/preparser.lua index 3cd5b5a..9d6a7c7 100644 --- a/parser/preparser.lua +++ b/parser/preparser.lua @@ -144,7 +144,7 @@ local function parse_line(line, state, namespace) min, max = variant.arity, r.variant.arity end if min == vmin and max == vmax then - return nil, ("trying to define %s %s with arity [%s;%s], but another function with the arity exist; at %s"):format(r.type, fqm, min, max, line.source) + return nil, ("trying to define %s %s with arity [%s;%s], but another function with the same name and arity exist; at %s"):format(r.type, fqm, min, max, line.source) end end -- add diff --git a/stdlib/functions.lua b/stdlib/functions.lua index d2d05cd..786a0f4 100644 --- a/stdlib/functions.lua +++ b/stdlib/functions.lua @@ -8,6 +8,27 @@ local function rewrite_assignement(fqm, state, arg, explicit_call) return ass end +local function compare(a, b) + if a.type ~= b.type then + return false + end + if a.type == "pair" then + return compare(a.value[1], b.value[1]) and compare(a.value[2], b.value[2]) + elseif a.type == "list" then + if #a.value ~= #b.value then + return false + end + for i, v in ipairs(a.value) do + if not compare(v, b.value[i]) then + return false + end + end + return true + else + return a.value == b.value + end +end + local functions functions = { -- discard left @@ -69,7 +90,7 @@ functions = { value = function(a, b) return { type = "number", - value = (a.type == b.type and a.value == b.value) and 1 or 0 + value = compare(a, b) and 1 or 0 } end } @@ -80,7 +101,7 @@ functions = { value = function(a, b) return { type = "number", - value = (a.type == b.type and a.value == b.value) and 0 or 1 + value = compare(a, b) and 0 or 1 } end } @@ -170,10 +191,11 @@ functions = { { arity = 2, return_type = "number", mode = "custom", value = function(state, exp) - local left, lefte = eval(state, exp.left) + local arg = exp.argument + local left, lefte = eval(state, arg.left) if not left then return left, lefte end if truthy(left) then - local right, righte = eval(state, exp.right) + local right, righte = eval(state, arg.right) if not right then return right, righte end if truthy(right) then return { @@ -191,9 +213,10 @@ functions = { }, ["|"] = { { - arity = 2, return_type = "number", mode = "raw", + arity = 2, return_type = "number", mode = "custom", value = function(state, exp) - local left, lefte = eval(state, exp.left) + local arg = exp.argument + local left, lefte = eval(state, arg.left) if not left then return left, lefte end if truthy(left) then return { @@ -201,7 +224,7 @@ functions = { value = 1 } end - local right, righte = eval(state, exp.right) + local right, righte = eval(state, arg.right) if not right then return right, righte end return { type = "number", @@ -275,6 +298,20 @@ functions = { end } }, + find = { + { + arity = 2, types = { "list" }, return_type = "number", mode = "raw", + value = function(a, v) + for i, x in ipairs(v.value) do + if compare(v, x) then + return i + end + end + return 0 + end + }, + }, + -- other methods rand = { { arity = 0, return_type = "number", diff --git a/test/tests/choice block.lua b/test/tests/choice block.lua index 3600536..f2759da 100644 --- a/test/tests/choice block.lua +++ b/test/tests/choice block.lua @@ -5,12 +5,12 @@ _[19]={} _[18]={} _[17]={} _[16]={} -_[15]={data="plop",tags=_[21]} -_[14]={data="oh",tags=_[20]} -_[13]={data="ho",tags=_[19]} -_[12]={data="ok",tags=_[18]} -_[11]={data="ne",tags=_[17]} -_[10]={data="ye",tags=_[16]} +_[15]={tags=_[21],data="plop"} +_[14]={tags=_[20],data="oh"} +_[13]={tags=_[19],data="ho"} +_[12]={tags=_[18],data="ok"} +_[11]={tags=_[17],data="ne"} +_[10]={tags=_[16],data="ye"} _[9]={_[15]} _[8]={_[13],_[14]} _[7]={_[12]} diff --git a/test/tests/choice function.lua b/test/tests/choice function.lua index 315354d..d99f3e1 100644 --- a/test/tests/choice function.lua +++ b/test/tests/choice function.lua @@ -4,11 +4,11 @@ _[14]={} _[13]={} _[12]={} _[11]={} -_[10]={data="ok",tags=_[15]} -_[9]={data="neol",tags=_[14]} -_[8]={data="oh",tags=_[13]} -_[7]={data="neol",tags=_[12]} -_[6]={data="ho",tags=_[11]} +_[10]={tags=_[15],data="ok"} +_[9]={tags=_[14],data="neol"} +_[8]={tags=_[13],data="oh"} +_[7]={tags=_[12],data="neol"} +_[6]={tags=_[11],data="ho"} _[5]={_[10]} _[4]={_[6],_[7],_[8],_[9]} _[3]={"return"} diff --git a/test/tests/choice simple.lua b/test/tests/choice simple.lua index ee55413..133048b 100644 --- a/test/tests/choice simple.lua +++ b/test/tests/choice simple.lua @@ -2,9 +2,9 @@ local _={} _[11]={} _[10]={} _[9]={} -_[8]={data="ok",tags=_[11]} -_[7]={data="ne",tags=_[10]} -_[6]={data="ye",tags=_[9]} +_[8]={tags=_[11],data="ok"} +_[7]={tags=_[10],data="ne"} +_[6]={tags=_[9],data="ye"} _[5]={_[8]} _[4]={_[6],_[7]} _[3]={"return"} diff --git a/test/tests/commit.lua b/test/tests/commit.lua index 0fe975a..821bb9f 100644 --- a/test/tests/commit.lua +++ b/test/tests/commit.lua @@ -3,10 +3,10 @@ _[17]={} _[16]={} _[15]={} _[14]={} -_[13]={data="parallel: 2",tags=_[17]} -_[12]={data="after: 2",tags=_[16]} -_[11]={data="parallel: 5",tags=_[15]} -_[10]={data="before: 2",tags=_[14]} +_[13]={tags=_[17],data="parallel: 2"} +_[12]={tags=_[16],data="after: 2"} +_[11]={tags=_[15],data="parallel: 5"} +_[10]={tags=_[14],data="before: 2"} _[9]={_[13]} _[8]={_[12]} _[7]={_[11]} diff --git a/test/tests/condition decorator.lua b/test/tests/condition decorator.lua index f5f9a03..6a5f16d 100644 --- a/test/tests/condition decorator.lua +++ b/test/tests/condition decorator.lua @@ -1,8 +1,8 @@ local _={} _[7]={} _[6]={} -_[5]={data="ok bis",tags=_[7]} -_[4]={data="ok",tags=_[6]} +_[5]={tags=_[7],data="ok bis"} +_[4]={tags=_[6],data="ok"} _[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/condition else false.lua b/test/tests/condition else false.lua index c75476f..1243028 100644 --- a/test/tests/condition else false.lua +++ b/test/tests/condition else false.lua @@ -1,6 +1,6 @@ local _={} _[5]={} -_[4]={data="ok",tags=_[5]} +_[4]={tags=_[5],data="ok"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/condition else true.lua b/test/tests/condition else true.lua index c75476f..1243028 100644 --- a/test/tests/condition else true.lua +++ b/test/tests/condition else true.lua @@ -1,6 +1,6 @@ local _={} _[5]={} -_[4]={data="ok",tags=_[5]} +_[4]={tags=_[5],data="ok"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/condition elseif false.lua b/test/tests/condition elseif false.lua index c75476f..1243028 100644 --- a/test/tests/condition elseif false.lua +++ b/test/tests/condition elseif false.lua @@ -1,6 +1,6 @@ local _={} _[5]={} -_[4]={data="ok",tags=_[5]} +_[4]={tags=_[5],data="ok"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/condition elseif true.lua b/test/tests/condition elseif true.lua index c75476f..1243028 100644 --- a/test/tests/condition elseif true.lua +++ b/test/tests/condition elseif true.lua @@ -1,6 +1,6 @@ local _={} _[5]={} -_[4]={data="ok",tags=_[5]} +_[4]={tags=_[5],data="ok"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/condition true.lua b/test/tests/condition true.lua index c75476f..1243028 100644 --- a/test/tests/condition true.lua +++ b/test/tests/condition true.lua @@ -1,6 +1,6 @@ local _={} _[5]={} -_[4]={data="ok",tags=_[5]} +_[4]={tags=_[5],data="ok"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/custom event.lua b/test/tests/custom event.lua index 88ec1ce..68bc268 100644 --- a/test/tests/custom event.lua +++ b/test/tests/custom event.lua @@ -1,8 +1,8 @@ local _={} _[8]={} _[7]={} -_[6]={data="ho",tags=_[8]} -_[5]={data="ah",tags=_[7]} +_[6]={tags=_[8],data="ho"} +_[5]={tags=_[7],data="ah"} _[4]={_[5],_[6]} _[3]={"return"} _[2]={"text",_[4]} diff --git a/test/tests/define override.lua b/test/tests/define override.lua index ab7c161..c5653d1 100644 --- a/test/tests/define override.lua +++ b/test/tests/define override.lua @@ -1,6 +1,6 @@ local _={} _[5]={} -_[4]={data="a: 5",tags=_[5]} +_[4]={tags=_[5],data="a: 5"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/equality operator.ans b/test/tests/equality operator.ans new file mode 100644 index 0000000..dec2d76 --- /dev/null +++ b/test/tests/equality operator.ans @@ -0,0 +1,19 @@ +:(1:2) a + +0 = {a = (5:2)} + +0 = {a = (1:3)} + +1 = {a = (1:2)} + +:[1,2,3] b + +0 = {b = a} + +0 = {b = []} + +0 = {b = [3,1,2]} + +0 = {b = [1,2,3,4]} + +1 = {b = [1,2,3]} diff --git a/test/tests/equality operator.lua b/test/tests/equality operator.lua new file mode 100644 index 0000000..b493824 --- /dev/null +++ b/test/tests/equality operator.lua @@ -0,0 +1,70 @@ +local _={} +_[33]={} +_[32]={} +_[31]={} +_[30]={} +_[29]={} +_[28]={} +_[27]={} +_[26]={} +_[25]={tags=_[33],data="1 = 1"} +_[24]={tags=_[32],data="0 = 0"} +_[23]={tags=_[31],data="0 = 0"} +_[22]={tags=_[30],data="0 = 0"} +_[21]={tags=_[29],data="0 = 0"} +_[20]={tags=_[28],data="1 = 1"} +_[19]={tags=_[27],data="0 = 0"} +_[18]={tags=_[26],data="0 = 0"} +_[17]={_[25]} +_[16]={_[24]} +_[15]={_[23]} +_[14]={_[22]} +_[13]={_[21]} +_[12]={_[20]} +_[11]={_[19]} +_[10]={_[18]} +_[9]={"return"} +_[8]={"text",_[17]} +_[7]={"text",_[16]} +_[6]={"text",_[15]} +_[5]={"text",_[14]} +_[4]={"text",_[13]} +_[3]={"text",_[12]} +_[2]={"text",_[11]} +_[1]={"text",_[10]} +return {_[1],_[2],_[3],_[4],_[5],_[6],_[7],_[8],_[9]} +--[[ +{ "text", { { + data = "0 = 0", + tags = {} + } } } +{ "text", { { + data = "0 = 0", + tags = {} + } } } +{ "text", { { + data = "1 = 1", + tags = {} + } } } +{ "text", { { + data = "0 = 0", + tags = {} + } } } +{ "text", { { + data = "0 = 0", + tags = {} + } } } +{ "text", { { + data = "0 = 0", + tags = {} + } } } +{ "text", { { + data = "0 = 0", + tags = {} + } } } +{ "text", { { + data = "1 = 1", + tags = {} + } } } +{ "return" } +]]-- \ No newline at end of file diff --git a/test/tests/function arg vararg.lua b/test/tests/function arg vararg.lua index 763d91a..898276b 100644 --- a/test/tests/function arg vararg.lua +++ b/test/tests/function arg vararg.lua @@ -1,8 +1,8 @@ local _={} _[7]={} _[6]={} -_[5]={data="[o, k]",tags=_[7]} -_[4]={data="ok",tags=_[6]} +_[5]={tags=_[7],data="[o, k]"} +_[4]={tags=_[6],data="ok"} _[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/function arg.lua b/test/tests/function arg.lua index c75476f..1243028 100644 --- a/test/tests/function arg.lua +++ b/test/tests/function arg.lua @@ -1,6 +1,6 @@ local _={} _[5]={} -_[4]={data="ok",tags=_[5]} +_[4]={tags=_[5],data="ok"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/function args vararg empty.lua b/test/tests/function args vararg empty.lua index fc7ecbe..a195e2e 100644 --- a/test/tests/function args vararg empty.lua +++ b/test/tests/function args vararg empty.lua @@ -1,8 +1,8 @@ local _={} _[7]={} _[6]={} -_[5]={data="[]",tags=_[7]} -_[4]={data="ok",tags=_[6]} +_[5]={tags=_[7],data="[]"} +_[4]={tags=_[6],data="ok"} _[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/function args vararg.lua b/test/tests/function args vararg.lua index 763d91a..898276b 100644 --- a/test/tests/function args vararg.lua +++ b/test/tests/function args vararg.lua @@ -1,8 +1,8 @@ local _={} _[7]={} _[6]={} -_[5]={data="[o, k]",tags=_[7]} -_[4]={data="ok",tags=_[6]} +_[5]={tags=_[7],data="[o, k]"} +_[4]={tags=_[6],data="ok"} _[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/function args.lua b/test/tests/function args.lua index c75476f..1243028 100644 --- a/test/tests/function args.lua +++ b/test/tests/function args.lua @@ -1,6 +1,6 @@ local _={} _[5]={} -_[4]={data="ok",tags=_[5]} +_[4]={tags=_[5],data="ok"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/function arity conflict.lua b/test/tests/function arity conflict.lua index 5a130e5..c77b958 100644 --- a/test/tests/function arity conflict.lua +++ b/test/tests/function arity conflict.lua @@ -1,6 +1,6 @@ local _={} -_[1]={"error","trying to define function function arity conflict.f with arity [2;2], but another function with the arity exist; at test/tests/function arity conflict.ans:5"} +_[1]={"error","trying to define function function arity conflict.f with arity [2;2], but another function with the same name and arity exist; at test/tests/function arity conflict.ans:5"} return {_[1]} --[[ -{ "error", "trying to define function function arity conflict.f with arity [2;2], but another function with the arity exist; at test/tests/function arity conflict.ans:5" } +{ "error", "trying to define function function arity conflict.f with arity [2;2], but another function with the same name and arity exist; at test/tests/function arity conflict.ans:5" } ]]-- \ No newline at end of file diff --git a/test/tests/function cycle.lua b/test/tests/function cycle.lua index f4a5748..dc573ad 100644 --- a/test/tests/function cycle.lua +++ b/test/tests/function cycle.lua @@ -4,11 +4,11 @@ _[20]={} _[19]={} _[18]={} _[17]={} -_[16]={data="b",tags=_[21]} -_[15]={data="a",tags=_[20]} -_[14]={data="c",tags=_[19]} -_[13]={data="b",tags=_[18]} -_[12]={data="a",tags=_[17]} +_[16]={tags=_[21],data="b"} +_[15]={tags=_[20],data="a"} +_[14]={tags=_[19],data="c"} +_[13]={tags=_[18],data="b"} +_[12]={tags=_[17],data="a"} _[11]={_[16]} _[10]={_[15]} _[9]={_[14]} diff --git a/test/tests/function next.lua b/test/tests/function next.lua index 5574217..05e6015 100644 --- a/test/tests/function next.lua +++ b/test/tests/function next.lua @@ -4,11 +4,11 @@ _[20]={} _[19]={} _[18]={} _[17]={} -_[16]={data="c",tags=_[21]} -_[15]={data="c",tags=_[20]} -_[14]={data="c",tags=_[19]} -_[13]={data="b",tags=_[18]} -_[12]={data="a",tags=_[17]} +_[16]={tags=_[21],data="c"} +_[15]={tags=_[20],data="c"} +_[14]={tags=_[19],data="c"} +_[13]={tags=_[18],data="b"} +_[12]={tags=_[17],data="a"} _[11]={_[16]} _[10]={_[15]} _[9]={_[14]} diff --git a/test/tests/function random.lua b/test/tests/function random.lua index 27c7f24..d0e0f2b 100644 --- a/test/tests/function random.lua +++ b/test/tests/function random.lua @@ -4,11 +4,11 @@ _[20]={} _[19]={} _[18]={} _[17]={} -_[16]={data="a",tags=_[21]} -_[15]={data="c",tags=_[20]} -_[14]={data="c",tags=_[19]} -_[13]={data="c",tags=_[18]} -_[12]={data="b",tags=_[17]} +_[16]={tags=_[21],data="a"} +_[15]={tags=_[20],data="a"} +_[14]={tags=_[19],data="b"} +_[13]={tags=_[18],data="a"} +_[12]={tags=_[17],data="b"} _[11]={_[16]} _[10]={_[15]} _[9]={_[14]} @@ -27,15 +27,15 @@ return {_[1],_[2],_[3],_[4],_[5],_[6]} tags = {} } } } { "text", { { - data = "c", + data = "a", tags = {} } } } { "text", { { - data = "c", + data = "b", tags = {} } } } { "text", { { - data = "c", + data = "a", tags = {} } } } { "text", { { diff --git a/test/tests/function return nested.lua b/test/tests/function return nested.lua index baedcdc..3373cd9 100644 --- a/test/tests/function return nested.lua +++ b/test/tests/function return nested.lua @@ -1,8 +1,8 @@ local _={} _[7]={} _[6]={} -_[5]={data="2",tags=_[7]} -_[4]={data="5",tags=_[6]} +_[5]={tags=_[7],data="2"} +_[4]={tags=_[6],data="5"} _[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/function return.lua b/test/tests/function return.lua index 9d39b3d..1cfd3c9 100644 --- a/test/tests/function return.lua +++ b/test/tests/function return.lua @@ -1,6 +1,6 @@ local _={} _[5]={} -_[4]={data="5",tags=_[5]} +_[4]={tags=_[5],data="5"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/function scope.lua b/test/tests/function scope.lua index ab7c161..c5653d1 100644 --- a/test/tests/function scope.lua +++ b/test/tests/function scope.lua @@ -1,6 +1,6 @@ local _={} _[5]={} -_[4]={data="a: 5",tags=_[5]} +_[4]={tags=_[5],data="a: 5"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/function ufcs arg.ans b/test/tests/function ufcs arg.ans index 2917dac..873e827 100644 --- a/test/tests/function ufcs arg.ans +++ b/test/tests/function ufcs arg.ans @@ -1,4 +1,6 @@ $ f(a) {a} +~ "ok".f + ~ "ok".f() diff --git a/test/tests/function ufcs arg.lua b/test/tests/function ufcs arg.lua index c75476f..92dc1c1 100644 --- a/test/tests/function ufcs arg.lua +++ b/test/tests/function ufcs arg.lua @@ -1,11 +1,19 @@ local _={} -_[5]={} -_[4]={data="ok",tags=_[5]} -_[3]={_[4]} -_[2]={"return"} -_[1]={"text",_[3]} -return {_[1],_[2]} +_[9]={} +_[8]={} +_[7]={tags=_[9],data="ok"} +_[6]={tags=_[8],data="ok"} +_[5]={_[7]} +_[4]={_[6]} +_[3]={"return"} +_[2]={"text",_[5]} +_[1]={"text",_[4]} +return {_[1],_[2],_[3]} --[[ +{ "text", { { + data = "ok", + tags = {} + } } } { "text", { { data = "ok", tags = {} diff --git a/test/tests/function ufcs args.lua b/test/tests/function ufcs args.lua index c75476f..1243028 100644 --- a/test/tests/function ufcs args.lua +++ b/test/tests/function ufcs args.lua @@ -1,6 +1,6 @@ local _={} _[5]={} -_[4]={data="ok",tags=_[5]} +_[4]={tags=_[5],data="ok"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/function vararg empty.lua b/test/tests/function vararg empty.lua index 25ed63e..4131fec 100644 --- a/test/tests/function vararg empty.lua +++ b/test/tests/function vararg empty.lua @@ -1,6 +1,6 @@ local _={} _[5]={} -_[4]={data="[]",tags=_[5]} +_[4]={tags=_[5],data="[]"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/function vararg.lua b/test/tests/function vararg.lua index 4b57911..0d0116e 100644 --- a/test/tests/function vararg.lua +++ b/test/tests/function vararg.lua @@ -1,6 +1,6 @@ local _={} _[5]={} -_[4]={data="[o, k]",tags=_[5]} +_[4]={tags=_[5],data="[o, k]"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/function.lua b/test/tests/function.lua index c75476f..1243028 100644 --- a/test/tests/function.lua +++ b/test/tests/function.lua @@ -1,6 +1,6 @@ local _={} _[5]={} -_[4]={data="ok",tags=_[5]} +_[4]={tags=_[5],data="ok"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/interrupt callback nested paragraph.lua b/test/tests/interrupt callback nested paragraph.lua index 35ff609..00fb3a4 100644 --- a/test/tests/interrupt callback nested paragraph.lua +++ b/test/tests/interrupt callback nested paragraph.lua @@ -2,9 +2,9 @@ local _={} _[12]={} _[11]={} _[10]={} -_[9]={data="no",tags=_[12]} -_[8]={data="in interrupt: 5",tags=_[11]} -_[7]={data="before: 2",tags=_[10]} +_[9]={tags=_[12],data="no"} +_[8]={tags=_[11],data="in interrupt: 5"} +_[7]={tags=_[10],data="before: 2"} _[6]={_[8],_[9]} _[5]={_[7]} _[4]={"return"} diff --git a/test/tests/interrupt callback nested.lua b/test/tests/interrupt callback nested.lua index 0a29f65..6000689 100644 --- a/test/tests/interrupt callback nested.lua +++ b/test/tests/interrupt callback nested.lua @@ -1,8 +1,8 @@ local _={} _[10]={} _[9]={} -_[8]={data="in interrupt: 5",tags=_[10]} -_[7]={data="before: 2",tags=_[9]} +_[8]={tags=_[10],data="in interrupt: 5"} +_[7]={tags=_[9],data="before: 2"} _[6]={_[8]} _[5]={_[7]} _[4]={"return"} diff --git a/test/tests/interrupt callback.lua b/test/tests/interrupt callback.lua index 0a29f65..6000689 100644 --- a/test/tests/interrupt callback.lua +++ b/test/tests/interrupt callback.lua @@ -1,8 +1,8 @@ local _={} _[10]={} _[9]={} -_[8]={data="in interrupt: 5",tags=_[10]} -_[7]={data="before: 2",tags=_[9]} +_[8]={tags=_[10],data="in interrupt: 5"} +_[7]={tags=_[9],data="before: 2"} _[6]={_[8]} _[5]={_[7]} _[4]={"return"} diff --git a/test/tests/interrupt no callback.lua b/test/tests/interrupt no callback.lua index 3c4fc54..97eafe6 100644 --- a/test/tests/interrupt no callback.lua +++ b/test/tests/interrupt no callback.lua @@ -1,6 +1,6 @@ local _={} _[6]={} -_[5]={data="before: 2",tags=_[6]} +_[5]={tags=_[6],data="before: 2"} _[4]={_[5]} _[3]={"return",""} _[2]={"wait",0} diff --git a/test/tests/paragraph decorator scope explicit call.lua b/test/tests/paragraph decorator scope explicit call.lua index f4169f2..92b05dc 100644 --- a/test/tests/paragraph decorator scope explicit call.lua +++ b/test/tests/paragraph decorator scope explicit call.lua @@ -1,8 +1,8 @@ local _={} _[9]={} _[8]={} -_[7]={data="a.\240\159\145\129\239\184\143: 1",tags=_[9]} -_[6]={data="a.\240\159\145\129\239\184\143: 0",tags=_[8]} +_[7]={tags=_[9],data="a.\240\159\145\129\239\184\143: 1"} +_[6]={tags=_[8],data="a.\240\159\145\129\239\184\143: 0"} _[5]={_[7]} _[4]={_[6]} _[3]={"return"} diff --git a/test/tests/paragraph decorator scope implicit call.lua b/test/tests/paragraph decorator scope implicit call.lua index 662b7a5..cdf0f8f 100644 --- a/test/tests/paragraph decorator scope implicit call.lua +++ b/test/tests/paragraph decorator scope implicit call.lua @@ -1,8 +1,8 @@ local _={} _[7]={} _[6]={} -_[5]={data="ok",tags=_[7]} -_[4]={data="a.\240\159\145\129\239\184\143: 0",tags=_[6]} +_[5]={tags=_[7],data="ok"} +_[4]={tags=_[6],data="a.\240\159\145\129\239\184\143: 0"} _[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/paragraph decorator scope.lua b/test/tests/paragraph decorator scope.lua index 514bf2c..94aae53 100644 --- a/test/tests/paragraph decorator scope.lua +++ b/test/tests/paragraph decorator scope.lua @@ -1,6 +1,6 @@ local _={} _[5]={} -_[4]={data="a.\240\159\145\129\239\184\143: 0",tags=_[5]} +_[4]={tags=_[5],data="a.\240\159\145\129\239\184\143: 0"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/paragraph run force.lua b/test/tests/paragraph run force.lua index ebfabf4..383699a 100644 --- a/test/tests/paragraph run force.lua +++ b/test/tests/paragraph run force.lua @@ -7,14 +7,14 @@ _[19]={} _[18]={} _[17]={} _[16]={} -_[15]={data="b",tags=_[23]} -_[14]={data="x",tags=_[22]} -_[13]={data="Force no checkpoint:",tags=_[21]} -_[12]={data="b",tags=_[20]} -_[11]={data="a",tags=_[19]} -_[10]={data="From checkpoint:",tags=_[18]} -_[9]={data="a",tags=_[17]} -_[8]={data="Force run checkpoint:",tags=_[16]} +_[15]={tags=_[23],data="b"} +_[14]={tags=_[22],data="x"} +_[13]={tags=_[21],data="Force no checkpoint:"} +_[12]={tags=_[20],data="b"} +_[11]={tags=_[19],data="a"} +_[10]={tags=_[18],data="From checkpoint:"} +_[9]={tags=_[17],data="a"} +_[8]={tags=_[16],data="Force run checkpoint:"} _[7]={_[13],_[14],_[15]} _[6]={_[10],_[11],_[12]} _[5]={_[8],_[9]} diff --git a/test/tests/paragraph run from.lua b/test/tests/paragraph run from.lua index 2a60103..e9fcae3 100644 --- a/test/tests/paragraph run from.lua +++ b/test/tests/paragraph run from.lua @@ -8,15 +8,15 @@ _[20]={} _[19]={} _[18]={} _[17]={} -_[16]={data="b",tags=_[25]} -_[15]={data="x",tags=_[24]} -_[14]={data="Force no checkpoint:",tags=_[23]} -_[13]={data="b",tags=_[22]} -_[12]={data="a",tags=_[21]} -_[11]={data="From checkpoint:",tags=_[20]} -_[10]={data="b",tags=_[19]} -_[9]={data="a",tags=_[18]} -_[8]={data="Force run from checkpoint:",tags=_[17]} +_[16]={tags=_[25],data="b"} +_[15]={tags=_[24],data="x"} +_[14]={tags=_[23],data="Force no checkpoint:"} +_[13]={tags=_[22],data="b"} +_[12]={tags=_[21],data="a"} +_[11]={tags=_[20],data="From checkpoint:"} +_[10]={tags=_[19],data="b"} +_[9]={tags=_[18],data="a"} +_[8]={tags=_[17],data="Force run from checkpoint:"} _[7]={_[14],_[15],_[16]} _[6]={_[11],_[12],_[13]} _[5]={_[8],_[9],_[10]} diff --git a/test/tests/paragraph run.lua b/test/tests/paragraph run.lua index 1c639b3..e941849 100644 --- a/test/tests/paragraph run.lua +++ b/test/tests/paragraph run.lua @@ -8,15 +8,15 @@ _[20]={} _[19]={} _[18]={} _[17]={} -_[16]={data="b",tags=_[25]} -_[15]={data="x",tags=_[24]} -_[14]={data="Force no checkpoint:",tags=_[23]} -_[13]={data="b",tags=_[22]} -_[12]={data="a",tags=_[21]} -_[11]={data="From checkpoint:",tags=_[20]} -_[10]={data="b",tags=_[19]} -_[9]={data="x",tags=_[18]} -_[8]={data="No checkpoint:",tags=_[17]} +_[16]={tags=_[25],data="b"} +_[15]={tags=_[24],data="x"} +_[14]={tags=_[23],data="Force no checkpoint:"} +_[13]={tags=_[22],data="b"} +_[12]={tags=_[21],data="a"} +_[11]={tags=_[20],data="From checkpoint:"} +_[10]={tags=_[19],data="b"} +_[9]={tags=_[18],data="x"} +_[8]={tags=_[17],data="No checkpoint:"} _[7]={_[14],_[15],_[16]} _[6]={_[11],_[12],_[13]} _[5]={_[8],_[9],_[10]} diff --git a/test/tests/paragraph.lua b/test/tests/paragraph.lua index b086675..004133c 100644 --- a/test/tests/paragraph.lua +++ b/test/tests/paragraph.lua @@ -1,6 +1,6 @@ local _={} _[5]={} -_[4]={data="b",tags=_[5]} +_[4]={tags=_[5],data="b"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/tag decorator empty.lua b/test/tests/tag decorator empty.lua index c5fd791..780a643 100644 --- a/test/tests/tag decorator empty.lua +++ b/test/tests/tag decorator empty.lua @@ -1,7 +1,7 @@ local _={} _[6]={1} -_[5]={data="bar",tags=_[6]} -_[4]={data="foo",tags=_[6]} +_[5]={tags=_[6],data="bar"} +_[4]={tags=_[6],data="foo"} _[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/tag decorator nested.lua b/test/tests/tag decorator nested.lua index 9611766..a6f5928 100644 --- a/test/tests/tag decorator nested.lua +++ b/test/tests/tag decorator nested.lua @@ -2,8 +2,8 @@ local _={} _[8]={2,3} _[7]={1,a=_[8]} _[6]={1} -_[5]={data="bar",tags=_[7]} -_[4]={data="foo",tags=_[6]} +_[5]={tags=_[7],data="bar"} +_[4]={tags=_[6],data="foo"} _[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/tag decorator.lua b/test/tests/tag decorator.lua index 9611766..a6f5928 100644 --- a/test/tests/tag decorator.lua +++ b/test/tests/tag decorator.lua @@ -2,8 +2,8 @@ local _={} _[8]={2,3} _[7]={1,a=_[8]} _[6]={1} -_[5]={data="bar",tags=_[7]} -_[4]={data="foo",tags=_[6]} +_[5]={tags=_[7],data="bar"} +_[4]={tags=_[6],data="foo"} _[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/tag empty.lua b/test/tests/tag empty.lua index c5fd791..780a643 100644 --- a/test/tests/tag empty.lua +++ b/test/tests/tag empty.lua @@ -1,7 +1,7 @@ local _={} _[6]={1} -_[5]={data="bar",tags=_[6]} -_[4]={data="foo",tags=_[6]} +_[5]={tags=_[6],data="bar"} +_[4]={tags=_[6],data="foo"} _[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/tag.lua b/test/tests/tag.lua index 9611766..a6f5928 100644 --- a/test/tests/tag.lua +++ b/test/tests/tag.lua @@ -2,8 +2,8 @@ local _={} _[8]={2,3} _[7]={1,a=_[8]} _[6]={1} -_[5]={data="bar",tags=_[7]} -_[4]={data="foo",tags=_[6]} +_[5]={tags=_[7],data="bar"} +_[4]={tags=_[6],data="foo"} _[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/text beak.lua b/test/tests/text beak.lua deleted file mode 100644 index 89356fb..0000000 --- a/test/tests/text beak.lua +++ /dev/null @@ -1,22 +0,0 @@ -local _={} -_[9]={} -_[8]={} -_[7]={data="b c",tags=_[9]} -_[6]={data="a",tags=_[8]} -_[5]={_[7]} -_[4]={_[6]} -_[3]={"return"} -_[2]={"text",_[5]} -_[1]={"text",_[4]} -return {_[1],_[2],_[3]} ---[[ -{ "text", { { - data = "a", - tags = {} - } } } -{ "text", { { - data = "b c", - tags = {} - } } } -{ "return" } -]]-- \ No newline at end of file diff --git a/test/tests/text block.lua b/test/tests/text block.lua index 8c9d78c..b7a6dc2 100644 --- a/test/tests/text block.lua +++ b/test/tests/text block.lua @@ -1,8 +1,8 @@ local _={} _[7]={} _[6]={} -_[5]={data="b c",tags=_[7]} -_[4]={data="a",tags=_[6]} +_[5]={tags=_[7],data="b c"} +_[4]={tags=_[6],data="a"} _[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/text beak.ans b/test/tests/text break.ans similarity index 100% rename from test/tests/text beak.ans rename to test/tests/text break.ans diff --git a/test/tests/text break.lua b/test/tests/text break.lua index ffed445..7a00295 100644 --- a/test/tests/text break.lua +++ b/test/tests/text break.lua @@ -1,23 +1,22 @@ local _={} +_[9]={} _[8]={} -_[7]={} -_[6]={data="b c",tags=_[8]} -_[5]={data="a",tags=_[7]} -_[4]={type="string",value=""} -_[3]={_[5],_[6]} -_[2]={"return",_[4]} -_[1]={"text",_[3]} -return {_[1],_[2]} +_[7]={tags=_[9],data="b c"} +_[6]={tags=_[8],data="a"} +_[5]={_[7]} +_[4]={_[6]} +_[3]={"return"} +_[2]={"text",_[5]} +_[1]={"text",_[4]} +return {_[1],_[2],_[3]} --[[ { "text", { { data = "a", tags = {} - }, { + } } } +{ "text", { { data = "b c", tags = {} } } } -{ "return", { - type = "string", - value = "" - } } +{ "return" } ]]-- \ No newline at end of file diff --git a/test/tests/text format.lua b/test/tests/text format.lua index ab7c161..c5653d1 100644 --- a/test/tests/text format.lua +++ b/test/tests/text format.lua @@ -1,6 +1,6 @@ local _={} _[5]={} -_[4]={data="a: 5",tags=_[5]} +_[4]={tags=_[5],data="a: 5"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/text.lua b/test/tests/text.lua index 9c00295..504a82d 100644 --- a/test/tests/text.lua +++ b/test/tests/text.lua @@ -1,6 +1,6 @@ local _={} _[5]={} -_[4]={data="a",tags=_[5]} +_[4]={tags=_[5],data="a"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} diff --git a/test/tests/unseen line.lua b/test/tests/unseen line.lua index f2546fa..f6ac2a6 100644 --- a/test/tests/unseen line.lua +++ b/test/tests/unseen line.lua @@ -4,11 +4,11 @@ _[12]={} _[11]={} _[10]={} _[9]={} -_[8]={data="b",tags=_[13]} -_[7]={data="a",tags=_[12]} -_[6]={data="b",tags=_[11]} -_[5]={data="seen only once",tags=_[10]} -_[4]={data="a",tags=_[9]} +_[8]={tags=_[13],data="b"} +_[7]={tags=_[12],data="a"} +_[6]={tags=_[11],data="b"} +_[5]={tags=_[10],data="seen only once"} +_[4]={tags=_[9],data="a"} _[3]={_[4],_[5],_[6],_[7],_[8]} _[2]={"return"} _[1]={"text",_[3]}