From 7105b445ef654173ebe83c5cd3ef49aefeb89aec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Reuh=20Fildadut?= Date: Fri, 26 Nov 2021 21:26:41 +0100 Subject: [PATCH] Handle events in text interpolation; capture text events in choice lines; improve test script --- README.md | 62 ++- anselme.lua | 10 +- interpreter/common.lua | 41 +- interpreter/expression.lua | 2 +- interpreter/interpreter.lua | 209 +++++++--- parser/preparser.lua | 2 - test/run.lua | 75 +++- test/tests/argument alias.lua | 18 +- test/tests/binary operator overload.lua | 18 +- test/tests/checkpoint change.ans | 33 ++ test/tests/checkpoint change.lua | 193 ++++++++++ test/tests/checkpoint reached seen.lua | 64 +-- test/tests/choice block.lua | 58 +-- test/tests/choice function.lua | 51 +-- ...e line interpolation with choice event.ans | 10 + ...e line interpolation with choice event.lua | 47 +++ ...ce line interpolation with event flush.ans | 11 + ...ce line interpolation with event flush.lua | 55 +++ ...ice line interpolation with text event.ans | 18 + ...ice line interpolation with text event.lua | 72 ++++ test/tests/choice preserve tags.lua | 88 +++-- test/tests/choice simple.lua | 29 +- test/tests/commit.lua | 56 ++- test/tests/condition decorator.lua | 12 +- test/tests/condition else false.lua | 6 +- test/tests/condition else true.lua | 6 +- test/tests/condition elseif false.lua | 6 +- test/tests/condition elseif true.lua | 6 +- test/tests/condition true.lua | 6 +- test/tests/custom event.lua | 12 +- test/tests/custom text formatting.lua | 6 +- test/tests/equality operator.lua | 112 ++++-- test/tests/flush.lua | 38 +- test/tests/function alias.lua | 36 +- test/tests/function arg vararg.lua | 12 +- test/tests/function arg.lua | 6 +- test/tests/function args vararg empty.lua | 20 +- test/tests/function args vararg.lua | 20 +- test/tests/function args.lua | 14 +- test/tests/function assignement.lua | 50 ++- .../function custom type dispatch error.lua | 42 +- test/tests/function custom type dispatch.lua | 42 +- test/tests/function cycle.lua | 30 +- ...function decorator scope explicit call.lua | 28 +- ...function decorator scope implicit call.lua | 46 ++- test/tests/function decorator scope.lua | 14 +- test/tests/function name dispatch.lua | 12 +- test/tests/function next.lua | 30 +- test/tests/function random.lua | 30 +- .../function return exit function nested.lua | 12 +- test/tests/function return exit function.lua | 6 +- test/tests/function return nested.lua | 12 +- test/tests/function return.lua | 6 +- test/tests/function scope.lua | 14 +- test/tests/function selection.lua | 12 +- ...nction separate variable from variants.lua | 14 +- .../function type dispatch with default.lua | 66 ++-- test/tests/function type dispatch.lua | 12 +- test/tests/function ufcs arg.lua | 12 +- test/tests/function ufcs args.lua | 14 +- test/tests/function vararg empty.lua | 6 +- test/tests/function vararg.lua | 6 +- test/tests/function.lua | 6 +- .../interrupt callback nested paragraph.lua | 34 +- test/tests/interrupt callback nested.lua | 28 +- test/tests/interrupt callback.lua | 28 +- test/tests/interrupt no callback.lua | 14 +- test/tests/lazy boolean operators.lua | 184 +++++---- test/tests/list assignement.lua | 54 +-- test/tests/named arguments.lua | 26 +- test/tests/named varag.lua | 6 +- test/tests/nested conditions.lua | 18 +- test/tests/nested flush.lua | 62 +-- test/tests/optional arguments.lua | 26 +- test/tests/paragraph alias.lua | 18 +- test/tests/paragraph run force.lua | 48 +-- test/tests/paragraph run from.lua | 54 +-- test/tests/paragraph run.lua | 54 +-- test/tests/paragraph.lua | 6 +- test/tests/resume from nested paragraph.lua | 108 +++--- .../resume from paragraph restore tags.lua | 50 +-- ...sume from paragraph with nested choice.lua | 363 +++++++++--------- ...e from paragraph with nested condition.lua | 24 +- test/tests/return in choice.lua | 26 +- test/tests/string escaping.lua | 68 +++- test/tests/tag decorator empty.lua | 12 +- test/tests/tag decorator nested.lua | 12 +- test/tests/tag decorator.lua | 12 +- test/tests/tag empty.lua | 12 +- test/tests/tag.lua | 12 +- test/tests/text block.lua | 12 +- test/tests/text break.lua | 12 +- test/tests/text format.lua | 14 +- ...t line interpolation with choice event.ans | 16 + ...t line interpolation with choice event.lua | 82 ++++ ...xt line interpolation with event flush.ans | 13 + ...xt line interpolation with event flush.lua | 50 +++ ...ext line interpolation with text event.ans | 10 + ...ext line interpolation with text event.lua | 44 +++ test/tests/text.lua | 6 +- test/tests/unary operator overload.lua | 18 +- test/tests/unseen line.lua | 30 +- test/tests/variable alias.lua | 18 +- 103 files changed, 2452 insertions(+), 1294 deletions(-) create mode 100644 test/tests/checkpoint change.ans create mode 100644 test/tests/checkpoint change.lua create mode 100644 test/tests/choice line interpolation with choice event.ans create mode 100644 test/tests/choice line interpolation with choice event.lua create mode 100644 test/tests/choice line interpolation with event flush.ans create mode 100644 test/tests/choice line interpolation with event flush.lua create mode 100644 test/tests/choice line interpolation with text event.ans create mode 100644 test/tests/choice line interpolation with text event.lua create mode 100644 test/tests/text line interpolation with choice event.ans create mode 100644 test/tests/text line interpolation with choice event.lua create mode 100644 test/tests/text line interpolation with event flush.ans create mode 100644 test/tests/text line interpolation with event flush.lua create mode 100644 test/tests/text line interpolation with text event.ans create mode 100644 test/tests/text line interpolation with text event.lua diff --git a/README.md b/README.md index cb6cbe4..510ff3c 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ HELLO SIR, HOW ARE YOU TODAY > Sure is! YEAH. YEAH. > I've seen better. - ENTITLED PRICK. + NOT NICE. WELL, GOOD BYE. ``` @@ -156,12 +156,16 @@ There's different types of lines, depending on their first character(s) (after i This is. ``` -* `>`: write a choice into the event buffer. Followed by arbitrary text. Support [text interpolation](#text-interpolation). +* `>`: write a choice into the event buffer. Followed by arbitrary text. Support [text interpolation](#text-interpolation); if a text event is created during the text interpolation, it is added to the choice text content instead of the global event buffer. ``` +$ f + Third choice + > First choice > Second choice > Last choice +> {f} ``` * `$`: function line. Followed by an [identifier](#identifiers), then eventually an [alias](#aliases), and eventually a parameter list. Define a function using its children as function body. Also define a new namespace for its children (using the function name if it has no arguments, or a unique name otherwise). @@ -268,9 +272,9 @@ $ inane dialog Checkpoints always have the following variable defined in its namespace by default: `๐Ÿ‘๏ธ`: number, number of times the checkpoint was executed before -`๐Ÿ`: number, number of times the checkpoint was reached before (including times where it was resumed from and executed) +`๐Ÿ`: number, number of times the checkpoint was reached before (includes times where it was resumed from and executed) -* `#`: tag line. Can be followed by an [expression](#expressions); otherwise nil expression is assumed. The results of the [expression](#expressions) will be added to the tags send along with any event sent from its children. Can be nested. +* `#`: tag line. Can be followed by an [expression](#expressions); otherwise nil expression is assumed. The results of the [expression](#expressions) will be added to the tags send along with any `choice` or `text` event sent from its children. Can be nested. ``` # "color": "red" @@ -298,7 +302,9 @@ $ hey {hey} = 5 ``` -Be careful when using `@` in a choice block. Choice blocks are not ran right as they are read, but at the next event flush (i.e. empty line). This means that if there is no flush in the function itself, the choice will be ran *after* the function has already been executed and returning a value at this point makes no sense: +Please note that Anselme will discard returns values sent from within a choice block. Returns inside choice block still have the expected behaviour of stopping the execution of the choice block. + +This is the case because choice blocks are not ran right as they are read, but only at the next event flush (i.e. empty line). This means that if there is no flush in the function itself, the choice will be ran *after* the function has already been executed and returning a value at this point makes no sense: ``` $ f @@ -315,9 +321,7 @@ $ f ``` -For this reason, Anselme will discard returns values sent from within a choice block. Returns inside choice block still have the expected behaviour of stopping the execution of the block. - -* empty line: flush events, i.e., if there are any pending lines of text or choices, send them to your game. See [Event buffer](#event-buffer). This line always keep the same identation as the last non-empty line, so you don't need to put invisible whitespace on an empty-looking line. Is also automatically added at the end of a file. +* empty line: flush the event buffer, i.e., if there are any pending lines of text or choices, send them to your game. See [Event buffer](#event-buffer). This line always keep the same identation as the last non-empty line, so you don't need to put invisible whitespace on an empty-looking line. Is also automatically added at the end of a file. * regular text: write some text into the event buffer. Support [text interpolation](#text-interpolation). @@ -395,21 +399,47 @@ $ loop ### Text interpolation -Text and choice lines allow for arbitrary text. Expression can be evaluated and inserted into the text as the line is executed by enclosing the [expression](#expressions) into brackets. +Text and choice lines allow for arbitrary text. Expression can be evaluated and inserted into the text as the line is executed by enclosing the [expression](#expressions) into brackets. The expressions are evaluated in the same order as the reading direction. + +The expression is automatically wrapped in a call to `{}(expr)`. You can overload `{}` to change its behaviour for custom types; main intended use is to provide some pretty-printing function. + +Note that events can be sent from the interpolated expression as usual. So you may not want to send a choice event or flush the event buffer from, for example, an interpolated expression in a text line, as your text line will be cut in two with the flush or choice between the two halves. + +Text interpolated in choices have the special property of capturing text events into the choice text. ``` :a = 5 Value of a: {a} -``` -The expression is automatically wrapped in a call to `{}(expr)`. You can overload `{}` to change its behaviour for custom types. +(in text and choices, text events created from an interpolated expression are included in the final text) +$ f + wor + (the returned value comes after) + @"ld." + +(Will print "Hello world.") +Hello {f} + +> Hello {f} + +(keep in mind that events are also sent as usual in places that would usually not send event and thus can't really handle them in a sensible manner) +(for example in text litterals: this will send a "wor" text event and put "ld." in b) +:b = "{f}" +``` ### Event buffer -Since Lua mainly run into a signle thread, Anselme need to give back control to the game at some point. This is done with flush event lines (empty lines), where the intrepreter yield its coroutine and returns a buch of data to your game (called the event buffer). It's called an event buffer because, well, it's a buffer, and events are what we call whatever Anselme sends back to your game. +Anselme need to give back control to the game at some point. This is done through events: the interpreter regularly yield its coroutine and returns a buch of data to your game (called the event buffer or just "event"). It's called an event buffer because, well, it's a buffer, and events are what we call whatever Anselme sends back to your game. -As Anselme interpret the script, it keeps a buffer of events that will be sent to your game on the next event flush line. These events are, by default, either text, choice or return (this one sent when the script end). +Each event have a type (`text`, `choice`, `return` or `error` by default, custom types can also be defined) and associated data; the data associated with each event depends on its type. For the default events this data is: + +* `text` (text to display) is a list of text elements, each with a `text` field, containing the text contents, and a `tags` field, containing the tags associated with this text. +* `choice` (choices to choose from) is a list of tableas, each associated to a choice. Each of these choice is a list of text elements like for the `text` event. +* `return` (when the script ends) is the returned value. +* `error` (when the script error) is the error message. + +For some event types (`text` and `choice`), Anselme does not immediately sends the event as soon as they are available but appends them to a buffer of events that will be sent to your game on the next event flush line (empty lines). ``` Some text. @@ -419,7 +449,7 @@ Another text. Text in another event. ``` -Beyond theses pragmatic reasons, the event buffering also serves as a way to group together several lines. For example, choice A and B will be sent to the game at the same time and can therefore be assumed to be part of the same "choice block", as opposed to choice C wich will be sent alone: +Beyond technical reasons, the event buffering also serves as a way to group together several lines. For example, choice A and B will be sent to the game at the same time and can therefore be assumed to be part of the same "choice block", as opposed to choice C wich will be sent alone: ``` > Choice A @@ -439,15 +469,13 @@ $ reusable choice > Choice C ``` -Anselme will also flush events when the current event type change, so your game only has to handle a single event of a single type at a time. For example, this will send a text event, flush it, and then buffer a choice event: +Besides empty lines, Anselme will also automatically flush events when the current event type change (when reaching a choice line with a text event in the event buffer, or vice versa), so your game only has to handle a single event of a single type at a time. For example, this will send a text event, flush it, and then buffer a choice event: ``` Text > Choice ``` -Every event have a type (`text`, `choice`, `return` or `error` by default, custom types can also be defined), and consist of a `data` field, containing its contents, and a `tags` field, containing the tags at the time the event was created. - ### Identifiers Valid identifiers must be at least 1 caracters long and can contain anything except the caracters ``~`^+-=<>/[]*{}|\_!?,;:()"@&$#%`` (that is, every special caracter on a US keyboard except '). They can contain spaces. They can not start with a number. diff --git a/anselme.lua b/anselme.lua index c35e570..ac7a90d 100644 --- a/anselme.lua +++ b/anselme.lua @@ -6,11 +6,11 @@ local anselme = { -- api is incremented a each update which may break Lua API compatibility versions = { save = 1, - language = 15, - api = 1 + language = 16, + api = 2 }, -- version is incremented at each update - version = 16, + version = 17, --- currently running interpreter running = nil } @@ -336,6 +336,7 @@ local vm_mt = { end, --- set aliases for built-in variables ๐Ÿ‘๏ธ, ๐Ÿ”– and ๐Ÿ that will be defined on every new checkpoint and function + -- this does not affect variables that were defined before this function was called -- nil for no alias -- return self setaliases = function(self, seen, checkpoint, reached) @@ -461,9 +462,10 @@ local vm_mt = { event_buffer = nil, -- choice event choice_selected = nil, - choice_available = {}, -- skip next choices until next event change (to skip currently running choice block when resuming from a checkpoint) skip_choices_until_flush = nil, + -- captured events stack {[event type]=stack{fn, ...}, ...} + event_capture_stack = {}, -- interrupt interrupt = nil, -- tag stack diff --git a/interpreter/common.lua b/interpreter/common.lua index ed607ff..8c34047 100644 --- a/interpreter/common.lua +++ b/interpreter/common.lua @@ -3,7 +3,7 @@ local eval local common common = { - -- flush interpreter state to global state + --- merge interpreter state with global state merge_state = function(state) local global_vars = state.interpreter.global_state.variables for var, value in pairs(state.variables) do @@ -11,7 +11,7 @@ common = { state.variables[var] = nil end end, - -- returns a variable's value, evaluating a pending expression if neccessary + --- returns a variable's value, evaluating a pending expression if neccessary -- if you're sure the variable has already been evaluated, use state.variables[fqm] directly -- return var -- return nil, err @@ -28,7 +28,7 @@ common = { return var end end, - -- check truthyness of an anselme value + --- check truthyness of an anselme value truthy = function(val) if val.type == "number" then return val.value ~= 0 @@ -38,7 +38,7 @@ common = { return true end end, - -- compare two anselme value for equality + --- compare two anselme value for equality compare = function(a, b) if a.type ~= b.type then return false @@ -59,10 +59,10 @@ common = { return a.value == b.value end end, - -- format a anselme value to something printable + --- format a anselme value to something printable -- does not call custom {}() functions, only built-in ones, so it should not be able to fail -- str: if success - -- * nil, err: if error + -- nil, err: if error format = function(val) if atypes[val.type] and atypes[val.type].format then return atypes[val.type].format(val.value) @@ -70,8 +70,9 @@ common = { return nil, ("no formatter for type %q"):format(val.type) end end, + --- convert anselme value to lua -- lua value: if success (may be nil!) - -- * nil, err: if error + -- nil, err: if error to_lua = function(val) if atypes[val.type] and atypes[val.type].to_lua then return atypes[val.type].to_lua(val.value) @@ -79,8 +80,9 @@ common = { return nil, ("no Lua exporter for type %q"):format(val.type) end end, + --- convert lua value to anselme -- anselme value: if success - -- * nil, err: if error + -- nil, err: if error from_lua = function(val) if ltypes[type(val)] and ltypes[type(val)].to_anselme then return ltypes[type(val)].to_anselme(val) @@ -88,23 +90,36 @@ common = { return nil, ("no Lua importer for type %q"):format(type(val)) end end, + --- evaluate a text AST into a single Lua string -- string: if success - -- * nil, err: if error + -- nil, err: if error eval_text = function(state, text) - local s = "" + local l = {} + common.eval_text_callback(state, text, function(str) table.insert(l, str) end) + return table.concat(l) + end, + --- same as eval_text, but instead of building a Lua string, call callback for every evaluated part of the text + -- callback returns nil, err in case of error + -- true: if success + -- nil, err: if error + eval_text_callback = function(state, text, callback) for _, item in ipairs(text) do if type(item) == "string" then - s = s .. item + callback(item) else local v, e = eval(state, item) if not v then return v, e end v, e = common.format(v) if not v then return v, e end - s = s .. v + if v ~= "" then + local r, err = callback(v) + if err then return r, err end + end end end - return s + return true end, + --- check if an anselme value is of a certain type -- specificity(number): if var is of type type -- false: if not is_of_type = function(var, type) diff --git a/interpreter/expression.lua b/interpreter/expression.lua index 0a45190..1639abb 100644 --- a/interpreter/expression.lua +++ b/interpreter/expression.lua @@ -350,7 +350,7 @@ local function eval(state, exp) ret, e = run(state, fn.child) -- resume at last checkpoint else - local expr, err = expression(checkpoint.value, state, "") + local expr, err = expression(checkpoint.value, state, fn.namespace) if not expr then return expr, err end ret, e = eval(state, expr) end diff --git a/interpreter/interpreter.lua b/interpreter/interpreter.lua index e185832..be284d5 100644 --- a/interpreter/interpreter.lua +++ b/interpreter/interpreter.lua @@ -1,6 +1,8 @@ local eval -local truthy, merge_state, to_lua, eval_text, escape, get_variable +local truthy, merge_state, to_lua, escape, get_variable, eval_text_callback +local run_line, run_block +--- tag management local tags = { --- push new tags on top of the stack, from Anselme values push = function(self, state, val) @@ -13,10 +15,12 @@ local tags = { for k, v in pairs(to_lua(val)) do new[k] = v end -- add table.insert(state.interpreter.tags, new) + return self:len(state) end, --- same but do not merge with last stack item push_lua_no_merge = function(self, state, val) table.insert(state.interpreter.tags, val) + return self:len(state) end, -- pop tag table on top of the stack pop = function(self, state) @@ -31,6 +35,8 @@ local tags = { return #state.interpreter.tags end, --- pop item until we reached desired stack length + -- try to prefer this to pop if possible, so in case we mess up the stack somehow it will restore the stack to a good state + -- (we may allow tag push/pop from the user side at some point) trim = function(self, state, len) while #state.interpreter.tags > len do self:pop(state) @@ -38,31 +44,120 @@ local tags = { end } -local function write_event(state, type, data) - if state.interpreter.event_buffer and state.interpreter.event_type ~= type then - error(("previous event of type %q has not been flushed, can't write new %q event"):format(state.interpreter.event_type, type)) - end - if not state.interpreter.event_buffer then - state.interpreter.event_type = type - state.interpreter.event_buffer = {} - end - table.insert(state.interpreter.event_buffer, { data = data, tags = tags:current(state) }) -end +--- event buffer management +-- i.e. only for text and choice events +local events = { + --- add a new element to the event buffer + -- will flush if needed + -- returns true in case of success + -- returns nil, err in case of error + append = function(self, state, type, data) + if state.interpreter.event_capture_stack[type] then + local r, e = state.interpreter.event_capture_stack[type][#state.interpreter.event_capture_stack[type]](data) + if not r then return r, e end + else + local r, e = self:make_space_for(state, type) + if not r then return r, e end -local run_block + if not state.interpreter.event_buffer then + state.interpreter.event_type = type + state.interpreter.event_buffer = {} + end + + table.insert(state.interpreter.event_buffer, data) + end + return true + end, + --- add a new item in the last element (a list of elements) of the event buffer + -- will flush if needed + -- will use default or a new list if buffer is empty + -- returns true in case of success + -- returns nil, err in case of error + append_in_last = function(self, state, type, data, default) + local r, e = self:make_space_for(state, type) + if not r then return r, e end + + if not state.interpreter.event_buffer then + r, e = self:append(state, type, default or {}) + if not r then return r, e end + end + + table.insert(state.interpreter.event_buffer[#state.interpreter.event_buffer], data) + + return true + end, + + --- start capturing events of a certain type + -- when an event of the type is appended, fn will be called with this event data + -- and the event will not be added to the event buffer + -- fn returns nil, err in case of error + push_capture = function(self, state, type, fn) + if not state.interpreter.event_capture_stack[type] then + state.interpreter.event_capture_stack[type] = {} + end + table.insert(state.interpreter.event_capture_stack[type], fn) + end, + --- stop capturing events of a certain type. + -- must be called after a push_capture + -- this is handled by a stack so nested capturing is allowed. + pop_capture = function(self, state, type) + table.remove(state.interpreter.event_capture_stack[type]) + if #state.interpreter.event_capture_stack[type] == 0 then + state.interpreter.event_capture_stack[type] = nil + end + end, + + -- flush event buffer if it's neccessary to push an event of the given type + -- returns true in case of success + -- returns nil, err in case of error + make_space_for = function(self, state, type) + if state.interpreter.event_buffer and state.interpreter.event_type ~= type and not state.interpreter.event_capture_stack[type] then + return self:flush(state) + end + return true + end, + --- flush events and send them to the game if possible + -- returns true in case of success + -- returns nil, err in case of error + flush = function(self, state) + while state.interpreter.event_buffer do + local type, buffer = state.interpreter.event_type, state.interpreter.event_buffer + state.interpreter.event_type = nil + state.interpreter.event_buffer = nil + state.interpreter.skip_choices_until_flush = nil + -- yield + coroutine.yield(type, buffer) + -- run choice + if type == "choice" then + local sel = state.interpreter.choice_selected + state.interpreter.choice_selected = nil + if not sel or sel < 1 or sel > #buffer then + return nil, "invalid choice" + else + local choice = buffer[sel]._d + -- execute in expected tag & event capture state + local capture_state = state.interpreter.event_capture_stack + state.interpreter.event_capture_stack = {} + local i = tags:push_lua_no_merge(state, choice.tags) + local _, e = run_block(state, choice.block) + tags:trim(state, i-1) + state.interpreter.event_capture_stack = capture_state + if e then return nil, e end + -- we discard return value from choice block as the execution is delayed until an event flush + -- and we don't want to stop the execution of another function unexpectedly + end + end + end + return true + end +} -- returns var in case of success and there is a return -- return nil in case of success and there is no return -- return nil, err in case of error -local function run_line(state, line) +run_line = function(state, line) -- store line state.interpreter.running_line = line - -- if line intend to push an event, flush buffer it it's a different event - if line.push_event and state.interpreter.event_buffer and state.interpreter.event_type ~= line.push_event then - local v, e = run_line(state, { source = line.source, type = "flush_events" }) - if e then return v, e end - if v then return v end - end -- line types if line.type == "condition" then line.parent_block.last_condition_success = nil @@ -86,19 +181,27 @@ local function run_line(state, line) end end elseif line.type == "choice" then - local t, er = eval_text(state, line.text) - if not t then return t, er end - table.insert(state.interpreter.choice_available, { - tags = tags:current(state), - block = line.child - }) - write_event(state, "choice", t) + local v, e = events:make_space_for(state, "choice") + if not v then return v, ("%s; in automatic event flush at %s"):format(e, line.source) end + local currentTags = tags:current(state) + v, e = events:append(state, "choice", { _d = { tags = currentTags, block = line.child }}) -- new choice + if not v then return v, e end + events:push_capture(state, "text", function(event) + local v2, e2 = events:append_in_last(state, "choice", event, { _d = { tags = currentTags, block = line.child }}) + if not v2 then return v2, e2 end + end) + v, e = eval_text_callback(state, line.text, function(text) + local v2, e2 = events:append_in_last(state, "choice", { text = text, tags = currentTags }, { _d = { tags = currentTags, block = line.child }}) + if not v2 then return v2, e2 end + end) + events:pop_capture(state, "text") + if not v then return v, ("%s; at %s"):format(e, line.source) end elseif line.type == "tag" then local v, e = eval(state, line.expression) if not v then return v, ("%s; at %s"):format(e, line.source) end - tags:push(state, v) + local i = tags:push(state, v) v, e = run_block(state, line.child) - tags:pop(state) + tags:trim(state, i-1) if e then return v, e end if v then return v end elseif line.type == "return" then @@ -106,34 +209,18 @@ local function run_line(state, line) if not v then return v, ("%s; at %s"):format(e, line.source) end return v elseif line.type == "text" then - local t, er = eval_text(state, line.text) - if not t then return t, ("%s; at %s"):format(er, line.source) end - write_event(state, "text", t) + local v, e = events:make_space_for(state, "text") -- do this before any evaluation start + if not v then return v, ("%s; in automatic event flush at %s"):format(e, line.source) end + local currentTags = tags:current(state) + v, e = eval_text_callback(state, line.text, function(text) + -- why you would want to send a non-text event from there, I have no idea, but I'm not going to stop you + local v2, e2 = events:append(state, "text", { text = text, tags = currentTags }) + if not v2 then return v2, e2 end + end) + if not v then return v, ("%s; at %s"):format(e, line.source) end elseif line.type == "flush_events" then - while state.interpreter.event_buffer do - local type, buffer = state.interpreter.event_type, state.interpreter.event_buffer - state.interpreter.event_type = nil - state.interpreter.event_buffer = nil - -- yield - coroutine.yield(type, buffer) - -- run choice - if type == "choice" then - local sel = state.interpreter.choice_selected - state.interpreter.choice_selected = nil - if not sel or sel < 1 or sel > #state.interpreter.choice_available then - return nil, "invalid choice" - else - local choice = state.interpreter.choice_available[sel] - state.interpreter.choice_available = {} - tags:push_lua_no_merge(state, choice.tags) - local v, e = run_block(state, choice.block) - tags:pop(state) - if e then return v, e end - -- discard return value from choice block as the execution is delayed until an event flush - -- and we don't want to stop the execution of another function unexpectedly - end - end - end + local v, e = events:flush(state) + if not v then return v, ("%s; in event flush at %s"):format(e, line.source) end elseif line.type == "checkpoint" then local reached, reachede = get_variable(state, line.namespace.."๐Ÿ") if not reached then return nil, reachede end @@ -161,12 +248,8 @@ run_block = function(state, block, resume_from_there, i, j) local line = block[i] local skip = false -- skip current choice block if enabled - if state.interpreter.skip_choices_until_flush then - if line.type == "choice" then - skip = true - elseif line.type == "flush_events" or (line.push_event and line.push_event ~= "choice") then - state.interpreter.skip_choices_until_flush = nil - end + if state.interpreter.skip_choices_until_flush and line.type == "choice" then + skip = true end -- run line if not skip then @@ -253,7 +336,7 @@ local function run(state, block, resume_from_there, i, j) -- run local v, e = run_block(state, block, resume_from_there, i, j) -- return to previous tag state - -- tag stack pop when resuming is done when exiting the tag block + -- when resuming is done, tag stack pop when exiting the tag block -- stray elements may be left on the stack if there is a return before we exit all the tag block, so we trim them if resume_from_there then tags:trim(state, tags_len) @@ -280,7 +363,7 @@ local interpreter = { package.loaded[...] = interpreter eval = require((...):gsub("interpreter$", "expression")) local common = require((...):gsub("interpreter$", "common")) -truthy, merge_state, to_lua, eval_text, get_variable = common.truthy, common.merge_state, common.to_lua, common.eval_text, common.get_variable +truthy, merge_state, to_lua, get_variable, eval_text_callback = common.truthy, common.merge_state, common.to_lua, common.get_variable, common.eval_text_callback escape = require((...):gsub("interpreter%.interpreter$", "parser.common")).escape return interpreter diff --git a/parser/preparser.lua b/parser/preparser.lua index 6ff945a..6655474 100644 --- a/parser/preparser.lua +++ b/parser/preparser.lua @@ -42,7 +42,6 @@ local function parse_line(line, state, namespace) -- choice elseif l:match("^>") then r.type = "choice" - r.push_event = "choice" r.child = true r.text = l:match("^>%s*(.-)$") -- function & checkpoint @@ -271,7 +270,6 @@ local function parse_line(line, state, namespace) -- text elseif l:match("[^%s]") then r.type = "text" - r.push_event = "text" r.text = l -- flush events else diff --git a/test/run.lua b/test/run.lua index f4f95b4..3f208b4 100644 --- a/test/run.lua +++ b/test/run.lua @@ -3,24 +3,38 @@ local anselme = require("anselme") local ser = require("test.ser") local inspect = require("test.inspect") -local function format_text(t, prefix) - prefix = prefix or " " +local function format_text(t) local r = "" for _, l in ipairs(t) do - r = r .. prefix + -- format tags display local tags = "" for k, v in pairs(l.tags) do tags = tags .. ("[%q]=%q"):format(k, v) end + -- build text if tags ~= "" then - r = r .. ("[%s]%s"):format(tags, l.data) + r = r .. ("[%s]%s"):format(tags, l.text) else - r = r .. l.data + r = r .. l.text end end return r end +--- remove unneeded things from a result table (namely private fields) +local function strip(t, visited) + visited = visited or {} + for k, v in pairs(t) do + if type(k) == "string" and k:match("^_") then + t[k] = nil + end + if type(v) == "table" and not visited[v] then + visited[v] = true + strip(v, visited) + end + end +end + local function compare(a, b) if type(a) == "table" and type(b) == "table" then for k, v in pairs(a) do @@ -63,14 +77,25 @@ while i <= #arg do end end --- list tests -local files = {} -for item in lfs.dir("test/tests/") do - if item:match("%.ans$") and item:match(args.filter or "") then - table.insert(files, "test/tests/"..item) - end +if args.help then + print("Anselme test runner. Usage:") + print(" no arguments: perform included test suite") + print(" --script filename: test a script interactively") + print(" --game directory: test a game interactively") + print(" --help: display this message") + print("") + print("For test suite mode:") + print(" --filter pattern: only perform tests matching pattern") + print(" --write-all: rewrite all expected test results with current output") + print(" --write-new: write expected test results with current output for test that do not already have a saved expected output") + print(" --write-error: rewrite expected test results with current output for test with invalid output") + print(" --silent: silent output") + 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") + os.exit() end -table.sort(files) -- test script if args.script or args.game then @@ -99,7 +124,9 @@ if args.script or args.game then if t == "text" then print(format_text(d)) elseif t == "choice" then - print(format_text(d, "\n> ")) + for j, choice in ipairs(d) do + print(j.."> "..format_text(choice)) + end istate:choose(io.read()) elseif t == "error" then print(t, d) @@ -114,8 +141,19 @@ if args.script or args.game then if args.save then print(inspect(vm:save())) end --- run tests + +-- test mode else + -- list tests + local files = {} + for item in lfs.dir("test/tests/") do + if item:match("%.ans$") and item:match(args.filter or "") then + table.insert(files, "test/tests/"..item) + end + end + table.sort(files) + + -- run tests local total, success = #files, 0 for _, file in ipairs(files) do local filebase = file:match("^(.*)%.ans$") @@ -176,6 +214,8 @@ else table.insert(result, { "error", err }) end + strip(result) + if args["write-all"] then write_result(filebase, result) else @@ -190,6 +230,11 @@ else print(inspect(output)) print("") end + if args["write-error"] then + write_result(filebase, result) + print("Rewritten result file for "..filebase) + success = success + 1 + end else success = success + 1 end @@ -208,7 +253,7 @@ else end end end - if args.write then + if args["write-all"] then print("Wrote test results.") else print(("%s/%s tests success."):format(success, total)) diff --git a/test/tests/argument alias.lua b/test/tests/argument alias.lua index 482450d..13b38f4 100644 --- a/test/tests/argument alias.lua +++ b/test/tests/argument alias.lua @@ -1,14 +1,22 @@ local _={} -_[5]={} -_[4]={data="bibi = bibi",tags=_[5]} -_[3]={_[4]} +_[7]={} +_[6]={tags=_[7],text="bibi"} +_[5]={tags=_[7],text=" = "} +_[4]={tags=_[7],text="bibi"} +_[3]={_[4],_[5],_[6]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "bibi = bibi", - tags = {} + tags = <1>{}, + text = "bibi" + }, { + tags = , + text = " = " + }, { + tags =
, + text = "bibi" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/binary operator overload.lua b/test/tests/binary operator overload.lua index 728f831..991726f 100644 --- a/test/tests/binary operator overload.lua +++ b/test/tests/binary operator overload.lua @@ -2,9 +2,9 @@ local _={} _[13]={} _[12]={} _[11]={} -_[10]={data="generic minus",tags=_[13]} -_[9]={data="heh minus lol",tags=_[12]} -_[8]={data="-3",tags=_[11]} +_[10]={tags=_[13],text="generic minus"} +_[9]={tags=_[12],text="heh minus lol"} +_[8]={tags=_[11],text="-3"} _[7]={_[10]} _[6]={_[9]} _[5]={_[8]} @@ -15,16 +15,16 @@ _[1]={"text",_[5]} return {_[1],_[2],_[3],_[4]} --[[ { "text", { { - data = "-3", - tags = {} + tags = {}, + text = "-3" } } } { "text", { { - data = "heh minus lol", - tags = {} + tags = {}, + text = "heh minus lol" } } } { "text", { { - data = "generic minus", - tags = {} + tags = {}, + text = "generic minus" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/checkpoint change.ans b/test/tests/checkpoint change.ans new file mode 100644 index 0000000..0ab8586 --- /dev/null +++ b/test/tests/checkpoint change.ans @@ -0,0 +1,33 @@ +$ f + x + ยง p + a + + ยง q + b + + c + + d + +From start: +~ f + +From p checkpoint: +~ f + +From q checkpoint: +~ f + +From q checkpoint again: +~ f + +Force p checkpoint: +~ f.p() + +From q again: +~ f + +Go to p again by setting checkpoint manually: +~ f.checkpoint := "p" +~ f diff --git a/test/tests/checkpoint change.lua b/test/tests/checkpoint change.lua new file mode 100644 index 0000000..6eea480 --- /dev/null +++ b/test/tests/checkpoint change.lua @@ -0,0 +1,193 @@ +local _={} +_[91]={} +_[90]={} +_[89]={} +_[88]={} +_[87]={} +_[86]={} +_[85]={} +_[84]={} +_[83]={} +_[82]={} +_[81]={} +_[80]={} +_[79]={} +_[78]={} +_[77]={} +_[76]={} +_[75]={} +_[74]={} +_[73]={} +_[72]={} +_[71]={} +_[70]={} +_[69]={} +_[68]={} +_[67]={} +_[66]={} +_[65]={tags=_[91],text="d"} +_[64]={tags=_[90],text="c"} +_[63]={tags=_[89],text="a"} +_[62]={tags=_[88],text="Go to p again by setting checkpoint manually:"} +_[61]={tags=_[87],text="d"} +_[60]={tags=_[86],text="c"} +_[59]={tags=_[85],text="b"} +_[58]={tags=_[84],text="From q again:"} +_[57]={tags=_[83],text="c"} +_[56]={tags=_[82],text="a"} +_[55]={tags=_[81],text="Force p checkpoint:"} +_[54]={tags=_[80],text="d"} +_[53]={tags=_[79],text="c"} +_[52]={tags=_[78],text="b"} +_[51]={tags=_[77],text="From q checkpoint again:"} +_[50]={tags=_[76],text="d"} +_[49]={tags=_[75],text="c"} +_[48]={tags=_[74],text="b"} +_[47]={tags=_[73],text="From q checkpoint:"} +_[46]={tags=_[72],text="d"} +_[45]={tags=_[71],text="c"} +_[44]={tags=_[70],text="a"} +_[43]={tags=_[69],text="From p checkpoint:"} +_[42]={tags=_[68],text="d"} +_[41]={tags=_[67],text="x"} +_[40]={tags=_[66],text="From start:"} +_[39]={_[65]} +_[38]={_[64]} +_[37]={_[62],_[63]} +_[36]={_[61]} +_[35]={_[60]} +_[34]={_[58],_[59]} +_[33]={_[57]} +_[32]={_[55],_[56]} +_[31]={_[54]} +_[30]={_[53]} +_[29]={_[51],_[52]} +_[28]={_[50]} +_[27]={_[49]} +_[26]={_[47],_[48]} +_[25]={_[46]} +_[24]={_[45]} +_[23]={_[43],_[44]} +_[22]={_[42]} +_[21]={_[40],_[41]} +_[20]={"return"} +_[19]={"text",_[39]} +_[18]={"text",_[38]} +_[17]={"text",_[37]} +_[16]={"text",_[36]} +_[15]={"text",_[35]} +_[14]={"text",_[34]} +_[13]={"text",_[33]} +_[12]={"text",_[32]} +_[11]={"text",_[31]} +_[10]={"text",_[30]} +_[9]={"text",_[29]} +_[8]={"text",_[28]} +_[7]={"text",_[27]} +_[6]={"text",_[26]} +_[5]={"text",_[25]} +_[4]={"text",_[24]} +_[3]={"text",_[23]} +_[2]={"text",_[22]} +_[1]={"text",_[21]} +return {_[1],_[2],_[3],_[4],_[5],_[6],_[7],_[8],_[9],_[10],_[11],_[12],_[13],_[14],_[15],_[16],_[17],_[18],_[19],_[20]} +--[[ +{ "text", { { + tags = {}, + text = "From start:" + }, { + tags = {}, + text = "x" + } } } +{ "text", { { + tags = {}, + text = "d" + } } } +{ "text", { { + tags = {}, + text = "From p checkpoint:" + }, { + tags = {}, + text = "a" + } } } +{ "text", { { + tags = {}, + text = "c" + } } } +{ "text", { { + tags = {}, + text = "d" + } } } +{ "text", { { + tags = {}, + text = "From q checkpoint:" + }, { + tags = {}, + text = "b" + } } } +{ "text", { { + tags = {}, + text = "c" + } } } +{ "text", { { + tags = {}, + text = "d" + } } } +{ "text", { { + tags = {}, + text = "From q checkpoint again:" + }, { + tags = {}, + text = "b" + } } } +{ "text", { { + tags = {}, + text = "c" + } } } +{ "text", { { + tags = {}, + text = "d" + } } } +{ "text", { { + tags = {}, + text = "Force p checkpoint:" + }, { + tags = {}, + text = "a" + } } } +{ "text", { { + tags = {}, + text = "c" + } } } +{ "text", { { + tags = {}, + text = "From q again:" + }, { + tags = {}, + text = "b" + } } } +{ "text", { { + tags = {}, + text = "c" + } } } +{ "text", { { + tags = {}, + text = "d" + } } } +{ "text", { { + tags = {}, + text = "Go to p again by setting checkpoint manually:" + }, { + tags = {}, + text = "a" + } } } +{ "text", { { + tags = {}, + text = "c" + } } } +{ "text", { { + tags = {}, + text = "d" + } } } +{ "return" } +]]-- \ No newline at end of file diff --git a/test/tests/checkpoint reached seen.lua b/test/tests/checkpoint reached seen.lua index 0980bd2..04a0afd 100644 --- a/test/tests/checkpoint reached seen.lua +++ b/test/tests/checkpoint reached seen.lua @@ -1,19 +1,23 @@ local _={} +_[25]={} +_[24]={} +_[23]={} +_[22]={} _[21]={} -_[20]={} -_[19]={} -_[18]={} -_[17]={} -_[16]={data="Reached: 2",tags=_[21]} -_[15]={data="Seen: 1",tags=_[20]} -_[14]={data="seen!",tags=_[19]} -_[13]={data="Reached: 1",tags=_[18]} -_[12]={data="Seen: 0",tags=_[17]} -_[11]={_[16]} -_[10]={_[15]} -_[9]={_[14]} -_[8]={_[13]} -_[7]={_[12]} +_[20]={tags=_[25],text="2"} +_[19]={tags=_[25],text="Reached: "} +_[18]={tags=_[24],text="1"} +_[17]={tags=_[24],text="Seen: "} +_[16]={tags=_[23],text="seen!"} +_[15]={tags=_[22],text="1"} +_[14]={tags=_[22],text="Reached: "} +_[13]={tags=_[21],text="0"} +_[12]={tags=_[21],text="Seen: "} +_[11]={_[19],_[20]} +_[10]={_[17],_[18]} +_[9]={_[16]} +_[8]={_[14],_[15]} +_[7]={_[12],_[13]} _[6]={"return"} _[5]={"text",_[11]} _[4]={"text",_[10]} @@ -23,24 +27,36 @@ _[1]={"text",_[7]} return {_[1],_[2],_[3],_[4],_[5],_[6]} --[[ { "text", { { - data = "Seen: 0", - tags = {} + tags = <1>{}, + text = "Seen: " + }, { + tags =
, + text = "0" } } } { "text", { { - data = "Reached: 1", - tags = {} + tags = <1>{}, + text = "Reached: " + }, { + tags =
, + text = "1" } } } { "text", { { - data = "seen!", - tags = {} + tags = {}, + text = "seen!" } } } { "text", { { - data = "Seen: 1", - tags = {} + tags = <1>{}, + text = "Seen: " + }, { + tags =
, + text = "1" } } } { "text", { { - data = "Reached: 2", - tags = {} + tags = <1>{}, + text = "Reached: " + }, { + tags =
, + text = "2" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/choice block.lua b/test/tests/choice block.lua index 3600536..7edb258 100644 --- a/test/tests/choice block.lua +++ b/test/tests/choice block.lua @@ -1,16 +1,18 @@ local _={} +_[23]={} +_[22]={} _[21]={} -_[20]={} -_[19]={} +_[20]={tags=_[23],text="oh"} +_[19]={tags=_[21],text="ho"} _[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]} +_[17]={tags=_[18],text="ne"} +_[16]={tags=_[22],text="ye"} +_[15]={tags=_[21],text="plop"} +_[14]={_[20]} +_[13]={_[19]} +_[12]={tags=_[18],text="ok"} +_[11]={_[17]} +_[10]={_[16]} _[9]={_[15]} _[8]={_[13],_[14]} _[7]={_[12]} @@ -22,27 +24,27 @@ _[2]={"text",_[7]} _[1]={"choice",_[6]} return {_[1],_[2],_[3],_[4],_[5]} --[[ -{ "choice", { { - data = "ye", - tags = {} - }, { - data = "ne", - tags = {} - } } } +{ "choice", { { { + tags = {}, + text = "ye" + } }, { { + tags = {}, + text = "ne" + } } } } { "text", { { - data = "ok", - tags = {} - } } } -{ "choice", { { - data = "ho", - tags = {} - }, { - data = "oh", - tags = {} + tags = {}, + text = "ok" } } } +{ "choice", { { { + tags = {}, + text = "ho" + } }, { { + tags = {}, + text = "oh" + } } } } { "text", { { - data = "plop", - tags = {} + tags = {}, + text = "plop" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/choice function.lua b/test/tests/choice function.lua index 315354d..b965c9c 100644 --- a/test/tests/choice function.lua +++ b/test/tests/choice function.lua @@ -1,14 +1,17 @@ local _={} +_[18]={} +_[17]={} +_[16]={} _[15]={} -_[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]} +_[14]={tags=_[18],text="neol"} +_[13]={tags=_[15],text="oh"} +_[12]={tags=_[17],text="neol"} +_[11]={tags=_[16],text="ho"} +_[10]={tags=_[15],text="ok"} +_[9]={_[14]} +_[8]={_[13]} +_[7]={_[12]} +_[6]={_[11]} _[5]={_[10]} _[4]={_[6],_[7],_[8],_[9]} _[3]={"return"} @@ -16,22 +19,22 @@ _[2]={"text",_[5]} _[1]={"choice",_[4]} return {_[1],_[2],_[3]} --[[ -{ "choice", { { - data = "ho", - tags = {} - }, { - data = "neol", - tags = {} - }, { - data = "oh", - tags = {} - }, { - data = "neol", - tags = {} - } } } +{ "choice", { { { + tags = {}, + text = "ho" + } }, { { + tags = {}, + text = "neol" + } }, { { + tags = {}, + text = "oh" + } }, { { + tags = {}, + text = "neol" + } } } } { "text", { { - data = "ok", - tags = {} + tags = {}, + text = "ok" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/choice line interpolation with choice event.ans b/test/tests/choice line interpolation with choice event.ans new file mode 100644 index 0000000..834840d --- /dev/null +++ b/test/tests/choice line interpolation with choice event.ans @@ -0,0 +1,10 @@ +~ choose(1) +> Press {jump button} to jump. + ok +> No + ko + +$ jump button + A # 1 + > Suprise choice! + @"JOIN" diff --git a/test/tests/choice line interpolation with choice event.lua b/test/tests/choice line interpolation with choice event.lua new file mode 100644 index 0000000..f7f45e6 --- /dev/null +++ b/test/tests/choice line interpolation with choice event.lua @@ -0,0 +1,47 @@ +local _={} +_[19]={} +_[18]={} +_[17]={1} +_[16]={} +_[15]={text="No",tags=_[19]} +_[14]={text=" to jump.",tags=_[16]} +_[13]={text="JOIN",tags=_[16]} +_[12]={text="Suprise choice!",tags=_[18]} +_[11]={text="A",tags=_[17]} +_[10]={text="Press ",tags=_[16]} +_[9]={text="ok",tags=_[16]} +_[8]={_[15]} +_[7]={_[12],_[13],_[14]} +_[6]={_[10],_[11]} +_[5]={_[9]} +_[4]={_[6],_[7],_[8]} +_[3]={"return"} +_[2]={"text",_[5]} +_[1]={"choice",_[4]} +return {_[1],_[2],_[3]} +--[[ +{ "choice", { { { + tags = <1>{}, + text = "Press " + }, { + tags = { 1 }, + text = "A" + } }, { { + tags = {}, + text = "Suprise choice!" + }, { + tags =
, + text = "JOIN" + }, { + tags =
, + text = " to jump." + } }, { { + tags = {}, + text = "No" + } } } } +{ "text", { { + tags = {}, + text = "ok" + } } } +{ "return" } +]]-- \ No newline at end of file diff --git a/test/tests/choice line interpolation with event flush.ans b/test/tests/choice line interpolation with event flush.ans new file mode 100644 index 0000000..6c036fa --- /dev/null +++ b/test/tests/choice line interpolation with event flush.ans @@ -0,0 +1,11 @@ +~ choose(1) +> Press {jump button} to jump. + ok + ~ choose(1) +> No + ko + +$ jump button + A # 1 + + @"SPLIT" diff --git a/test/tests/choice line interpolation with event flush.lua b/test/tests/choice line interpolation with event flush.lua new file mode 100644 index 0000000..22cc45a --- /dev/null +++ b/test/tests/choice line interpolation with event flush.lua @@ -0,0 +1,55 @@ +local _={} +_[22]={} +_[21]={1} +_[20]={tags=_[22],text="No"} +_[19]={text=" to jump."} +_[18]={text="SPLIT"} +_[17]={} +_[16]={tags=_[21],text="A"} +_[15]={tags=_[17],text="Press "} +_[14]={tags=_[17],text="ok"} +_[13]={_[20]} +_[12]={_[18],_[19]} +_[11]={tags=_[17],text="ok"} +_[10]={_[15],_[16]} +_[9]={_[14]} +_[8]={_[12],_[13]} +_[7]={_[11]} +_[6]={_[10]} +_[5]={"return"} +_[4]={"text",_[9]} +_[3]={"choice",_[8]} +_[2]={"text",_[7]} +_[1]={"choice",_[6]} +_[0]={_[1],_[2],_[3],_[4],_[5]} +_[18].tags=_[17] +_[19].tags=_[17] +return _[0] +--[[ +{ "choice", { { { + tags = {}, + text = "Press " + }, { + tags = { 1 }, + text = "A" + } } } } +{ "text", { { + tags = {}, + text = "ok" + } } } +{ "choice", { { { + tags = <1>{}, + text = "SPLIT" + }, { + tags =
, + text = " to jump." + } }, { { + tags = {}, + text = "No" + } } } } +{ "text", { { + tags = {}, + text = "ok" + } } } +{ "return" } +]]-- \ No newline at end of file diff --git a/test/tests/choice line interpolation with text event.ans b/test/tests/choice line interpolation with text event.ans new file mode 100644 index 0000000..d177be0 --- /dev/null +++ b/test/tests/choice line interpolation with text event.ans @@ -0,0 +1,18 @@ +> Press {jump button} to jump. + ok +> No + ko +~ choose(1) + +$ jump button + A # 1 + +> Other + ko +> Use {move axis} to move. + ok +~ choose(2) + +$ move axis + left # 1 + @" joystick" diff --git a/test/tests/choice line interpolation with text event.lua b/test/tests/choice line interpolation with text event.lua new file mode 100644 index 0000000..62e9a1d --- /dev/null +++ b/test/tests/choice line interpolation with text event.lua @@ -0,0 +1,72 @@ +local _={} +_[30]={1} +_[29]={} +_[28]={} +_[27]={1} +_[26]={} +_[25]={tags=_[26],text=" to move."} +_[24]={tags=_[26],text=" joystick"} +_[23]={tags=_[30],text="left"} +_[22]={tags=_[26],text="Use "} +_[21]={tags=_[29],text="Other"} +_[20]={} +_[19]={tags=_[28],text="No"} +_[18]={tags=_[20],text=" to jump."} +_[17]={tags=_[27],text="A"} +_[16]={tags=_[20],text="Press "} +_[15]={tags=_[26],text="ok"} +_[14]={_[22],_[23],_[24],_[25]} +_[13]={_[21]} +_[12]={tags=_[20],text="ok"} +_[11]={_[19]} +_[10]={_[16],_[17],_[18]} +_[9]={_[15]} +_[8]={_[13],_[14]} +_[7]={_[12]} +_[6]={_[10],_[11]} +_[5]={"return"} +_[4]={"text",_[9]} +_[3]={"choice",_[8]} +_[2]={"text",_[7]} +_[1]={"choice",_[6]} +return {_[1],_[2],_[3],_[4],_[5]} +--[[ +{ "choice", { { { + tags = <1>{}, + text = "Press " + }, { + tags = { 1 }, + text = "A" + }, { + tags =
, + text = " to jump." + } }, { { + tags = {}, + text = "No" + } } } } +{ "text", { { + tags = {}, + text = "ok" + } } } +{ "choice", { { { + tags = {}, + text = "Other" + } }, { { + tags = <1>{}, + text = "Use " + }, { + tags = { 1 }, + text = "left" + }, { + tags =
, + text = " joystick" + }, { + tags =
, + text = " to move." + } } } } +{ "text", { { + tags = {}, + text = "ok" + } } } +{ "return" } +]]-- \ No newline at end of file diff --git a/test/tests/choice preserve tags.lua b/test/tests/choice preserve tags.lua index b01b74f..90cff95 100644 --- a/test/tests/choice preserve tags.lua +++ b/test/tests/choice preserve tags.lua @@ -1,17 +1,21 @@ local _={} -_[26]={} -_[25]={k="v"} -_[24]={42,k="v"} -_[23]={} -_[22]={42} -_[21]={data="f",tags=_[26]} -_[20]={data="e",tags=_[25]} -_[19]={data="b",tags=_[24]} -_[18]={data="d",tags=_[25]} -_[17]={data="a",tags=_[24]} -_[16]={data="b",tags=_[22]} -_[15]={data="c",tags=_[23]} -_[14]={data="a",tags=_[22]} +_[30]={} +_[29]={} +_[28]={k="v"} +_[27]={42,k="v"} +_[26]={tags=_[28],text="d"} +_[25]={tags=_[27],text="a"} +_[24]={42} +_[23]={tags=_[30],text="c"} +_[22]={tags=_[24],text="a"} +_[21]={tags=_[29],text="f"} +_[20]={tags=_[28],text="e"} +_[19]={tags=_[27],text="b"} +_[18]={_[26]} +_[17]={_[25]} +_[16]={tags=_[24],text="b"} +_[15]={_[23]} +_[14]={_[22]} _[13]={_[21]} _[12]={_[20]} _[11]={_[19]} @@ -27,43 +31,43 @@ _[2]={"text",_[9]} _[1]={"choice",_[8]} return {_[1],_[2],_[3],_[4],_[5],_[6],_[7]} --[[ -{ "choice", { { - data = "a", - tags = { 42 } - }, { - data = "c", - tags = {} - } } } +{ "choice", { { { + tags = { 42 }, + text = "a" + } }, { { + tags = {}, + text = "c" + } } } } { "text", { { - data = "b", - tags = { 42 } + tags = { 42 }, + text = "b" } } } -{ "choice", { { - data = "a", +{ "choice", { { { + tags = { 42, + k = "v" + }, + text = "a" + } }, { { + tags = { + k = "v" + }, + text = "d" + } } } } +{ "text", { { tags = { 42, k = "v" - } - }, { - data = "d", + }, + text = "b" + } } } +{ "text", { { tags = { k = "v" - } + }, + text = "e" } } } { "text", { { - data = "b", - tags = { 42, - k = "v" - } - } } } -{ "text", { { - data = "e", - tags = { - k = "v" - } - } } } -{ "text", { { - data = "f", - tags = {} + tags = {}, + text = "f" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/choice simple.lua b/test/tests/choice simple.lua index ee55413..88e67b6 100644 --- a/test/tests/choice simple.lua +++ b/test/tests/choice simple.lua @@ -1,10 +1,11 @@ local _={} +_[12]={} _[11]={} -_[10]={} -_[9]={} -_[8]={data="ok",tags=_[11]} -_[7]={data="ne",tags=_[10]} -_[6]={data="ye",tags=_[9]} +_[10]={tags=_[11],text="ne"} +_[9]={tags=_[12],text="ye"} +_[8]={tags=_[11],text="ok"} +_[7]={_[10]} +_[6]={_[9]} _[5]={_[8]} _[4]={_[6],_[7]} _[3]={"return"} @@ -12,16 +13,16 @@ _[2]={"text",_[5]} _[1]={"choice",_[4]} return {_[1],_[2],_[3]} --[[ -{ "choice", { { - data = "ye", - tags = {} - }, { - data = "ne", - tags = {} - } } } +{ "choice", { { { + tags = {}, + text = "ye" + } }, { { + tags = {}, + text = "ne" + } } } } { "text", { { - data = "ok", - tags = {} + tags = {}, + text = "ok" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/commit.lua b/test/tests/commit.lua index 0fe975a..3311efc 100644 --- a/test/tests/commit.lua +++ b/test/tests/commit.lua @@ -1,16 +1,20 @@ local _={} -_[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]} -_[9]={_[13]} -_[8]={_[12]} -_[7]={_[11]} -_[6]={_[10]} +_[21]={} +_[20]={} +_[19]={} +_[18]={} +_[17]={tags=_[21],text="2"} +_[16]={tags=_[21],text="parallel: "} +_[15]={tags=_[20],text="2"} +_[14]={tags=_[20],text="after: "} +_[13]={tags=_[19],text="5"} +_[12]={tags=_[19],text="parallel: "} +_[11]={tags=_[18],text="2"} +_[10]={tags=_[18],text="before: "} +_[9]={_[16],_[17]} +_[8]={_[14],_[15]} +_[7]={_[12],_[13]} +_[6]={_[10],_[11]} _[5]={"return"} _[4]={"text",_[9]} _[3]={"text",_[8]} @@ -19,20 +23,32 @@ _[1]={"text",_[6]} return {_[1],_[2],_[3],_[4],_[5]} --[[ { "text", { { - data = "before: 2", - tags = {} + tags = <1>{}, + text = "before: " + }, { + tags =
, + text = "2" } } } { "text", { { - data = "parallel: 5", - tags = {} + tags = <1>{}, + text = "parallel: " + }, { + tags =
, + text = "5" } } } { "text", { { - data = "after: 2", - tags = {} + tags = <1>{}, + text = "after: " + }, { + tags =
, + text = "2" } } } { "text", { { - data = "parallel: 2", - tags = {} + tags = <1>{}, + text = "parallel: " + }, { + tags =
, + text = "2" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/condition decorator.lua b/test/tests/condition decorator.lua index f5f9a03..13c947d 100644 --- a/test/tests/condition decorator.lua +++ b/test/tests/condition decorator.lua @@ -1,19 +1,19 @@ local _={} _[7]={} _[6]={} -_[5]={data="ok bis",tags=_[7]} -_[4]={data="ok",tags=_[6]} +_[5]={tags=_[7],text="ok bis"} +_[4]={tags=_[6],text="ok"} _[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "ok", - tags = {} + tags = {}, + text = "ok" }, { - data = "ok bis", - tags = {} + tags = {}, + text = "ok bis" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/condition else false.lua b/test/tests/condition else false.lua index c75476f..efc9631 100644 --- a/test/tests/condition else false.lua +++ b/test/tests/condition else false.lua @@ -1,14 +1,14 @@ local _={} _[5]={} -_[4]={data="ok",tags=_[5]} +_[4]={tags=_[5],text="ok"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "ok", - tags = {} + tags = {}, + text = "ok" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/condition else true.lua b/test/tests/condition else true.lua index c75476f..efc9631 100644 --- a/test/tests/condition else true.lua +++ b/test/tests/condition else true.lua @@ -1,14 +1,14 @@ local _={} _[5]={} -_[4]={data="ok",tags=_[5]} +_[4]={tags=_[5],text="ok"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "ok", - tags = {} + tags = {}, + text = "ok" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/condition elseif false.lua b/test/tests/condition elseif false.lua index c75476f..efc9631 100644 --- a/test/tests/condition elseif false.lua +++ b/test/tests/condition elseif false.lua @@ -1,14 +1,14 @@ local _={} _[5]={} -_[4]={data="ok",tags=_[5]} +_[4]={tags=_[5],text="ok"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "ok", - tags = {} + tags = {}, + text = "ok" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/condition elseif true.lua b/test/tests/condition elseif true.lua index c75476f..efc9631 100644 --- a/test/tests/condition elseif true.lua +++ b/test/tests/condition elseif true.lua @@ -1,14 +1,14 @@ local _={} _[5]={} -_[4]={data="ok",tags=_[5]} +_[4]={tags=_[5],text="ok"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "ok", - tags = {} + tags = {}, + text = "ok" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/condition true.lua b/test/tests/condition true.lua index c75476f..efc9631 100644 --- a/test/tests/condition true.lua +++ b/test/tests/condition true.lua @@ -1,14 +1,14 @@ local _={} _[5]={} -_[4]={data="ok",tags=_[5]} +_[4]={tags=_[5],text="ok"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "ok", - tags = {} + tags = {}, + text = "ok" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/custom event.lua b/test/tests/custom event.lua index 88ec1ce..2ca82b5 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],text="ho"} +_[5]={tags=_[7],text="ah"} _[4]={_[5],_[6]} _[3]={"return"} _[2]={"text",_[4]} @@ -11,11 +11,11 @@ return {_[1],_[2],_[3]} --[[ { "wait", 5 } { "text", { { - data = "ah", - tags = {} + tags = {}, + text = "ah" }, { - data = "ho", - tags = {} + tags = {}, + text = "ho" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/custom text formatting.lua b/test/tests/custom text formatting.lua index 0246063..7a5be31 100644 --- a/test/tests/custom text formatting.lua +++ b/test/tests/custom text formatting.lua @@ -1,14 +1,14 @@ local _={} _[5]={} -_[4]={data="Name: Darmanin\nAge: 38",tags=_[5]} +_[4]={tags=_[5],text="Name: Darmanin\nAge: 38"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "Name: Darmanin\nAge: 38", - tags = {} + tags = {}, + text = "Name: Darmanin\nAge: 38" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/equality operator.lua b/test/tests/equality operator.lua index d4c3d0d..de9c43d 100644 --- a/test/tests/equality operator.lua +++ b/test/tests/equality operator.lua @@ -1,28 +1,36 @@ local _={} -_[33]={} -_[32]={} -_[31]={} -_[30]={} -_[29]={} -_[28]={} -_[27]={} -_[26]={} -_[25]={data="1 = 1",tags=_[33]} -_[24]={data="0 = 0",tags=_[32]} -_[23]={data="0 = 0",tags=_[31]} -_[22]={data="0 = 0",tags=_[30]} -_[21]={data="0 = 0",tags=_[29]} -_[20]={data="1 = 1",tags=_[28]} -_[19]={data="0 = 0",tags=_[27]} -_[18]={data="0 = 0",tags=_[26]} -_[17]={_[25]} -_[16]={_[24]} -_[15]={_[23]} -_[14]={_[22]} -_[13]={_[21]} -_[12]={_[20]} -_[11]={_[19]} -_[10]={_[18]} +_[41]={} +_[40]={} +_[39]={} +_[38]={} +_[37]={} +_[36]={} +_[35]={} +_[34]={} +_[33]={tags=_[41],text="1"} +_[32]={tags=_[41],text="1 = "} +_[31]={tags=_[40],text="0"} +_[30]={tags=_[40],text="0 = "} +_[29]={tags=_[39],text="0"} +_[28]={tags=_[39],text="0 = "} +_[27]={tags=_[38],text="0"} +_[26]={tags=_[38],text="0 = "} +_[25]={tags=_[37],text="0"} +_[24]={tags=_[37],text="0 = "} +_[23]={tags=_[36],text="1"} +_[22]={tags=_[36],text="1 = "} +_[21]={tags=_[35],text="0"} +_[20]={tags=_[35],text="0 = "} +_[19]={tags=_[34],text="0"} +_[18]={tags=_[34],text="0 = "} +_[17]={_[32],_[33]} +_[16]={_[30],_[31]} +_[15]={_[28],_[29]} +_[14]={_[26],_[27]} +_[13]={_[24],_[25]} +_[12]={_[22],_[23]} +_[11]={_[20],_[21]} +_[10]={_[18],_[19]} _[9]={"return"} _[8]={"text",_[17]} _[7]={"text",_[16]} @@ -35,36 +43,60 @@ _[1]={"text",_[10]} return {_[1],_[2],_[3],_[4],_[5],_[6],_[7],_[8],_[9]} --[[ { "text", { { - data = "0 = 0", - tags = {} + tags = <1>{}, + text = "0 = " + }, { + tags =
, + text = "0" } } } { "text", { { - data = "0 = 0", - tags = {} + tags = <1>{}, + text = "0 = " + }, { + tags =
, + text = "0" } } } { "text", { { - data = "1 = 1", - tags = {} + tags = <1>{}, + text = "1 = " + }, { + tags =
, + text = "1" } } } { "text", { { - data = "0 = 0", - tags = {} + tags = <1>{}, + text = "0 = " + }, { + tags =
, + text = "0" } } } { "text", { { - data = "0 = 0", - tags = {} + tags = <1>{}, + text = "0 = " + }, { + tags =
, + text = "0" } } } { "text", { { - data = "0 = 0", - tags = {} + tags = <1>{}, + text = "0 = " + }, { + tags =
, + text = "0" } } } { "text", { { - data = "0 = 0", - tags = {} + tags = <1>{}, + text = "0 = " + }, { + tags =
, + text = "0" } } } { "text", { { - data = "1 = 1", - tags = {} + tags = <1>{}, + text = "1 = " + }, { + tags =
, + text = "1" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/flush.lua b/test/tests/flush.lua index 8add63e..2f7da9f 100644 --- a/test/tests/flush.lua +++ b/test/tests/flush.lua @@ -1,12 +1,14 @@ local _={} -_[17]={} +_[19]={} +_[18]={} +_[17]={tags=_[19],text="d"} _[16]={} -_[15]={} +_[15]={tags=_[18],text="b"} _[14]={} -_[13]={data="d",tags=_[17]} -_[12]={data="c",tags=_[16]} -_[11]={data="b",tags=_[15]} -_[10]={data="a",tags=_[14]} +_[13]={_[17]} +_[12]={tags=_[16],text="c"} +_[11]={_[15]} +_[10]={tags=_[14],text="a"} _[9]={_[13]} _[8]={_[12]} _[7]={_[11]} @@ -19,20 +21,20 @@ _[1]={"text",_[6]} return {_[1],_[2],_[3],_[4],_[5]} --[[ { "text", { { - data = "a", - tags = {} - } } } -{ "choice", { { - data = "b", - tags = {} + tags = {}, + text = "a" } } } +{ "choice", { { { + tags = {}, + text = "b" + } } } } { "text", { { - data = "c", - tags = {} - } } } -{ "choice", { { - data = "d", - tags = {} + tags = {}, + text = "c" } } } +{ "choice", { { { + tags = {}, + text = "d" + } } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function alias.lua b/test/tests/function alias.lua index 69c1089..aca155f 100644 --- a/test/tests/function alias.lua +++ b/test/tests/function alias.lua @@ -1,22 +1,38 @@ local _={} -_[9]={} -_[8]={} -_[7]={data="ye = ye",tags=_[9]} -_[6]={data="ok = ok",tags=_[8]} -_[5]={_[7]} -_[4]={_[6]} +_[13]={} +_[12]={} +_[11]={tags=_[13],text="ye"} +_[10]={tags=_[13],text=" = "} +_[9]={tags=_[13],text="ye"} +_[8]={tags=_[12],text="ok"} +_[7]={tags=_[12],text=" = "} +_[6]={tags=_[12],text="ok"} +_[5]={_[9],_[10],_[11]} +_[4]={_[6],_[7],_[8]} _[3]={"return"} _[2]={"text",_[5]} _[1]={"text",_[4]} return {_[1],_[2],_[3]} --[[ { "text", { { - data = "ok = ok", - tags = {} + tags = <1>{}, + text = "ok" + }, { + tags =
, + text = " = " + }, { + tags =
, + text = "ok" } } } { "text", { { - data = "ye = ye", - tags = {} + tags = <1>{}, + text = "ye" + }, { + tags =
, + text = " = " + }, { + tags =
, + text = "ye" } } } { "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..6ccb0a5 100644 --- a/test/tests/function arg vararg.lua +++ b/test/tests/function arg vararg.lua @@ -1,19 +1,19 @@ local _={} _[7]={} _[6]={} -_[5]={data="[o, k]",tags=_[7]} -_[4]={data="ok",tags=_[6]} +_[5]={tags=_[7],text="[o, k]"} +_[4]={tags=_[6],text="ok"} _[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "ok", - tags = {} + tags = {}, + text = "ok" }, { - data = "[o, k]", - tags = {} + tags = {}, + text = "[o, k]" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function arg.lua b/test/tests/function arg.lua index c75476f..efc9631 100644 --- a/test/tests/function arg.lua +++ b/test/tests/function arg.lua @@ -1,14 +1,14 @@ local _={} _[5]={} -_[4]={data="ok",tags=_[5]} +_[4]={tags=_[5],text="ok"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "ok", - tags = {} + tags = {}, + text = "ok" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function args vararg empty.lua b/test/tests/function args vararg empty.lua index fc7ecbe..013ecc1 100644 --- a/test/tests/function args vararg empty.lua +++ b/test/tests/function args vararg empty.lua @@ -1,19 +1,23 @@ local _={} +_[8]={} _[7]={} -_[6]={} -_[5]={data="[]",tags=_[7]} -_[4]={data="ok",tags=_[6]} -_[3]={_[4],_[5]} +_[6]={tags=_[8],text="[]"} +_[5]={tags=_[7],text="k"} +_[4]={tags=_[7],text="o"} +_[3]={_[4],_[5],_[6]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "ok", - tags = {} + tags = <1>{}, + text = "o" }, { - data = "[]", - tags = {} + tags =
, + text = "k" + }, { + tags = {}, + text = "[]" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function args vararg.lua b/test/tests/function args vararg.lua index 763d91a..4c56d4e 100644 --- a/test/tests/function args vararg.lua +++ b/test/tests/function args vararg.lua @@ -1,19 +1,23 @@ local _={} +_[8]={} _[7]={} -_[6]={} -_[5]={data="[o, k]",tags=_[7]} -_[4]={data="ok",tags=_[6]} -_[3]={_[4],_[5]} +_[6]={tags=_[8],text="[o, k]"} +_[5]={tags=_[7],text="k"} +_[4]={tags=_[7],text="o"} +_[3]={_[4],_[5],_[6]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "ok", - tags = {} + tags = <1>{}, + text = "o" }, { - data = "[o, k]", - tags = {} + tags =
, + text = "k" + }, { + tags = {}, + text = "[o, k]" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function args.lua b/test/tests/function args.lua index c75476f..5c81938 100644 --- a/test/tests/function args.lua +++ b/test/tests/function args.lua @@ -1,14 +1,18 @@ local _={} -_[5]={} -_[4]={data="ok",tags=_[5]} -_[3]={_[4]} +_[6]={} +_[5]={tags=_[6],text="k"} +_[4]={tags=_[6],text="o"} +_[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "ok", - tags = {} + tags = <1>{}, + text = "o" + }, { + tags =
, + text = "k" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function assignement.lua b/test/tests/function assignement.lua index 300798a..190c344 100644 --- a/test/tests/function assignement.lua +++ b/test/tests/function assignement.lua @@ -1,18 +1,20 @@ local _={} +_[23]={} +_[22]={} _[21]={} _[20]={} _[19]={} -_[18]={} -_[17]={} -_[16]={data="3",tags=_[21]} -_[15]={data="v2=ok",tags=_[20]} -_[14]={data="50",tags=_[19]} -_[13]={data="v=50",tags=_[18]} -_[12]={data="5",tags=_[17]} -_[11]={_[16]} -_[10]={_[15]} -_[9]={_[14]} -_[8]={_[13]} +_[18]={tags=_[23],text="3"} +_[17]={tags=_[22],text="ok"} +_[16]={tags=_[22],text="v2="} +_[15]={tags=_[21],text="50"} +_[14]={tags=_[20],text="50"} +_[13]={tags=_[20],text="v="} +_[12]={tags=_[19],text="5"} +_[11]={_[18]} +_[10]={_[16],_[17]} +_[9]={_[15]} +_[8]={_[13],_[14]} _[7]={_[12]} _[6]={"return"} _[5]={"text",_[11]} @@ -23,24 +25,30 @@ _[1]={"text",_[7]} return {_[1],_[2],_[3],_[4],_[5],_[6]} --[[ { "text", { { - data = "5", - tags = {} + tags = {}, + text = "5" } } } { "text", { { - data = "v=50", - tags = {} + tags = <1>{}, + text = "v=" + }, { + tags =
, + text = "50" } } } { "text", { { - data = "50", - tags = {} + tags = {}, + text = "50" } } } { "text", { { - data = "v2=ok", - tags = {} + tags = <1>{}, + text = "v2=" + }, { + tags =
, + text = "ok" } } } { "text", { { - data = "3", - tags = {} + tags = {}, + text = "3" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function custom type dispatch error.lua b/test/tests/function custom type dispatch error.lua index 93a1c39..3e0853f 100644 --- a/test/tests/function custom type dispatch error.lua +++ b/test/tests/function custom type dispatch error.lua @@ -1,13 +1,16 @@ local _={} -_[13]={} -_[12]={} -_[11]={} -_[10]={data="idk::esperanto::name::string is english or generic",tags=_[13]} -_[9]={data="pierre::french::name::string is french",tags=_[12]} -_[8]={data="bob::name::string is english or generic",tags=_[11]} -_[7]={_[10]} -_[6]={_[9]} -_[5]={_[8]} +_[16]={} +_[15]={} +_[14]={} +_[13]={tags=_[16],text=" is english or generic"} +_[12]={tags=_[16],text="idk::esperanto::name::string"} +_[11]={tags=_[15],text=" is french"} +_[10]={tags=_[15],text="pierre::french::name::string"} +_[9]={tags=_[14],text=" is english or generic"} +_[8]={tags=_[14],text="bob::name::string"} +_[7]={_[12],_[13]} +_[6]={_[10],_[11]} +_[5]={_[8],_[9]} _[4]={"error","no compatible function found for call to a(number); potential candidates were:\n\9function custom type dispatch error.a(name::string) (at test/tests/function custom type dispatch error.ans:5): argument name is not of expected type string\n\9function custom type dispatch error.a(name:nom::french name) (at test/tests/function custom type dispatch error.ans:8): argument name is not of expected type french::name::string; at test/tests/function custom type dispatch error.ans:17"} _[3]={"text",_[7]} _[2]={"text",_[6]} @@ -15,16 +18,25 @@ _[1]={"text",_[5]} return {_[1],_[2],_[3],_[4]} --[[ { "text", { { - data = "bob::name::string is english or generic", - tags = {} + tags = <1>{}, + text = "bob::name::string" + }, { + tags =
, + text = " is english or generic" } } } { "text", { { - data = "pierre::french::name::string is french", - tags = {} + tags = <1>{}, + text = "pierre::french::name::string" + }, { + tags =
, + text = " is french" } } } { "text", { { - data = "idk::esperanto::name::string is english or generic", - tags = {} + tags = <1>{}, + text = "idk::esperanto::name::string" + }, { + tags =
, + text = " is english or generic" } } } { "error", "no compatible function found for call to a(number); potential candidates were:\n\tfunction custom type dispatch error.a(name::string) (at test/tests/function custom type dispatch error.ans:5): argument name is not of expected type string\n\tfunction custom type dispatch error.a(name:nom::french name) (at test/tests/function custom type dispatch error.ans:8): argument name is not of expected type french::name::string; at test/tests/function custom type dispatch error.ans:17" } ]]-- \ No newline at end of file diff --git a/test/tests/function custom type dispatch.lua b/test/tests/function custom type dispatch.lua index a70d9e1..30ddd52 100644 --- a/test/tests/function custom type dispatch.lua +++ b/test/tests/function custom type dispatch.lua @@ -1,13 +1,16 @@ local _={} -_[13]={} -_[12]={} -_[11]={} -_[10]={data="idk::esperanto::name::string is english or generic",tags=_[13]} -_[9]={data="pierre::french::name::string is french",tags=_[12]} -_[8]={data="bob::name::string is english or generic",tags=_[11]} -_[7]={_[10]} -_[6]={_[9]} -_[5]={_[8]} +_[16]={} +_[15]={} +_[14]={} +_[13]={tags=_[16],text=" is english or generic"} +_[12]={tags=_[16],text="idk::esperanto::name::string"} +_[11]={tags=_[15],text=" is french"} +_[10]={tags=_[15],text="pierre::french::name::string"} +_[9]={tags=_[14],text=" is english or generic"} +_[8]={tags=_[14],text="bob::name::string"} +_[7]={_[12],_[13]} +_[6]={_[10],_[11]} +_[5]={_[8],_[9]} _[4]={"return"} _[3]={"text",_[7]} _[2]={"text",_[6]} @@ -15,16 +18,25 @@ _[1]={"text",_[5]} return {_[1],_[2],_[3],_[4]} --[[ { "text", { { - data = "bob::name::string is english or generic", - tags = {} + tags = <1>{}, + text = "bob::name::string" + }, { + tags =
, + text = " is english or generic" } } } { "text", { { - data = "pierre::french::name::string is french", - tags = {} + tags = <1>{}, + text = "pierre::french::name::string" + }, { + tags =
, + text = " is french" } } } { "text", { { - data = "idk::esperanto::name::string is english or generic", - tags = {} + tags = <1>{}, + text = "idk::esperanto::name::string" + }, { + tags =
, + text = " is english or generic" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function cycle.lua b/test/tests/function cycle.lua index f4a5748..dd54c30 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],text="b"} +_[15]={tags=_[20],text="a"} +_[14]={tags=_[19],text="c"} +_[13]={tags=_[18],text="b"} +_[12]={tags=_[17],text="a"} _[11]={_[16]} _[10]={_[15]} _[9]={_[14]} @@ -23,24 +23,24 @@ _[1]={"text",_[7]} return {_[1],_[2],_[3],_[4],_[5],_[6]} --[[ { "text", { { - data = "a", - tags = {} + tags = {}, + text = "a" } } } { "text", { { - data = "b", - tags = {} + tags = {}, + text = "b" } } } { "text", { { - data = "c", - tags = {} + tags = {}, + text = "c" } } } { "text", { { - data = "a", - tags = {} + tags = {}, + text = "a" } } } { "text", { { - data = "b", - tags = {} + tags = {}, + text = "b" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function decorator scope explicit call.lua b/test/tests/function decorator scope explicit call.lua index f4169f2..f021ef0 100644 --- a/test/tests/function decorator scope explicit call.lua +++ b/test/tests/function decorator scope explicit call.lua @@ -1,22 +1,30 @@ 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]} -_[5]={_[7]} -_[4]={_[6]} +_[11]={} +_[10]={} +_[9]={tags=_[11],text="1"} +_[8]={tags=_[11],text="a.\240\159\145\129\239\184\143: "} +_[7]={tags=_[10],text="0"} +_[6]={tags=_[10],text="a.\240\159\145\129\239\184\143: "} +_[5]={_[8],_[9]} +_[4]={_[6],_[7]} _[3]={"return"} _[2]={"text",_[5]} _[1]={"text",_[4]} return {_[1],_[2],_[3]} --[[ { "text", { { - data = "a.๐Ÿ‘๏ธ: 0", - tags = {} + tags = <1>{}, + text = "a.๐Ÿ‘๏ธ: " + }, { + tags =
, + text = "0" } } } { "text", { { - data = "a.๐Ÿ‘๏ธ: 1", - tags = {} + tags = <1>{}, + text = "a.๐Ÿ‘๏ธ: " + }, { + tags =
, + text = "1" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function decorator scope implicit call.lua b/test/tests/function decorator scope implicit call.lua index 440e665..914e22b 100644 --- a/test/tests/function decorator scope implicit call.lua +++ b/test/tests/function decorator scope implicit call.lua @@ -1,37 +1,45 @@ local _={} +_[17]={} +_[16]={} _[15]={} _[14]={} _[13]={} -_[12]={} -_[11]={} -_[10]={data="ok",tags=_[15]} -_[9]={data="a.\240\159\145\129\239\184\143: 1",tags=_[14]} -_[8]={data="ko",tags=_[13]} -_[7]={data="In function:",tags=_[12]} -_[6]={data="a.\240\159\145\129\239\184\143: 0",tags=_[11]} -_[5]={_[7],_[8],_[9],_[10]} -_[4]={_[6]} +_[12]={tags=_[17],text="ok"} +_[11]={tags=_[16],text="1"} +_[10]={tags=_[16],text="a.\240\159\145\129\239\184\143: "} +_[9]={tags=_[15],text="ko"} +_[8]={tags=_[14],text="In function:"} +_[7]={tags=_[13],text="0"} +_[6]={tags=_[13],text="a.\240\159\145\129\239\184\143: "} +_[5]={_[8],_[9],_[10],_[11],_[12]} +_[4]={_[6],_[7]} _[3]={"return"} _[2]={"text",_[5]} _[1]={"text",_[4]} return {_[1],_[2],_[3]} --[[ { "text", { { - data = "a.๐Ÿ‘๏ธ: 0", - tags = {} + tags = <1>{}, + text = "a.๐Ÿ‘๏ธ: " + }, { + tags =
, + text = "0" } } } { "text", { { - data = "In function:", - tags = {} + tags = {}, + text = "In function:" }, { - data = "ko", - tags = {} + tags = {}, + text = "ko" }, { - data = "a.๐Ÿ‘๏ธ: 1", - tags = {} + tags = <1>{}, + text = "a.๐Ÿ‘๏ธ: " }, { - data = "ok", - tags = {} + tags =
, + text = "1" + }, { + tags = {}, + text = "ok" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function decorator scope.lua b/test/tests/function decorator scope.lua index 514bf2c..5d7e948 100644 --- a/test/tests/function decorator scope.lua +++ b/test/tests/function decorator scope.lua @@ -1,14 +1,18 @@ local _={} -_[5]={} -_[4]={data="a.\240\159\145\129\239\184\143: 0",tags=_[5]} -_[3]={_[4]} +_[6]={} +_[5]={tags=_[6],text="0"} +_[4]={tags=_[6],text="a.\240\159\145\129\239\184\143: "} +_[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "a.๐Ÿ‘๏ธ: 0", - tags = {} + tags = <1>{}, + text = "a.๐Ÿ‘๏ธ: " + }, { + tags =
, + text = "0" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function name dispatch.lua b/test/tests/function name dispatch.lua index 1bea444..df94781 100644 --- a/test/tests/function name dispatch.lua +++ b/test/tests/function name dispatch.lua @@ -1,8 +1,8 @@ local _={} _[9]={} _[8]={} -_[7]={data="x",tags=_[9]} -_[6]={data="a",tags=_[8]} +_[7]={tags=_[9],text="x"} +_[6]={tags=_[8],text="a"} _[5]={_[7]} _[4]={_[6]} _[3]={"return"} @@ -11,12 +11,12 @@ _[1]={"text",_[4]} return {_[1],_[2],_[3]} --[[ { "text", { { - data = "a", - tags = {} + tags = {}, + text = "a" } } } { "text", { { - data = "x", - tags = {} + tags = {}, + text = "x" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function next.lua b/test/tests/function next.lua index 5574217..9d13f0f 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],text="c"} +_[15]={tags=_[20],text="c"} +_[14]={tags=_[19],text="c"} +_[13]={tags=_[18],text="b"} +_[12]={tags=_[17],text="a"} _[11]={_[16]} _[10]={_[15]} _[9]={_[14]} @@ -23,24 +23,24 @@ _[1]={"text",_[7]} return {_[1],_[2],_[3],_[4],_[5],_[6]} --[[ { "text", { { - data = "a", - tags = {} + tags = {}, + text = "a" } } } { "text", { { - data = "b", - tags = {} + tags = {}, + text = "b" } } } { "text", { { - data = "c", - tags = {} + tags = {}, + text = "c" } } } { "text", { { - data = "c", - tags = {} + tags = {}, + text = "c" } } } { "text", { { - data = "c", - tags = {} + tags = {}, + text = "c" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function random.lua b/test/tests/function random.lua index a029213..cd9f889 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="a",tags=_[20]} -_[14]={data="b",tags=_[19]} -_[13]={data="a",tags=_[18]} -_[12]={data="b",tags=_[17]} +_[16]={tags=_[21],text="a"} +_[15]={tags=_[20],text="a"} +_[14]={tags=_[19],text="b"} +_[13]={tags=_[18],text="a"} +_[12]={tags=_[17],text="b"} _[11]={_[16]} _[10]={_[15]} _[9]={_[14]} @@ -23,24 +23,24 @@ _[1]={"text",_[7]} return {_[1],_[2],_[3],_[4],_[5],_[6]} --[[ { "text", { { - data = "b", - tags = {} + tags = {}, + text = "b" } } } { "text", { { - data = "a", - tags = {} + tags = {}, + text = "a" } } } { "text", { { - data = "b", - tags = {} + tags = {}, + text = "b" } } } { "text", { { - data = "a", - tags = {} + tags = {}, + text = "a" } } } { "text", { { - data = "a", - tags = {} + tags = {}, + text = "a" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function return exit function nested.lua b/test/tests/function return exit function nested.lua index baedcdc..f07424a 100644 --- a/test/tests/function return exit function nested.lua +++ b/test/tests/function return exit function nested.lua @@ -1,19 +1,19 @@ local _={} _[7]={} _[6]={} -_[5]={data="2",tags=_[7]} -_[4]={data="5",tags=_[6]} +_[5]={tags=_[7],text="2"} +_[4]={tags=_[6],text="5"} _[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "5", - tags = {} + tags = {}, + text = "5" }, { - data = "2", - tags = {} + tags = {}, + text = "2" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function return exit function.lua b/test/tests/function return exit function.lua index 9d39b3d..6296c24 100644 --- a/test/tests/function return exit function.lua +++ b/test/tests/function return exit function.lua @@ -1,14 +1,14 @@ local _={} _[5]={} -_[4]={data="5",tags=_[5]} +_[4]={tags=_[5],text="5"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "5", - tags = {} + tags = {}, + text = "5" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function return nested.lua b/test/tests/function return nested.lua index baedcdc..f07424a 100644 --- a/test/tests/function return nested.lua +++ b/test/tests/function return nested.lua @@ -1,19 +1,19 @@ local _={} _[7]={} _[6]={} -_[5]={data="2",tags=_[7]} -_[4]={data="5",tags=_[6]} +_[5]={tags=_[7],text="2"} +_[4]={tags=_[6],text="5"} _[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "5", - tags = {} + tags = {}, + text = "5" }, { - data = "2", - tags = {} + tags = {}, + text = "2" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function return.lua b/test/tests/function return.lua index 9d39b3d..6296c24 100644 --- a/test/tests/function return.lua +++ b/test/tests/function return.lua @@ -1,14 +1,14 @@ local _={} _[5]={} -_[4]={data="5",tags=_[5]} +_[4]={tags=_[5],text="5"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "5", - tags = {} + tags = {}, + text = "5" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function scope.lua b/test/tests/function scope.lua index ab7c161..4055219 100644 --- a/test/tests/function scope.lua +++ b/test/tests/function scope.lua @@ -1,14 +1,18 @@ local _={} -_[5]={} -_[4]={data="a: 5",tags=_[5]} -_[3]={_[4]} +_[6]={} +_[5]={tags=_[6],text="5"} +_[4]={tags=_[6],text="a: "} +_[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "a: 5", - tags = {} + tags = <1>{}, + text = "a: " + }, { + tags =
, + text = "5" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function selection.lua b/test/tests/function selection.lua index 58f6655..e39f511 100644 --- a/test/tests/function selection.lua +++ b/test/tests/function selection.lua @@ -1,8 +1,8 @@ local _={} _[9]={} _[8]={} -_[7]={data="4",tags=_[9]} -_[6]={data="plopheh",tags=_[8]} +_[7]={tags=_[9],text="4"} +_[6]={tags=_[8],text="plopheh"} _[5]={_[7]} _[4]={_[6]} _[3]={"return"} @@ -11,12 +11,12 @@ _[1]={"text",_[4]} return {_[1],_[2],_[3]} --[[ { "text", { { - data = "plopheh", - tags = {} + tags = {}, + text = "plopheh" } } } { "text", { { - data = "4", - tags = {} + tags = {}, + text = "4" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function separate variable from variants.lua b/test/tests/function separate variable from variants.lua index 795296f..6be60bf 100644 --- a/test/tests/function separate variable from variants.lua +++ b/test/tests/function separate variable from variants.lua @@ -1,14 +1,18 @@ local _={} -_[5]={} -_[4]={data="2 = 2",tags=_[5]} -_[3]={_[4]} +_[6]={} +_[5]={tags=_[6],text=" = 2"} +_[4]={tags=_[6],text="2"} +_[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "2 = 2", - tags = {} + tags = <1>{}, + text = "2" + }, { + tags =
, + text = " = 2" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function type dispatch with default.lua b/test/tests/function type dispatch with default.lua index 3c90759..4ea3755 100644 --- a/test/tests/function type dispatch with default.lua +++ b/test/tests/function type dispatch with default.lua @@ -10,17 +10,17 @@ _[24]={} _[23]={} _[22]={} _[21]={} -_[20]={data="gn",tags=_[31]} -_[19]={data="gs",tags=_[30]} -_[18]={data="gn",tags=_[29]} -_[17]={data="gs",tags=_[28]} -_[16]={data="gn",tags=_[27]} -_[15]={data="gs",tags=_[26]} -_[14]={data="gn",tags=_[25]} -_[13]={data="gs",tags=_[24]} -_[12]={data="a",tags=_[23]} -_[11]={data="x",tags=_[22]} -_[10]={data="a",tags=_[21]} +_[20]={tags=_[31],text="gn"} +_[19]={tags=_[30],text="gs"} +_[18]={tags=_[29],text="gn"} +_[17]={tags=_[28],text="gs"} +_[16]={tags=_[27],text="gn"} +_[15]={tags=_[26],text="gs"} +_[14]={tags=_[25],text="gn"} +_[13]={tags=_[24],text="gs"} +_[12]={tags=_[23],text="a"} +_[11]={tags=_[22],text="x"} +_[10]={tags=_[21],text="a"} _[9]={_[13],_[14],_[15],_[16],_[17],_[18],_[19],_[20]} _[8]={_[12]} _[7]={_[11]} @@ -33,41 +33,41 @@ _[1]={"text",_[6]} return {_[1],_[2],_[3],_[4],_[5]} --[[ { "text", { { - data = "a", - tags = {} + tags = {}, + text = "a" } } } { "text", { { - data = "x", - tags = {} + tags = {}, + text = "x" } } } { "text", { { - data = "a", - tags = {} + tags = {}, + text = "a" } } } { "text", { { - data = "gs", - tags = {} + tags = {}, + text = "gs" }, { - data = "gn", - tags = {} + tags = {}, + text = "gn" }, { - data = "gs", - tags = {} + tags = {}, + text = "gs" }, { - data = "gn", - tags = {} + tags = {}, + text = "gn" }, { - data = "gs", - tags = {} + tags = {}, + text = "gs" }, { - data = "gn", - tags = {} + tags = {}, + text = "gn" }, { - data = "gs", - tags = {} + tags = {}, + text = "gs" }, { - data = "gn", - tags = {} + tags = {}, + text = "gn" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function type dispatch.lua b/test/tests/function type dispatch.lua index 1bea444..df94781 100644 --- a/test/tests/function type dispatch.lua +++ b/test/tests/function type dispatch.lua @@ -1,8 +1,8 @@ local _={} _[9]={} _[8]={} -_[7]={data="x",tags=_[9]} -_[6]={data="a",tags=_[8]} +_[7]={tags=_[9],text="x"} +_[6]={tags=_[8],text="a"} _[5]={_[7]} _[4]={_[6]} _[3]={"return"} @@ -11,12 +11,12 @@ _[1]={"text",_[4]} return {_[1],_[2],_[3]} --[[ { "text", { { - data = "a", - tags = {} + tags = {}, + text = "a" } } } { "text", { { - data = "x", - tags = {} + tags = {}, + text = "x" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function ufcs arg.lua b/test/tests/function ufcs arg.lua index b6c0803..229c5dc 100644 --- a/test/tests/function ufcs arg.lua +++ b/test/tests/function ufcs arg.lua @@ -1,8 +1,8 @@ local _={} _[9]={} _[8]={} -_[7]={data="ok",tags=_[9]} -_[6]={data="ok",tags=_[8]} +_[7]={tags=_[9],text="ok"} +_[6]={tags=_[8],text="ok"} _[5]={_[7]} _[4]={_[6]} _[3]={"return"} @@ -11,12 +11,12 @@ _[1]={"text",_[4]} return {_[1],_[2],_[3]} --[[ { "text", { { - data = "ok", - tags = {} + tags = {}, + text = "ok" } } } { "text", { { - data = "ok", - tags = {} + tags = {}, + text = "ok" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function ufcs args.lua b/test/tests/function ufcs args.lua index c75476f..5c81938 100644 --- a/test/tests/function ufcs args.lua +++ b/test/tests/function ufcs args.lua @@ -1,14 +1,18 @@ local _={} -_[5]={} -_[4]={data="ok",tags=_[5]} -_[3]={_[4]} +_[6]={} +_[5]={tags=_[6],text="k"} +_[4]={tags=_[6],text="o"} +_[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "ok", - tags = {} + tags = <1>{}, + text = "o" + }, { + tags =
, + text = "k" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function vararg empty.lua b/test/tests/function vararg empty.lua index 25ed63e..d9a3d85 100644 --- a/test/tests/function vararg empty.lua +++ b/test/tests/function vararg empty.lua @@ -1,14 +1,14 @@ local _={} _[5]={} -_[4]={data="[]",tags=_[5]} +_[4]={tags=_[5],text="[]"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "[]", - tags = {} + tags = {}, + text = "[]" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function vararg.lua b/test/tests/function vararg.lua index 4b57911..41da986 100644 --- a/test/tests/function vararg.lua +++ b/test/tests/function vararg.lua @@ -1,14 +1,14 @@ local _={} _[5]={} -_[4]={data="[o, k]",tags=_[5]} +_[4]={tags=_[5],text="[o, k]"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "[o, k]", - tags = {} + tags = {}, + text = "[o, k]" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/function.lua b/test/tests/function.lua index c75476f..efc9631 100644 --- a/test/tests/function.lua +++ b/test/tests/function.lua @@ -1,14 +1,14 @@ local _={} _[5]={} -_[4]={data="ok",tags=_[5]} +_[4]={tags=_[5],text="ok"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "ok", - tags = {} + tags = {}, + text = "ok" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/interrupt callback nested paragraph.lua b/test/tests/interrupt callback nested paragraph.lua index 35ff609..ad68679 100644 --- a/test/tests/interrupt callback nested paragraph.lua +++ b/test/tests/interrupt callback nested paragraph.lua @@ -1,12 +1,14 @@ local _={} +_[14]={} +_[13]={} _[12]={} -_[11]={} -_[10]={} -_[9]={data="no",tags=_[12]} -_[8]={data="in interrupt: 5",tags=_[11]} -_[7]={data="before: 2",tags=_[10]} -_[6]={_[8],_[9]} -_[5]={_[7]} +_[11]={tags=_[14],text="no"} +_[10]={tags=_[13],text="5"} +_[9]={tags=_[13],text="in interrupt: "} +_[8]={tags=_[12],text="2"} +_[7]={tags=_[12],text="before: "} +_[6]={_[9],_[10],_[11]} +_[5]={_[7],_[8]} _[4]={"return"} _[3]={"text",_[6]} _[2]={"wait",0} @@ -14,16 +16,22 @@ _[1]={"text",_[5]} return {_[1],_[2],_[3],_[4]} --[[ { "text", { { - data = "before: 2", - tags = {} + tags = <1>{}, + text = "before: " + }, { + tags =
, + text = "2" } } } { "wait", 0 } { "text", { { - data = "in interrupt: 5", - tags = {} + tags = <1>{}, + text = "in interrupt: " }, { - data = "no", - tags = {} + tags =
, + text = "5" + }, { + tags = {}, + text = "no" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/interrupt callback nested.lua b/test/tests/interrupt callback nested.lua index 0a29f65..97d6750 100644 --- a/test/tests/interrupt callback nested.lua +++ b/test/tests/interrupt callback nested.lua @@ -1,10 +1,12 @@ local _={} -_[10]={} -_[9]={} -_[8]={data="in interrupt: 5",tags=_[10]} -_[7]={data="before: 2",tags=_[9]} -_[6]={_[8]} -_[5]={_[7]} +_[12]={} +_[11]={} +_[10]={tags=_[12],text="5"} +_[9]={tags=_[12],text="in interrupt: "} +_[8]={tags=_[11],text="2"} +_[7]={tags=_[11],text="before: "} +_[6]={_[9],_[10]} +_[5]={_[7],_[8]} _[4]={"return"} _[3]={"text",_[6]} _[2]={"wait",0} @@ -12,13 +14,19 @@ _[1]={"text",_[5]} return {_[1],_[2],_[3],_[4]} --[[ { "text", { { - data = "before: 2", - tags = {} + tags = <1>{}, + text = "before: " + }, { + tags =
, + text = "2" } } } { "wait", 0 } { "text", { { - data = "in interrupt: 5", - tags = {} + tags = <1>{}, + text = "in interrupt: " + }, { + tags =
, + text = "5" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/interrupt callback.lua b/test/tests/interrupt callback.lua index 0a29f65..97d6750 100644 --- a/test/tests/interrupt callback.lua +++ b/test/tests/interrupt callback.lua @@ -1,10 +1,12 @@ local _={} -_[10]={} -_[9]={} -_[8]={data="in interrupt: 5",tags=_[10]} -_[7]={data="before: 2",tags=_[9]} -_[6]={_[8]} -_[5]={_[7]} +_[12]={} +_[11]={} +_[10]={tags=_[12],text="5"} +_[9]={tags=_[12],text="in interrupt: "} +_[8]={tags=_[11],text="2"} +_[7]={tags=_[11],text="before: "} +_[6]={_[9],_[10]} +_[5]={_[7],_[8]} _[4]={"return"} _[3]={"text",_[6]} _[2]={"wait",0} @@ -12,13 +14,19 @@ _[1]={"text",_[5]} return {_[1],_[2],_[3],_[4]} --[[ { "text", { { - data = "before: 2", - tags = {} + tags = <1>{}, + text = "before: " + }, { + tags =
, + text = "2" } } } { "wait", 0 } { "text", { { - data = "in interrupt: 5", - tags = {} + tags = <1>{}, + text = "in interrupt: " + }, { + tags =
, + text = "5" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/interrupt no callback.lua b/test/tests/interrupt no callback.lua index 3c4fc54..d1c20dd 100644 --- a/test/tests/interrupt no callback.lua +++ b/test/tests/interrupt no callback.lua @@ -1,15 +1,19 @@ local _={} -_[6]={} -_[5]={data="before: 2",tags=_[6]} -_[4]={_[5]} +_[7]={} +_[6]={tags=_[7],text="2"} +_[5]={tags=_[7],text="before: "} +_[4]={_[5],_[6]} _[3]={"return",""} _[2]={"wait",0} _[1]={"text",_[4]} return {_[1],_[2],_[3]} --[[ { "text", { { - data = "before: 2", - tags = {} + tags = <1>{}, + text = "before: " + }, { + tags =
, + text = "2" } } } { "wait", 0 } { "return", "" } diff --git a/test/tests/lazy boolean operators.lua b/test/tests/lazy boolean operators.lua index cd7d7de..faee7ea 100644 --- a/test/tests/lazy boolean operators.lua +++ b/test/tests/lazy boolean operators.lua @@ -1,4 +1,12 @@ local _={} +_[65]={} +_[64]={} +_[63]={} +_[62]={} +_[61]={} +_[60]={} +_[59]={} +_[58]={} _[57]={} _[56]={} _[55]={} @@ -11,42 +19,42 @@ _[49]={} _[48]={} _[47]={} _[46]={} -_[45]={} -_[44]={} -_[43]={} -_[42]={} -_[41]={} -_[40]={} -_[39]={} -_[38]={} -_[37]={data="0 = b b 0",tags=_[57]} -_[36]={data="b",tags=_[56]} -_[35]={data="b",tags=_[55]} -_[34]={data="1 = a 1",tags=_[54]} -_[33]={data="a",tags=_[53]} -_[32]={data="1 = b a 1",tags=_[52]} -_[31]={data="a",tags=_[51]} -_[30]={data="b",tags=_[50]} -_[29]={data="1 = a 1",tags=_[49]} -_[28]={data="a",tags=_[48]} -_[27]={data="0 = b 0",tags=_[47]} -_[26]={data="b",tags=_[46]} -_[25]={data="1 = a a 1",tags=_[45]} -_[24]={data="a",tags=_[44]} -_[23]={data="a",tags=_[43]} -_[22]={data="0 = b 0",tags=_[42]} -_[21]={data="b",tags=_[41]} -_[20]={data="0 = a b 0",tags=_[40]} -_[19]={data="b",tags=_[39]} -_[18]={data="a",tags=_[38]} -_[17]={_[35],_[36],_[37]} -_[16]={_[33],_[34]} -_[15]={_[30],_[31],_[32]} -_[14]={_[28],_[29]} -_[13]={_[26],_[27]} -_[12]={_[23],_[24],_[25]} -_[11]={_[21],_[22]} -_[10]={_[18],_[19],_[20]} +_[45]={tags=_[65],text=" = b b 0"} +_[44]={tags=_[65],text="0"} +_[43]={tags=_[64],text="b"} +_[42]={tags=_[63],text="b"} +_[41]={tags=_[62],text=" = a 1"} +_[40]={tags=_[62],text="1"} +_[39]={tags=_[61],text="a"} +_[38]={tags=_[60],text=" = b a 1"} +_[37]={tags=_[60],text="1"} +_[36]={tags=_[59],text="a"} +_[35]={tags=_[58],text="b"} +_[34]={tags=_[57],text=" = a 1"} +_[33]={tags=_[57],text="1"} +_[32]={tags=_[56],text="a"} +_[31]={tags=_[55],text=" = b 0"} +_[30]={tags=_[55],text="0"} +_[29]={tags=_[54],text="b"} +_[28]={tags=_[53],text=" = a a 1"} +_[27]={tags=_[53],text="1"} +_[26]={tags=_[52],text="a"} +_[25]={tags=_[51],text="a"} +_[24]={tags=_[50],text=" = b 0"} +_[23]={tags=_[50],text="0"} +_[22]={tags=_[49],text="b"} +_[21]={tags=_[48],text=" = a b 0"} +_[20]={tags=_[48],text="0"} +_[19]={tags=_[47],text="b"} +_[18]={tags=_[46],text="a"} +_[17]={_[42],_[43],_[44],_[45]} +_[16]={_[39],_[40],_[41]} +_[15]={_[35],_[36],_[37],_[38]} +_[14]={_[32],_[33],_[34]} +_[13]={_[29],_[30],_[31]} +_[12]={_[25],_[26],_[27],_[28]} +_[11]={_[22],_[23],_[24]} +_[10]={_[18],_[19],_[20],_[21]} _[9]={"return"} _[8]={"text",_[17]} _[7]={"text",_[16]} @@ -59,72 +67,96 @@ _[1]={"text",_[10]} return {_[1],_[2],_[3],_[4],_[5],_[6],_[7],_[8],_[9]} --[[ { "text", { { - data = "a", - tags = {} + tags = {}, + text = "a" }, { - data = "b", - tags = {} + tags = {}, + text = "b" }, { - data = "0 = a b 0", - tags = {} + tags = <1>{}, + text = "0" + }, { + tags =
, + text = " = a b 0" } } } { "text", { { - data = "b", - tags = {} + tags = {}, + text = "b" }, { - data = "0 = b 0", - tags = {} + tags = <1>{}, + text = "0" + }, { + tags =
, + text = " = b 0" } } } { "text", { { - data = "a", - tags = {} + tags = {}, + text = "a" }, { - data = "a", - tags = {} + tags = {}, + text = "a" }, { - data = "1 = a a 1", - tags = {} + tags = <1>{}, + text = "1" + }, { + tags =
, + text = " = a a 1" } } } { "text", { { - data = "b", - tags = {} + tags = {}, + text = "b" }, { - data = "0 = b 0", - tags = {} + tags = <1>{}, + text = "0" + }, { + tags =
, + text = " = b 0" } } } { "text", { { - data = "a", - tags = {} + tags = {}, + text = "a" }, { - data = "1 = a 1", - tags = {} + tags = <1>{}, + text = "1" + }, { + tags =
, + text = " = a 1" } } } { "text", { { - data = "b", - tags = {} + tags = {}, + text = "b" }, { - data = "a", - tags = {} + tags = {}, + text = "a" }, { - data = "1 = b a 1", - tags = {} + tags = <1>{}, + text = "1" + }, { + tags =
, + text = " = b a 1" } } } { "text", { { - data = "a", - tags = {} + tags = {}, + text = "a" }, { - data = "1 = a 1", - tags = {} + tags = <1>{}, + text = "1" + }, { + tags =
, + text = " = a 1" } } } { "text", { { - data = "b", - tags = {} + tags = {}, + text = "b" }, { - data = "b", - tags = {} + tags = {}, + text = "b" }, { - data = "0 = b b 0", - tags = {} + tags = <1>{}, + text = "0" + }, { + tags =
, + text = " = b b 0" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/list assignement.lua b/test/tests/list assignement.lua index 04cdaa5..f4ef410 100644 --- a/test/tests/list assignement.lua +++ b/test/tests/list assignement.lua @@ -8,15 +8,15 @@ _[32]={} _[31]={} _[30]={} _[29]={} -_[28]={data="[3, 2, foo:c, bar:b]",tags=_[37]} -_[27]={data="c",tags=_[36]} -_[26]={data="[3, 2, foo:a, bar:b]",tags=_[35]} -_[25]={data="b",tags=_[34]} -_[24]={data="[3, 2, foo:a]",tags=_[33]} -_[23]={data="a",tags=_[32]} -_[22]={data="[3, 2]",tags=_[31]} -_[21]={data="3",tags=_[30]} -_[20]={data="[1, 2]",tags=_[29]} +_[28]={tags=_[37],text="[3, 2, foo:c, bar:b]"} +_[27]={tags=_[36],text="c"} +_[26]={tags=_[35],text="[3, 2, foo:a, bar:b]"} +_[25]={tags=_[34],text="b"} +_[24]={tags=_[33],text="[3, 2, foo:a]"} +_[23]={tags=_[32],text="a"} +_[22]={tags=_[31],text="[3, 2]"} +_[21]={tags=_[30],text="3"} +_[20]={tags=_[29],text="[1, 2]"} _[19]={_[28]} _[18]={_[27]} _[17]={_[26]} @@ -39,40 +39,40 @@ _[1]={"text",_[11]} return {_[1],_[2],_[3],_[4],_[5],_[6],_[7],_[8],_[9],_[10]} --[[ { "text", { { - data = "[1, 2]", - tags = {} + tags = {}, + text = "[1, 2]" } } } { "text", { { - data = "3", - tags = {} + tags = {}, + text = "3" } } } { "text", { { - data = "[3, 2]", - tags = {} + tags = {}, + text = "[3, 2]" } } } { "text", { { - data = "a", - tags = {} + tags = {}, + text = "a" } } } { "text", { { - data = "[3, 2, foo:a]", - tags = {} + tags = {}, + text = "[3, 2, foo:a]" } } } { "text", { { - data = "b", - tags = {} + tags = {}, + text = "b" } } } { "text", { { - data = "[3, 2, foo:a, bar:b]", - tags = {} + tags = {}, + text = "[3, 2, foo:a, bar:b]" } } } { "text", { { - data = "c", - tags = {} + tags = {}, + text = "c" } } } { "text", { { - data = "[3, 2, foo:c, bar:b]", - tags = {} + tags = {}, + text = "[3, 2, foo:c, bar:b]" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/named arguments.lua b/test/tests/named arguments.lua index 432acd9..6b5010f 100644 --- a/test/tests/named arguments.lua +++ b/test/tests/named arguments.lua @@ -1,14 +1,30 @@ local _={} -_[5]={} -_[4]={data="abc = abc = abc",tags=_[5]} -_[3]={_[4]} +_[9]={} +_[8]={tags=_[9],text="abc"} +_[7]={tags=_[9],text=" = "} +_[6]={tags=_[9],text="abc"} +_[5]={tags=_[9],text=" = "} +_[4]={tags=_[9],text="abc"} +_[3]={_[4],_[5],_[6],_[7],_[8]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "abc = abc = abc", - tags = {} + tags = <1>{}, + text = "abc" + }, { + tags =
, + text = " = " + }, { + tags =
, + text = "abc" + }, { + tags =
, + text = " = " + }, { + tags =
, + text = "abc" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/named varag.lua b/test/tests/named varag.lua index 4a54948..339f3e3 100644 --- a/test/tests/named varag.lua +++ b/test/tests/named varag.lua @@ -1,14 +1,14 @@ local _={} _[5]={} -_[4]={data="15",tags=_[5]} +_[4]={tags=_[5],text="15"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "15", - tags = {} + tags = {}, + text = "15" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/nested conditions.lua b/test/tests/nested conditions.lua index 6dac2cf..56ca0b5 100644 --- a/test/tests/nested conditions.lua +++ b/test/tests/nested conditions.lua @@ -2,9 +2,9 @@ local _={} _[11]={} _[10]={} _[9]={} -_[8]={data="da",tags=_[11]} -_[7]={data="ye",tags=_[10]} -_[6]={data="yes",tags=_[9]} +_[8]={tags=_[11],text="da"} +_[7]={tags=_[10],text="ye"} +_[6]={tags=_[9],text="yes"} _[5]={_[7],_[8]} _[4]={_[6]} _[3]={"return"} @@ -13,15 +13,15 @@ _[1]={"text",_[4]} return {_[1],_[2],_[3]} --[[ { "text", { { - data = "yes", - tags = {} + tags = {}, + text = "yes" } } } { "text", { { - data = "ye", - tags = {} + tags = {}, + text = "ye" }, { - data = "da", - tags = {} + tags = {}, + text = "da" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/nested flush.lua b/test/tests/nested flush.lua index ac73894..098fb60 100644 --- a/test/tests/nested flush.lua +++ b/test/tests/nested flush.lua @@ -1,20 +1,22 @@ local _={} -_[31]={} +_[33]={} +_[32]={} +_[31]={tags=_[33],text="h"} _[30]={} -_[29]={} +_[29]={tags=_[32],text="f"} _[28]={} _[27]={} _[26]={} _[25]={} _[24]={} -_[23]={data="h",tags=_[31]} -_[22]={data="g",tags=_[30]} -_[21]={data="f",tags=_[29]} -_[20]={data="e",tags=_[28]} -_[19]={data="d",tags=_[27]} -_[18]={data="c",tags=_[26]} -_[17]={data="b",tags=_[25]} -_[16]={data="a",tags=_[24]} +_[23]={_[31]} +_[22]={tags=_[30],text="g"} +_[21]={_[29]} +_[20]={tags=_[28],text="e"} +_[19]={tags=_[27],text="d"} +_[18]={tags=_[26],text="c"} +_[17]={tags=_[25],text="b"} +_[16]={tags=_[24],text="a"} _[15]={_[23]} _[14]={_[22]} _[13]={_[21]} @@ -33,35 +35,35 @@ _[1]={"text",_[9]} return {_[1],_[2],_[3],_[4],_[5],_[6],_[7],_[8]} --[[ { "text", { { - data = "a", - tags = {} + tags = {}, + text = "a" } } } { "text", { { - data = "b", - tags = {} + tags = {}, + text = "b" } } } { "text", { { - data = "c", - tags = {} + tags = {}, + text = "c" }, { - data = "d", - tags = {} + tags = {}, + text = "d" } } } { "text", { { - data = "e", - tags = {} - } } } -{ "choice", { { - data = "f", - tags = {} + tags = {}, + text = "e" } } } +{ "choice", { { { + tags = {}, + text = "f" + } } } } { "text", { { - data = "g", - tags = {} - } } } -{ "choice", { { - data = "h", - tags = {} + tags = {}, + text = "g" } } } +{ "choice", { { { + tags = {}, + text = "h" + } } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/optional arguments.lua b/test/tests/optional arguments.lua index 432acd9..6b5010f 100644 --- a/test/tests/optional arguments.lua +++ b/test/tests/optional arguments.lua @@ -1,14 +1,30 @@ local _={} -_[5]={} -_[4]={data="abc = abc = abc",tags=_[5]} -_[3]={_[4]} +_[9]={} +_[8]={tags=_[9],text="abc"} +_[7]={tags=_[9],text=" = "} +_[6]={tags=_[9],text="abc"} +_[5]={tags=_[9],text=" = "} +_[4]={tags=_[9],text="abc"} +_[3]={_[4],_[5],_[6],_[7],_[8]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "abc = abc = abc", - tags = {} + tags = <1>{}, + text = "abc" + }, { + tags =
, + text = " = " + }, { + tags =
, + text = "abc" + }, { + tags =
, + text = " = " + }, { + tags =
, + text = "abc" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/paragraph alias.lua b/test/tests/paragraph alias.lua index c34ed96..c88d990 100644 --- a/test/tests/paragraph alias.lua +++ b/test/tests/paragraph alias.lua @@ -1,14 +1,22 @@ local _={} -_[5]={} -_[4]={data="ok = ok",tags=_[5]} -_[3]={_[4]} +_[7]={} +_[6]={tags=_[7],text="ok"} +_[5]={tags=_[7],text=" = "} +_[4]={tags=_[7],text="ok"} +_[3]={_[4],_[5],_[6]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "ok = ok", - tags = {} + tags = <1>{}, + text = "ok" + }, { + tags =
, + text = " = " + }, { + tags =
, + text = "ok" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/paragraph run force.lua b/test/tests/paragraph run force.lua index ebfabf4..f8b432b 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],text="b"} +_[14]={tags=_[22],text="x"} +_[13]={tags=_[21],text="Force no checkpoint:"} +_[12]={tags=_[20],text="b"} +_[11]={tags=_[19],text="a"} +_[10]={tags=_[18],text="From checkpoint:"} +_[9]={tags=_[17],text="a"} +_[8]={tags=_[16],text="Force run checkpoint:"} _[7]={_[13],_[14],_[15]} _[6]={_[10],_[11],_[12]} _[5]={_[8],_[9]} @@ -25,31 +25,31 @@ _[1]={"text",_[5]} return {_[1],_[2],_[3],_[4]} --[[ { "text", { { - data = "Force run checkpoint:", - tags = {} + tags = {}, + text = "Force run checkpoint:" }, { - data = "a", - tags = {} + tags = {}, + text = "a" } } } { "text", { { - data = "From checkpoint:", - tags = {} + tags = {}, + text = "From checkpoint:" }, { - data = "a", - tags = {} + tags = {}, + text = "a" }, { - data = "b", - tags = {} + tags = {}, + text = "b" } } } { "text", { { - data = "Force no checkpoint:", - tags = {} + tags = {}, + text = "Force no checkpoint:" }, { - data = "x", - tags = {} + tags = {}, + text = "x" }, { - data = "b", - tags = {} + tags = {}, + text = "b" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/paragraph run from.lua b/test/tests/paragraph run from.lua index 2a60103..9a38458 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],text="b"} +_[15]={tags=_[24],text="x"} +_[14]={tags=_[23],text="Force no checkpoint:"} +_[13]={tags=_[22],text="b"} +_[12]={tags=_[21],text="a"} +_[11]={tags=_[20],text="From checkpoint:"} +_[10]={tags=_[19],text="b"} +_[9]={tags=_[18],text="a"} +_[8]={tags=_[17],text="Force run from checkpoint:"} _[7]={_[14],_[15],_[16]} _[6]={_[11],_[12],_[13]} _[5]={_[8],_[9],_[10]} @@ -27,34 +27,34 @@ _[1]={"text",_[5]} return {_[1],_[2],_[3],_[4]} --[[ { "text", { { - data = "Force run from checkpoint:", - tags = {} + tags = {}, + text = "Force run from checkpoint:" }, { - data = "a", - tags = {} + tags = {}, + text = "a" }, { - data = "b", - tags = {} + tags = {}, + text = "b" } } } { "text", { { - data = "From checkpoint:", - tags = {} + tags = {}, + text = "From checkpoint:" }, { - data = "a", - tags = {} + tags = {}, + text = "a" }, { - data = "b", - tags = {} + tags = {}, + text = "b" } } } { "text", { { - data = "Force no checkpoint:", - tags = {} + tags = {}, + text = "Force no checkpoint:" }, { - data = "x", - tags = {} + tags = {}, + text = "x" }, { - data = "b", - tags = {} + tags = {}, + text = "b" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/paragraph run.lua b/test/tests/paragraph run.lua index 1c639b3..e74ba4a 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],text="b"} +_[15]={tags=_[24],text="x"} +_[14]={tags=_[23],text="Force no checkpoint:"} +_[13]={tags=_[22],text="b"} +_[12]={tags=_[21],text="a"} +_[11]={tags=_[20],text="From checkpoint:"} +_[10]={tags=_[19],text="b"} +_[9]={tags=_[18],text="x"} +_[8]={tags=_[17],text="No checkpoint:"} _[7]={_[14],_[15],_[16]} _[6]={_[11],_[12],_[13]} _[5]={_[8],_[9],_[10]} @@ -27,34 +27,34 @@ _[1]={"text",_[5]} return {_[1],_[2],_[3],_[4]} --[[ { "text", { { - data = "No checkpoint:", - tags = {} + tags = {}, + text = "No checkpoint:" }, { - data = "x", - tags = {} + tags = {}, + text = "x" }, { - data = "b", - tags = {} + tags = {}, + text = "b" } } } { "text", { { - data = "From checkpoint:", - tags = {} + tags = {}, + text = "From checkpoint:" }, { - data = "a", - tags = {} + tags = {}, + text = "a" }, { - data = "b", - tags = {} + tags = {}, + text = "b" } } } { "text", { { - data = "Force no checkpoint:", - tags = {} + tags = {}, + text = "Force no checkpoint:" }, { - data = "x", - tags = {} + tags = {}, + text = "x" }, { - data = "b", - tags = {} + tags = {}, + text = "b" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/paragraph.lua b/test/tests/paragraph.lua index b086675..da0e7fa 100644 --- a/test/tests/paragraph.lua +++ b/test/tests/paragraph.lua @@ -1,14 +1,14 @@ local _={} _[5]={} -_[4]={data="b",tags=_[5]} +_[4]={tags=_[5],text="b"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "b", - tags = {} + tags = {}, + text = "b" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/resume from nested paragraph.lua b/test/tests/resume from nested paragraph.lua index ce5245a..b3de8e6 100644 --- a/test/tests/resume from nested paragraph.lua +++ b/test/tests/resume from nested paragraph.lua @@ -17,24 +17,24 @@ _[49]={} _[48]={} _[47]={} _[46]={} -_[45]={data="c",tags=_[63]} -_[44]={data="a",tags=_[62]} -_[43]={data="Force p checkpoint:",tags=_[61]} -_[42]={data="d",tags=_[60]} -_[41]={data="c",tags=_[59]} -_[40]={data="b",tags=_[58]} -_[39]={data="From q checkpoint again:",tags=_[57]} -_[38]={data="d",tags=_[56]} -_[37]={data="c",tags=_[55]} -_[36]={data="b",tags=_[54]} -_[35]={data="From q checkpoint:",tags=_[53]} -_[34]={data="d",tags=_[52]} -_[33]={data="c",tags=_[51]} -_[32]={data="a",tags=_[50]} -_[31]={data="From p checkpoint:",tags=_[49]} -_[30]={data="d",tags=_[48]} -_[29]={data="x",tags=_[47]} -_[28]={data="From start:",tags=_[46]} +_[45]={tags=_[63],text="c"} +_[44]={tags=_[62],text="a"} +_[43]={tags=_[61],text="Force p checkpoint:"} +_[42]={tags=_[60],text="d"} +_[41]={tags=_[59],text="c"} +_[40]={tags=_[58],text="b"} +_[39]={tags=_[57],text="From q checkpoint again:"} +_[38]={tags=_[56],text="d"} +_[37]={tags=_[55],text="c"} +_[36]={tags=_[54],text="b"} +_[35]={tags=_[53],text="From q checkpoint:"} +_[34]={tags=_[52],text="d"} +_[33]={tags=_[51],text="c"} +_[32]={tags=_[50],text="a"} +_[31]={tags=_[49],text="From p checkpoint:"} +_[30]={tags=_[48],text="d"} +_[29]={tags=_[47],text="x"} +_[28]={tags=_[46],text="From start:"} _[27]={_[45]} _[26]={_[43],_[44]} _[25]={_[42]} @@ -65,71 +65,71 @@ _[1]={"text",_[15]} return {_[1],_[2],_[3],_[4],_[5],_[6],_[7],_[8],_[9],_[10],_[11],_[12],_[13],_[14]} --[[ { "text", { { - data = "From start:", - tags = {} + tags = {}, + text = "From start:" }, { - data = "x", - tags = {} + tags = {}, + text = "x" } } } { "text", { { - data = "d", - tags = {} + tags = {}, + text = "d" } } } { "text", { { - data = "From p checkpoint:", - tags = {} + tags = {}, + text = "From p checkpoint:" }, { - data = "a", - tags = {} + tags = {}, + text = "a" } } } { "text", { { - data = "c", - tags = {} + tags = {}, + text = "c" } } } { "text", { { - data = "d", - tags = {} + tags = {}, + text = "d" } } } { "text", { { - data = "From q checkpoint:", - tags = {} + tags = {}, + text = "From q checkpoint:" }, { - data = "b", - tags = {} + tags = {}, + text = "b" } } } { "text", { { - data = "c", - tags = {} + tags = {}, + text = "c" } } } { "text", { { - data = "d", - tags = {} + tags = {}, + text = "d" } } } { "text", { { - data = "From q checkpoint again:", - tags = {} + tags = {}, + text = "From q checkpoint again:" }, { - data = "b", - tags = {} + tags = {}, + text = "b" } } } { "text", { { - data = "c", - tags = {} + tags = {}, + text = "c" } } } { "text", { { - data = "d", - tags = {} + tags = {}, + text = "d" } } } { "text", { { - data = "Force p checkpoint:", - tags = {} + tags = {}, + text = "Force p checkpoint:" }, { - data = "a", - tags = {} + tags = {}, + text = "a" } } } { "text", { { - data = "c", - tags = {} + tags = {}, + text = "c" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/resume from paragraph restore tags.lua b/test/tests/resume from paragraph restore tags.lua index f8b3955..65570e3 100644 --- a/test/tests/resume from paragraph restore tags.lua +++ b/test/tests/resume from paragraph restore tags.lua @@ -2,18 +2,18 @@ local _={} _[32]={} _[31]={a="a"} _[30]={a="a",b="b"} -_[29]={a="a",b="b",c="c"} +_[29]={a="a",c="c",b="b"} _[28]={} _[27]={a="a",b="b"} _[26]={a="a"} -_[25]={data="e",tags=_[32]} -_[24]={data="d",tags=_[31]} -_[23]={data="c",tags=_[30]} -_[22]={data="b",tags=_[29]} -_[21]={data="e",tags=_[28]} -_[20]={data="d",tags=_[26]} -_[19]={data="c",tags=_[27]} -_[18]={data="a",tags=_[26]} +_[25]={tags=_[32],text="e"} +_[24]={tags=_[31],text="d"} +_[23]={tags=_[30],text="c"} +_[22]={tags=_[29],text="b"} +_[21]={tags=_[28],text="e"} +_[20]={tags=_[26],text="d"} +_[19]={tags=_[27],text="c"} +_[18]={tags=_[26],text="a"} _[17]={_[25]} _[16]={_[24]} _[15]={_[23]} @@ -34,52 +34,52 @@ _[1]={"text",_[10]} return {_[1],_[2],_[3],_[4],_[5],_[6],_[7],_[8],_[9]} --[[ { "text", { { - data = "a", tags = { a = "a" - } + }, + text = "a" } } } { "text", { { - data = "c", tags = { a = "a", b = "b" - } + }, + text = "c" } } } { "text", { { - data = "d", tags = { a = "a" - } + }, + text = "d" } } } { "text", { { - data = "e", - tags = {} + tags = {}, + text = "e" } } } { "text", { { - data = "b", tags = { a = "a", b = "b", c = "c" - } + }, + text = "b" } } } { "text", { { - data = "c", tags = { a = "a", b = "b" - } + }, + text = "c" } } } { "text", { { - data = "d", tags = { a = "a" - } + }, + text = "d" } } } { "text", { { - data = "e", - tags = {} + tags = {}, + text = "e" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/resume from paragraph with nested choice.lua b/test/tests/resume from paragraph with nested choice.lua index 8e543e3..937f343 100644 --- a/test/tests/resume from paragraph with nested choice.lua +++ b/test/tests/resume from paragraph with nested choice.lua @@ -1,71 +1,83 @@ local _={} -_[118]={} +_[130]={} +_[129]={} +_[128]={} +_[127]={} +_[126]={} +_[125]={} +_[124]={} +_[123]={} +_[122]={} +_[121]={} +_[120]={text="c",tags=_[130]} +_[119]={text="b",tags=_[129]} +_[118]={text="a",tags=_[128]} _[117]={} -_[116]={} -_[115]={} -_[114]={} -_[113]={} +_[116]={text="ab",tags=_[127]} +_[115]={text="aa",tags=_[117]} +_[114]={text="ab"} +_[113]={text="aa"} _[112]={} -_[111]={} -_[110]={} -_[109]={} +_[111]={text="c",tags=_[126]} +_[110]={text="b",tags=_[125]} +_[109]={text="a",tags=_[112]} _[108]={} -_[107]={} +_[107]={text="c",tags=_[108]} _[106]={} _[105]={} -_[104]={} -_[103]={} +_[104]={text="ab",tags=_[105]} +_[103]={text="aa",tags=_[124]} _[102]={} -_[101]={} +_[101]={text="c",tags=_[102]} _[100]={} _[99]={} -_[98]={} -_[97]={} +_[98]={text="b",tags=_[99]} +_[97]={text="a",tags=_[123]} _[96]={} -_[95]={} +_[95]={text="c",tags=_[96]} _[94]={} -_[93]={} -_[92]={} +_[93]={text="ab",tags=_[94]} +_[92]={text="aa",tags=_[122]} _[91]={} -_[90]={} +_[90]={text="c",tags=_[91]} _[89]={} -_[88]={} -_[87]={} -_[86]={data="c",tags=_[118]} -_[85]={data="b",tags=_[117]} -_[84]={data="a",tags=_[116]} -_[83]={data="-> aa",tags=_[115]} -_[82]={data="ab",tags=_[114]} -_[81]={data="aa",tags=_[113]} -_[80]={data="-> aa",tags=_[112]} -_[79]={data="ab",tags=_[112]} -_[78]={data="aa",tags=_[112]} -_[77]={data="-> a",tags=_[112]} -_[76]={data="c",tags=_[111]} -_[75]={data="b",tags=_[110]} -_[74]={data="a",tags=_[109]} -_[73]={data="-> c",tags=_[108]} -_[72]={data="c",tags=_[107]} -_[71]={data="autoflush",tags=_[106]} -_[70]={data="-> ab",tags=_[105]} -_[69]={data="ab",tags=_[104]} -_[68]={data="aa",tags=_[103]} -_[67]={data="-> c",tags=_[102]} -_[66]={data="c",tags=_[101]} -_[65]={data="autoflush",tags=_[100]} -_[64]={data="-> b",tags=_[99]} -_[63]={data="b",tags=_[98]} -_[62]={data="a",tags=_[97]} -_[61]={data="-> c",tags=_[96]} -_[60]={data="c",tags=_[95]} -_[59]={data="-> ab",tags=_[94]} -_[58]={data="ab",tags=_[93]} -_[57]={data="aa",tags=_[92]} -_[56]={data="-> c",tags=_[91]} -_[55]={data="c",tags=_[90]} -_[54]={data="-> b",tags=_[89]} -_[53]={data="b",tags=_[88]} -_[52]={data="a",tags=_[87]} +_[88]={text="b",tags=_[89]} +_[87]={text="a",tags=_[121]} +_[86]={_[120]} +_[85]={_[119]} +_[84]={_[118]} +_[83]={text="-> aa",tags=_[117]} +_[82]={_[116]} +_[81]={_[115]} +_[80]={text="-> aa",tags=_[112]} +_[79]={_[114]} +_[78]={_[113]} +_[77]={text="-> a",tags=_[112]} +_[76]={_[111]} +_[75]={_[110]} +_[74]={_[109]} +_[73]={text="-> c",tags=_[108]} +_[72]={_[107]} +_[71]={text="autoflush",tags=_[106]} +_[70]={text="-> ab",tags=_[105]} +_[69]={_[104]} +_[68]={_[103]} +_[67]={text="-> c",tags=_[102]} +_[66]={_[101]} +_[65]={text="autoflush",tags=_[100]} +_[64]={text="-> b",tags=_[99]} +_[63]={_[98]} +_[62]={_[97]} +_[61]={text="-> c",tags=_[96]} +_[60]={_[95]} +_[59]={text="-> ab",tags=_[94]} +_[58]={_[93]} +_[57]={_[92]} +_[56]={text="-> c",tags=_[91]} +_[55]={_[90]} +_[54]={text="-> b",tags=_[89]} +_[53]={_[88]} +_[52]={_[87]} _[51]={_[84],_[85],_[86]} _[50]={_[83]} _[49]={_[81],_[82]} @@ -91,7 +103,7 @@ _[30]={_[56]} _[29]={_[55]} _[28]={_[54]} _[27]={_[52],_[53]} -_[26]={"error","invalid choice"} +_[26]={"error","invalid choice; in event flush at test/tests/resume from paragraph with nested choice.ans:76"} _[25]={"choice",_[51]} _[24]={"text",_[50]} _[23]={"choice",_[49]} @@ -117,137 +129,140 @@ _[4]={"text",_[30]} _[3]={"choice",_[29]} _[2]={"text",_[28]} _[1]={"choice",_[27]} -return {_[1],_[2],_[3],_[4],_[5],_[6],_[7],_[8],_[9],_[10],_[11],_[12],_[13],_[14],_[15],_[16],_[17],_[18],_[19],_[20],_[21],_[22],_[23],_[24],_[25],_[26]} +_[0]={_[1],_[2],_[3],_[4],_[5],_[6],_[7],_[8],_[9],_[10],_[11],_[12],_[13],_[14],_[15],_[16],_[17],_[18],_[19],_[20],_[21],_[22],_[23],_[24],_[25],_[26]} +_[113].tags=_[112] +_[114].tags=_[112] +return _[0] --[[ -{ "choice", { { - data = "a", - tags = {} - }, { - data = "b", - tags = {} +{ "choice", { { { + tags = {}, + text = "a" + } }, { { + tags = {}, + text = "b" + } } } } +{ "text", { { + tags = {}, + text = "-> b" + } } } +{ "choice", { { { + tags = {}, + text = "c" + } } } } +{ "text", { { + tags = {}, + text = "-> c" + } } } +{ "choice", { { { + tags = {}, + text = "aa" + } }, { { + tags = {}, + text = "ab" + } } } } +{ "text", { { + tags = {}, + text = "-> ab" + } } } +{ "choice", { { { + tags = {}, + text = "c" + } } } } +{ "text", { { + tags = {}, + text = "-> c" + } } } +{ "choice", { { { + tags = {}, + text = "a" + } }, { { + tags = {}, + text = "b" + } } } } +{ "text", { { + tags = {}, + text = "-> b" } } } { "text", { { - data = "-> b", - tags = {} + tags = {}, + text = "autoflush" } } } -{ "choice", { { - data = "c", - tags = {} +{ "choice", { { { + tags = {}, + text = "c" + } } } } +{ "text", { { + tags = {}, + text = "-> c" + } } } +{ "choice", { { { + tags = {}, + text = "aa" + } }, { { + tags = {}, + text = "ab" + } } } } +{ "text", { { + tags = {}, + text = "-> ab" } } } { "text", { { - data = "-> c", - tags = {} - } } } -{ "choice", { { - data = "aa", - tags = {} - }, { - data = "ab", - tags = {} + tags = {}, + text = "autoflush" } } } +{ "choice", { { { + tags = {}, + text = "c" + } } } } { "text", { { - data = "-> ab", - tags = {} - } } } -{ "choice", { { - data = "c", - tags = {} + tags = {}, + text = "-> c" } } } +{ "choice", { { { + tags = {}, + text = "a" + } }, { { + tags = {}, + text = "b" + } }, { { + tags = {}, + text = "c" + } } } } { "text", { { - data = "-> c", - tags = {} - } } } -{ "choice", { { - data = "a", - tags = {} - }, { - data = "b", - tags = {} + tags = {}, + text = "-> a" } } } +{ "choice", { { { + tags = <1>{}, + text = "aa" + } }, { { + tags =
, + text = "ab" + } } } } { "text", { { - data = "-> b", - tags = {} + tags = {}, + text = "-> aa" } } } +{ "choice", { { { + tags = {}, + text = "aa" + } }, { { + tags = {}, + text = "ab" + } } } } { "text", { { - data = "autoflush", - tags = {} + tags = {}, + text = "-> aa" } } } -{ "choice", { { - data = "c", - tags = {} - } } } -{ "text", { { - data = "-> c", - tags = {} - } } } -{ "choice", { { - data = "aa", - tags = {} - }, { - data = "ab", - tags = {} - } } } -{ "text", { { - data = "-> ab", - tags = {} - } } } -{ "text", { { - data = "autoflush", - tags = {} - } } } -{ "choice", { { - data = "c", - tags = {} - } } } -{ "text", { { - data = "-> c", - tags = {} - } } } -{ "choice", { { - data = "a", - tags = {} - }, { - data = "b", - tags = {} - }, { - data = "c", - tags = {} - } } } -{ "text", { { - data = "-> a", - tags = {} - } } } -{ "choice", { { - data = "aa", - tags = <1>{} - }, { - data = "ab", - tags =
- } } } -{ "text", { { - data = "-> aa", - tags = {} - } } } -{ "choice", { { - data = "aa", - tags = {} - }, { - data = "ab", - tags = {} - } } } -{ "text", { { - data = "-> aa", - tags = {} - } } } -{ "choice", { { - data = "a", - tags = {} - }, { - data = "b", - tags = {} - }, { - data = "c", - tags = {} - } } } -{ "error", "invalid choice" } +{ "choice", { { { + tags = {}, + text = "a" + } }, { { + tags = {}, + text = "b" + } }, { { + tags = {}, + text = "c" + } } } } +{ "error", "invalid choice; in event flush at test/tests/resume from paragraph with nested choice.ans:76" } ]]-- \ No newline at end of file diff --git a/test/tests/resume from paragraph with nested condition.lua b/test/tests/resume from paragraph with nested condition.lua index f662658..70b7f88 100644 --- a/test/tests/resume from paragraph with nested condition.lua +++ b/test/tests/resume from paragraph with nested condition.lua @@ -3,10 +3,10 @@ _[17]={} _[16]={} _[15]={} _[14]={} -_[13]={data="x",tags=_[17]} -_[12]={data="y",tags=_[16]} -_[11]={data="x",tags=_[15]} -_[10]={data="x",tags=_[14]} +_[13]={tags=_[17],text="x"} +_[12]={tags=_[16],text="y"} +_[11]={tags=_[15],text="x"} +_[10]={tags=_[14],text="x"} _[9]={_[13]} _[8]={_[12]} _[7]={_[11]} @@ -19,20 +19,20 @@ _[1]={"text",_[6]} return {_[1],_[2],_[3],_[4],_[5]} --[[ { "text", { { - data = "x", - tags = {} + tags = {}, + text = "x" } } } { "text", { { - data = "x", - tags = {} + tags = {}, + text = "x" } } } { "text", { { - data = "y", - tags = {} + tags = {}, + text = "y" } } } { "text", { { - data = "x", - tags = {} + tags = {}, + text = "x" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/return in choice.lua b/test/tests/return in choice.lua index 365d386..38b91af 100644 --- a/test/tests/return in choice.lua +++ b/test/tests/return in choice.lua @@ -1,10 +1,10 @@ local _={} _[13]={} _[12]={} -_[11]={} -_[10]={data="Yes.",tags=_[13]} -_[9]={data="x",tags=_[12]} -_[8]={data="a",tags=_[11]} +_[11]={tags=_[12],text="a"} +_[10]={tags=_[13],text="Yes."} +_[9]={tags=_[12],text="x"} +_[8]={_[11]} _[7]={_[10]} _[6]={_[9]} _[5]={_[8]} @@ -14,17 +14,17 @@ _[2]={"text",_[6]} _[1]={"choice",_[5]} return {_[1],_[2],_[3],_[4]} --[[ -{ "choice", { { - data = "a", - tags = {} +{ "choice", { { { + tags = {}, + text = "a" + } } } } +{ "text", { { + tags = {}, + text = "x" } } } { "text", { { - data = "x", - tags = {} - } } } -{ "text", { { - data = "Yes.", - tags = {} + tags = {}, + text = "Yes." } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/string escaping.lua b/test/tests/string escaping.lua index 0baafe3..c0bf8a5 100644 --- a/test/tests/string escaping.lua +++ b/test/tests/string escaping.lua @@ -1,16 +1,23 @@ local _={} -_[17]={} -_[16]={} -_[15]={} -_[14]={} -_[13]={data="escaping expressions abc and stuff \\ and quotes \"",tags=_[17]} -_[12]={data="other codes \n \\ \9",tags=_[16]} -_[11]={data="quote \"",tags=_[15]} -_[10]={data="expression a",tags=_[14]} -_[9]={_[13]} -_[8]={_[12]} -_[7]={_[11]} -_[6]={_[10]} +_[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]} +_[7]={_[12],_[13]} +_[6]={_[10],_[11]} _[5]={"return"} _[4]={"text",_[9]} _[3]={"text",_[8]} @@ -19,20 +26,41 @@ _[1]={"text",_[6]} return {_[1],_[2],_[3],_[4],_[5]} --[[ { "text", { { - data = "expression a", - tags = {} + tags = <1>{}, + text = "expression " + }, { + tags =
, + text = "a" } } } { "text", { { - data = 'quote "', - tags = {} + tags = <1>{}, + text = "quote " + }, { + tags =
, + text = '"' } } } { "text", { { - data = "other codes \n \\ \t", - tags = {} + tags = <1>{}, + text = "other codes " + }, { + tags =
, + text = "\n" + }, { + tags =
, + text = " " + }, { + tags =
, + text = "\\" + }, { + tags =
, + text = " " + }, { + tags =
, + text = "\t" } } } { "text", { { - data = 'escaping expressions abc and stuff \\ and quotes "', - tags = {} + tags = {}, + text = 'escaping expressions abc and stuff \\ and quotes "' } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/tag decorator empty.lua b/test/tests/tag decorator empty.lua index 74ceac2..9e952f9 100644 --- a/test/tests/tag decorator empty.lua +++ b/test/tests/tag decorator empty.lua @@ -1,19 +1,19 @@ local _={} _[7]={1} _[6]={1} -_[5]={data="bar",tags=_[7]} -_[4]={data="foo",tags=_[6]} +_[5]={tags=_[7],text="bar"} +_[4]={tags=_[6],text="foo"} _[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "foo", - tags = { 1 } + tags = { 1 }, + text = "foo" }, { - data = "bar", - tags = { 1 } + tags = { 1 }, + text = "bar" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/tag decorator nested.lua b/test/tests/tag decorator nested.lua index 9611766..17f75be 100644 --- a/test/tests/tag decorator nested.lua +++ b/test/tests/tag decorator nested.lua @@ -2,21 +2,21 @@ local _={} _[8]={2,3} _[7]={1,a=_[8]} _[6]={1} -_[5]={data="bar",tags=_[7]} -_[4]={data="foo",tags=_[6]} +_[5]={tags=_[7],text="bar"} +_[4]={tags=_[6],text="foo"} _[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "foo", - tags = { 1 } + tags = { 1 }, + text = "foo" }, { - data = "bar", tags = { 1, a = { 2, 3 } - } + }, + text = "bar" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/tag decorator.lua b/test/tests/tag decorator.lua index 9611766..17f75be 100644 --- a/test/tests/tag decorator.lua +++ b/test/tests/tag decorator.lua @@ -2,21 +2,21 @@ local _={} _[8]={2,3} _[7]={1,a=_[8]} _[6]={1} -_[5]={data="bar",tags=_[7]} -_[4]={data="foo",tags=_[6]} +_[5]={tags=_[7],text="bar"} +_[4]={tags=_[6],text="foo"} _[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "foo", - tags = { 1 } + tags = { 1 }, + text = "foo" }, { - data = "bar", tags = { 1, a = { 2, 3 } - } + }, + text = "bar" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/tag empty.lua b/test/tests/tag empty.lua index 74ceac2..9e952f9 100644 --- a/test/tests/tag empty.lua +++ b/test/tests/tag empty.lua @@ -1,19 +1,19 @@ local _={} _[7]={1} _[6]={1} -_[5]={data="bar",tags=_[7]} -_[4]={data="foo",tags=_[6]} +_[5]={tags=_[7],text="bar"} +_[4]={tags=_[6],text="foo"} _[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "foo", - tags = { 1 } + tags = { 1 }, + text = "foo" }, { - data = "bar", - tags = { 1 } + tags = { 1 }, + text = "bar" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/tag.lua b/test/tests/tag.lua index 9611766..17f75be 100644 --- a/test/tests/tag.lua +++ b/test/tests/tag.lua @@ -2,21 +2,21 @@ local _={} _[8]={2,3} _[7]={1,a=_[8]} _[6]={1} -_[5]={data="bar",tags=_[7]} -_[4]={data="foo",tags=_[6]} +_[5]={tags=_[7],text="bar"} +_[4]={tags=_[6],text="foo"} _[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "foo", - tags = { 1 } + tags = { 1 }, + text = "foo" }, { - data = "bar", tags = { 1, a = { 2, 3 } - } + }, + text = "bar" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/text block.lua b/test/tests/text block.lua index 8c9d78c..92312d6 100644 --- a/test/tests/text block.lua +++ b/test/tests/text block.lua @@ -1,19 +1,19 @@ local _={} _[7]={} _[6]={} -_[5]={data="b c",tags=_[7]} -_[4]={data="a",tags=_[6]} +_[5]={tags=_[7],text="b c"} +_[4]={tags=_[6],text="a"} _[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "a", - tags = {} + tags = {}, + text = "a" }, { - data = "b c", - tags = {} + tags = {}, + text = "b c" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/text break.lua b/test/tests/text break.lua index 89356fb..e8036e3 100644 --- a/test/tests/text break.lua +++ b/test/tests/text break.lua @@ -1,8 +1,8 @@ local _={} _[9]={} _[8]={} -_[7]={data="b c",tags=_[9]} -_[6]={data="a",tags=_[8]} +_[7]={tags=_[9],text="b c"} +_[6]={tags=_[8],text="a"} _[5]={_[7]} _[4]={_[6]} _[3]={"return"} @@ -11,12 +11,12 @@ _[1]={"text",_[4]} return {_[1],_[2],_[3]} --[[ { "text", { { - data = "a", - tags = {} + tags = {}, + text = "a" } } } { "text", { { - data = "b c", - tags = {} + tags = {}, + text = "b c" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/text format.lua b/test/tests/text format.lua index ab7c161..4055219 100644 --- a/test/tests/text format.lua +++ b/test/tests/text format.lua @@ -1,14 +1,18 @@ local _={} -_[5]={} -_[4]={data="a: 5",tags=_[5]} -_[3]={_[4]} +_[6]={} +_[5]={tags=_[6],text="5"} +_[4]={tags=_[6],text="a: "} +_[3]={_[4],_[5]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "a: 5", - tags = {} + tags = <1>{}, + text = "a: " + }, { + tags =
, + text = "5" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/text line interpolation with choice event.ans b/test/tests/text line interpolation with choice event.ans new file mode 100644 index 0000000..3dbf8a3 --- /dev/null +++ b/test/tests/text line interpolation with choice event.ans @@ -0,0 +1,16 @@ +Press {jump button} to jump. + +$ jump button + A # 1 + ~ choose(1) + > Surprise choice! + ok + +Use {move axis} to move. + +$ move axis + left # 1 + ~ choose(1) + > Surprise choice! + ok2 + @" joystick" diff --git a/test/tests/text line interpolation with choice event.lua b/test/tests/text line interpolation with choice event.lua new file mode 100644 index 0000000..95f3f32 --- /dev/null +++ b/test/tests/text line interpolation with choice event.lua @@ -0,0 +1,82 @@ +local _={} +_[36]={} +_[35]={tags=_[36],text="Surprise choice!"} +_[34]={1} +_[33]={} +_[32]={} +_[31]={tags=_[32],text="Surprise choice!"} +_[30]={1} +_[29]={} +_[28]={tags=_[33],text=" to move."} +_[27]={tags=_[33],text=" joystick"} +_[26]={tags=_[36],text="ok2"} +_[25]={_[35]} +_[24]={tags=_[34],text="left"} +_[23]={tags=_[33],text="Use "} +_[22]={tags=_[29],text=" to jump."} +_[21]={tags=_[32],text="ok"} +_[20]={_[31]} +_[19]={tags=_[30],text="A"} +_[18]={tags=_[29],text="Press "} +_[17]={_[27],_[28]} +_[16]={_[26]} +_[15]={_[25]} +_[14]={_[23],_[24]} +_[13]={_[22]} +_[12]={_[21]} +_[11]={_[20]} +_[10]={_[18],_[19]} +_[9]={"return"} +_[8]={"text",_[17]} +_[7]={"text",_[16]} +_[6]={"choice",_[15]} +_[5]={"text",_[14]} +_[4]={"text",_[13]} +_[3]={"text",_[12]} +_[2]={"choice",_[11]} +_[1]={"text",_[10]} +return {_[1],_[2],_[3],_[4],_[5],_[6],_[7],_[8],_[9]} +--[[ +{ "text", { { + tags = {}, + text = "Press " + }, { + tags = { 1 }, + text = "A" + } } } +{ "choice", { { { + tags = {}, + text = "Surprise choice!" + } } } } +{ "text", { { + tags = {}, + text = "ok" + } } } +{ "text", { { + tags = {}, + text = " to jump." + } } } +{ "text", { { + tags = {}, + text = "Use " + }, { + tags = { 1 }, + text = "left" + } } } +{ "choice", { { { + tags = {}, + text = "Surprise choice!" + } } } } +{ "text", { { + tags = {}, + text = "ok2" + } } } +{ "text", { { + tags = <1>{}, + text = " joystick" + }, { + tags =
, + text = " to move." + } } } +{ "return" } +]]-- \ No newline at end of file diff --git a/test/tests/text line interpolation with event flush.ans b/test/tests/text line interpolation with event flush.ans new file mode 100644 index 0000000..c06e181 --- /dev/null +++ b/test/tests/text line interpolation with event flush.ans @@ -0,0 +1,13 @@ +Press {jump button} to jump. + +$ jump button + A # 1 + + @ + +Use {move axis} to move. + +$ move axis + left # 1 + + @" joystick" diff --git a/test/tests/text line interpolation with event flush.lua b/test/tests/text line interpolation with event flush.lua new file mode 100644 index 0000000..e5700b2 --- /dev/null +++ b/test/tests/text line interpolation with event flush.lua @@ -0,0 +1,50 @@ +local _={} +_[20]={1} +_[19]={} +_[18]={1} +_[17]={} +_[16]={text=" to move.",tags=_[19]} +_[15]={text=" joystick",tags=_[19]} +_[14]={text="left",tags=_[20]} +_[13]={text="Use ",tags=_[19]} +_[12]={text=" to jump.",tags=_[17]} +_[11]={text="A",tags=_[18]} +_[10]={text="Press ",tags=_[17]} +_[9]={_[15],_[16]} +_[8]={_[13],_[14]} +_[7]={_[12]} +_[6]={_[10],_[11]} +_[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 = { 1 }, + text = "A" + } } } +{ "text", { { + tags = {}, + text = " to jump." + } } } +{ "text", { { + tags = {}, + text = "Use " + }, { + tags = { 1 }, + text = "left" + } } } +{ "text", { { + tags = <1>{}, + text = " joystick" + }, { + tags =
, + text = " to move." + } } } +{ "return" } +]]-- \ No newline at end of file diff --git a/test/tests/text line interpolation with text event.ans b/test/tests/text line interpolation with text event.ans new file mode 100644 index 0000000..acb03f5 --- /dev/null +++ b/test/tests/text line interpolation with text event.ans @@ -0,0 +1,10 @@ +Press {jump button} to jump. + +$ jump button + A # 1 + +Use {move axis} to move. + +$ move axis + left # 1 + @" joystick" diff --git a/test/tests/text line interpolation with text event.lua b/test/tests/text line interpolation with text event.lua new file mode 100644 index 0000000..cab6e7e --- /dev/null +++ b/test/tests/text line interpolation with text event.lua @@ -0,0 +1,44 @@ +local _={} +_[16]={1} +_[15]={} +_[14]={1} +_[13]={} +_[12]={tags=_[15],text=" to move."} +_[11]={tags=_[15],text=" joystick"} +_[10]={tags=_[16],text="left"} +_[9]={tags=_[15],text="Use "} +_[8]={tags=_[13],text=" to jump."} +_[7]={tags=_[14],text="A"} +_[6]={tags=_[13],text="Press "} +_[5]={_[9],_[10],_[11],_[12]} +_[4]={_[6],_[7],_[8]} +_[3]={"return"} +_[2]={"text",_[5]} +_[1]={"text",_[4]} +return {_[1],_[2],_[3]} +--[[ +{ "text", { { + tags = <1>{}, + text = "Press " + }, { + tags = { 1 }, + text = "A" + }, { + tags =
, + text = " to jump." + } } } +{ "text", { { + tags = <1>{}, + text = "Use " + }, { + tags = { 1 }, + text = "left" + }, { + tags =
, + text = " joystick" + }, { + tags =
, + text = " to move." + } } } +{ "return" } +]]-- \ No newline at end of file diff --git a/test/tests/text.lua b/test/tests/text.lua index 9c00295..fe44ce0 100644 --- a/test/tests/text.lua +++ b/test/tests/text.lua @@ -1,14 +1,14 @@ local _={} _[5]={} -_[4]={data="a",tags=_[5]} +_[4]={tags=_[5],text="a"} _[3]={_[4]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "a", - tags = {} + tags = {}, + text = "a" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/unary operator overload.lua b/test/tests/unary operator overload.lua index c937fc5..3797b53 100644 --- a/test/tests/unary operator overload.lua +++ b/test/tests/unary operator overload.lua @@ -2,9 +2,9 @@ local _={} _[13]={} _[12]={} _[11]={} -_[10]={data="generic minus",tags=_[13]} -_[9]={data="minus lol",tags=_[12]} -_[8]={data="-5",tags=_[11]} +_[10]={tags=_[13],text="generic minus"} +_[9]={tags=_[12],text="minus lol"} +_[8]={tags=_[11],text="-5"} _[7]={_[10]} _[6]={_[9]} _[5]={_[8]} @@ -15,16 +15,16 @@ _[1]={"text",_[5]} return {_[1],_[2],_[3],_[4]} --[[ { "text", { { - data = "-5", - tags = {} + tags = {}, + text = "-5" } } } { "text", { { - data = "minus lol", - tags = {} + tags = {}, + text = "minus lol" } } } { "text", { { - data = "generic minus", - tags = {} + tags = {}, + text = "generic minus" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/unseen line.lua b/test/tests/unseen line.lua index f2546fa..e6f2745 100644 --- a/test/tests/unseen line.lua +++ b/test/tests/unseen line.lua @@ -4,31 +4,31 @@ _[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],text="b"} +_[7]={tags=_[12],text="a"} +_[6]={tags=_[11],text="b"} +_[5]={tags=_[10],text="seen only once"} +_[4]={tags=_[9],text="a"} _[3]={_[4],_[5],_[6],_[7],_[8]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "a", - tags = {} + tags = {}, + text = "a" }, { - data = "seen only once", - tags = {} + tags = {}, + text = "seen only once" }, { - data = "b", - tags = {} + tags = {}, + text = "b" }, { - data = "a", - tags = {} + tags = {}, + text = "a" }, { - data = "b", - tags = {} + tags = {}, + text = "b" } } } { "return" } ]]-- \ No newline at end of file diff --git a/test/tests/variable alias.lua b/test/tests/variable alias.lua index 3a434a7..794e4c4 100644 --- a/test/tests/variable alias.lua +++ b/test/tests/variable alias.lua @@ -1,14 +1,22 @@ local _={} -_[5]={} -_[4]={data="42 = 42",tags=_[5]} -_[3]={_[4]} +_[7]={} +_[6]={tags=_[7],text="42"} +_[5]={tags=_[7],text=" = "} +_[4]={tags=_[7],text="42"} +_[3]={_[4],_[5],_[6]} _[2]={"return"} _[1]={"text",_[3]} return {_[1],_[2]} --[[ { "text", { { - data = "42 = 42", - tags = {} + tags = <1>{}, + text = "42" + }, { + tags =
, + text = " = " + }, { + tags =
, + text = "42" } } } { "return" } ]]-- \ No newline at end of file