mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-27 16:49:31 +00:00
Fix a lot of issues when resuming from a paragraph in a choice or expression block
This commit is contained in:
parent
f93d6fab6b
commit
dde89502da
67 changed files with 762 additions and 173 deletions
|
|
@ -139,7 +139,7 @@ There's different types of lines, depending on their first character(s) (after i
|
|||
|
||||
* `~`: expression line. Can be followed by an [expression](#expressions); otherwise the expression `1` is assumed. If the expression evaluates to [true](#truethness), run its children.
|
||||
|
||||
* `~~`: else expression. Same as an expression line, but is only run if the last expression or else-expression line was false (regardless of line distance).
|
||||
* `~~`: else expression. Same as an expression line, but is only run if the last expression or else-expression line (in the same indentation block) was false (regardless of line distance).
|
||||
|
||||
```
|
||||
~ 1
|
||||
|
|
|
|||
|
|
@ -335,6 +335,8 @@ local vm_mt = {
|
|||
-- events
|
||||
event_type = nil,
|
||||
event_buffer = nil,
|
||||
-- skip next choices until next event change (to skip currently running choice block when resuming from a paragraph)
|
||||
skip_choices_until_flush = nil,
|
||||
-- status
|
||||
running_line = nil,
|
||||
-- choice
|
||||
|
|
@ -342,8 +344,6 @@ local vm_mt = {
|
|||
choice_available = {},
|
||||
-- interrupt
|
||||
interrupt = nil,
|
||||
-- conditions
|
||||
last_condition_success = nil,
|
||||
-- tags
|
||||
tags = tags or {},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ local function eval(state, exp)
|
|||
if fn.value.type == "paragraph" or fn.value.paragraph then
|
||||
local r, e
|
||||
if fn.value.type == "paragraph" then
|
||||
r, e = run_block(state, fn.value.child, false)
|
||||
r, e = run_block(state, fn.value.child)
|
||||
if e then return r, e end
|
||||
state.variables[fn.value.namespace.."👁️"] = {
|
||||
type = "number",
|
||||
|
|
|
|||
|
|
@ -51,23 +51,29 @@ local function run_line(state, line)
|
|||
if not v then return v, ("%s; in tag decorator at %s"):format(e, line.source) end
|
||||
tags:push(state, v)
|
||||
end
|
||||
-- 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
|
||||
state.interpreter.last_condition_success = nil
|
||||
line.parent_block.last_condition_success = nil
|
||||
local v, e = eval(state, line.expression)
|
||||
if not v then return v, ("%s; at %s"):format(e, line.source) end
|
||||
if truthy(v) then
|
||||
state.interpreter.last_condition_success = true
|
||||
line.parent_block.last_condition_success = true
|
||||
v, e = run_block(state, line.child)
|
||||
if e then return v, e end
|
||||
if v then return v end
|
||||
end
|
||||
elseif line.type == "else-condition" then
|
||||
if not state.interpreter.last_condition_success then
|
||||
if not line.parent_block.last_condition_success then
|
||||
local v, e = eval(state, line.expression)
|
||||
if not v then return v, ("%s; at %s"):format(e, line.source) end
|
||||
if truthy(v) then
|
||||
state.interpreter.last_condition_success = true
|
||||
line.parent_block.last_condition_success = true
|
||||
v, e = run_block(state, line.child)
|
||||
if e then return v, e end
|
||||
if v then return v end
|
||||
|
|
@ -146,19 +152,40 @@ 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
|
||||
run_block = function(state, block, run_whole_function, i, j)
|
||||
run_block = function(state, block, resume_from_there, i, j)
|
||||
i = i or 1
|
||||
local len = math.min(#block, j or math.huge)
|
||||
while i <= len do
|
||||
local v, e = run_line(state, block[i])
|
||||
if e then return v, e end
|
||||
if v then return v end
|
||||
local max = math.min(#block, j or math.huge)
|
||||
while i <= max do
|
||||
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
|
||||
end
|
||||
-- run line
|
||||
if not skip then
|
||||
local v, e = run_line(state, line)
|
||||
if e then return v, e end
|
||||
if v then return v end
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
-- go up hierarchy if asked to run the whole function
|
||||
if run_whole_function and block.parent_line and block.parent_line.type ~= "function" then
|
||||
-- go up hierarchy if asked to resume
|
||||
-- will stop at function boundary
|
||||
-- if parent is a choice, will ignore choices that belong to the same block (like the whole block was executed naturally from a higher parent)
|
||||
-- if parent if a condition, will mark it as a success (skipping following else-conditions) (for the same reasons as for choices)
|
||||
if resume_from_there and block.parent_line and block.parent_line.type ~= "function" then
|
||||
local parent_line = block.parent_line
|
||||
local v, e = run_block(state, parent_line.parent_block, run_whole_function, parent_line.parent_position+1)
|
||||
if parent_line.type == "choice" then
|
||||
state.interpreter.skip_choices_until_flush = true
|
||||
elseif parent_line.type == "condition" or parent_line.type == "else-condition" then
|
||||
parent_line.parent_block.last_condition_success = true
|
||||
end
|
||||
local v, e = run_block(state, parent_line.parent_block, resume_from_there, parent_line.parent_position+1)
|
||||
if e then return v, e end
|
||||
if v then return v, e end
|
||||
end
|
||||
|
|
@ -167,9 +194,9 @@ end
|
|||
|
||||
-- returns var in case of success
|
||||
-- return nil, err in case of error
|
||||
local function run(state, block, run_whole_function, i, j)
|
||||
local function run(state, block, resume_from_there, i, j)
|
||||
-- run
|
||||
local v, e = run_block(state, block, run_whole_function, i, j)
|
||||
local v, e = run_block(state, block, resume_from_there, i, j)
|
||||
if e then return v, e end
|
||||
if v then
|
||||
return v
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ common = {
|
|||
return nil, ("can't find %q in namespace %s"):format(name, namespace)
|
||||
end,
|
||||
--- transform an identifier into a clean version (trim each part)
|
||||
format_identifier = function(identifier, state)
|
||||
format_identifier = function(identifier)
|
||||
local r = identifier:gsub("[^%.]+", function(str)
|
||||
return common.trim(str)
|
||||
end)
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ local function expression(s, state, namespace, currentPriority, operatingOn)
|
|||
-- identifier
|
||||
elseif s:match("^"..identifier_pattern) then
|
||||
local name, r = s:match("^("..identifier_pattern..")(.-)$")
|
||||
name = format_identifier(name, state)
|
||||
name = format_identifier(name)
|
||||
-- variables
|
||||
local var, vfqm = find(state.aliases, state.variables, namespace, name)
|
||||
if var then
|
||||
|
|
@ -161,7 +161,7 @@ local function expression(s, state, namespace, currentPriority, operatingOn)
|
|||
-- suffix call
|
||||
if op == "." and sright:match("^"..identifier_pattern) then
|
||||
local name, r = sright:match("^("..identifier_pattern..")(.-)$")
|
||||
name = format_identifier(name, state)
|
||||
name = format_identifier(name)
|
||||
local funcs, ffqm = find(state.aliases, state.functions, namespace, name)
|
||||
if funcs then
|
||||
local args, explicit_call
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ local function parse_line(line, state, namespace)
|
|||
local identifier, rem = name:match("^("..identifier_pattern..")(.-)$")
|
||||
if not identifier then return nil, ("no valid identifier in paragraph decorator %q; at %s"):format(identifier, line.source) end
|
||||
-- format identifier
|
||||
local fqm = ("%s%s"):format(namespace, format_identifier(identifier, state))
|
||||
local fqm = ("%s%s"):format(namespace, format_identifier(identifier))
|
||||
-- get alias
|
||||
if rem:match("^%:") then
|
||||
local content = rem:sub(2)
|
||||
|
|
@ -38,7 +38,7 @@ local function parse_line(line, state, namespace)
|
|||
if not alias then return nil, ("expected an identifier in alias in paragraph decorator, but got %q; at %s"):format(content, line.source) end
|
||||
if rem2:match("[^%s]") then return nil, ("expected end-of-line after identifier in alias in paragraph decorator, but got %q; at %s"):format(rem2, line.source) end
|
||||
-- format alias
|
||||
local aliasfqm = ("%s%s"):format(namespace, format_identifier(alias, state))
|
||||
local aliasfqm = ("%s%s"):format(namespace, format_identifier(alias))
|
||||
-- define alias
|
||||
if state.aliases[aliasfqm] ~= nil and state.aliases[aliasfqm] ~= fqm then
|
||||
return nil, ("trying to define alias %q for variable %q, but already exist and refer to different variable %q; at %s"):format(aliasfqm, fqm, state.aliases[aliasfqm], line.source)
|
||||
|
|
@ -113,7 +113,7 @@ local function parse_line(line, state, namespace)
|
|||
local identifier, rem = lc:match("^("..identifier_pattern..")(.-)$")
|
||||
if not identifier then return nil, ("no valid identifier in paragraph/function definition line %q; at %s"):format(lc, line.source) end
|
||||
-- format identifier
|
||||
local fqm = ("%s%s"):format(namespace, format_identifier(identifier, state))
|
||||
local fqm = ("%s%s"):format(namespace, format_identifier(identifier))
|
||||
-- get alias
|
||||
if rem:match("^%:") then
|
||||
local content = rem:sub(2)
|
||||
|
|
@ -121,7 +121,7 @@ local function parse_line(line, state, namespace)
|
|||
alias, rem = content:match("^("..identifier_pattern..")(.-)$")
|
||||
if not alias then return nil, ("expected an identifier in alias in paragraph/function definition line, but got %q; at %s"):format(content, line.source) end
|
||||
-- format alias
|
||||
local aliasfqm = ("%s%s"):format(namespace, format_identifier(alias, state))
|
||||
local aliasfqm = ("%s%s"):format(namespace, format_identifier(alias))
|
||||
-- define alias
|
||||
if state.aliases[aliasfqm] ~= nil and state.aliases[aliasfqm] ~= fqm then
|
||||
return nil, ("trying to define alias %q for function/paragraph %q, but already exist and refer to %q; at %s"):format(aliasfqm, fqm, state.aliases[aliasfqm], line.source)
|
||||
|
|
@ -137,7 +137,7 @@ local function parse_line(line, state, namespace)
|
|||
local param_identifier, param_rem = param:match("^("..identifier_pattern..")(.-)$")
|
||||
if not identifier then return nil, ("no valid identifier in function parameter %q; at %s"):format(param, line.source) end
|
||||
-- format identifier
|
||||
local param_fqm = ("%s.%s"):format(fqm, format_identifier(param_identifier, state))
|
||||
local param_fqm = ("%s.%s"):format(fqm, format_identifier(param_identifier))
|
||||
-- get alias
|
||||
if param_rem:match("^%:") then
|
||||
local param_content = param_rem:sub(2)
|
||||
|
|
@ -145,7 +145,7 @@ local function parse_line(line, state, namespace)
|
|||
alias, param_rem = param_content:match("^("..identifier_pattern..")(.-)$")
|
||||
if not alias then return nil, ("expected an identifier in alias in parameter, but got %q; at %s"):format(param_content, line.source) end
|
||||
-- format alias
|
||||
local aliasfqm = ("%s.%s"):format(fqm, format_identifier(alias, state))
|
||||
local aliasfqm = ("%s.%s"):format(fqm, format_identifier(alias))
|
||||
-- define alias
|
||||
if state.aliases[aliasfqm] ~= nil and state.aliases[aliasfqm] ~= param_fqm then
|
||||
return nil, ("trying to define alias %q for parameter %q, but already exist and refer to %q; at %s"):format(aliasfqm, param_fqm, state.aliases[aliasfqm], line.source)
|
||||
|
|
@ -268,7 +268,7 @@ local function parse_line(line, state, namespace)
|
|||
local identifier, rem2 = rem:match("^("..identifier_pattern..")(.-)$")
|
||||
if not identifier then return nil, ("no valid identifier after expression in definition line %q; at %s"):format(rem, line.source) end
|
||||
-- format identifier
|
||||
local fqm = ("%s%s"):format(namespace, format_identifier(identifier, state))
|
||||
local fqm = ("%s%s"):format(namespace, format_identifier(identifier))
|
||||
-- get alias
|
||||
if rem2:match("^%:") then
|
||||
local content = rem2:sub(2)
|
||||
|
|
@ -276,7 +276,7 @@ local function parse_line(line, state, namespace)
|
|||
if not alias then return nil, ("expected an identifier in alias in definition line, but got %q; at %s"):format(content, line.source) end
|
||||
if rem3:match("[^%s]") then return nil, ("expected end-of-line after identifier in alias in definition line, but got %q; at %s"):format(rem3, line.source) end
|
||||
-- format alias
|
||||
local aliasfqm = ("%s%s"):format(namespace, format_identifier(alias, state))
|
||||
local aliasfqm = ("%s%s"):format(namespace, format_identifier(alias))
|
||||
-- define alias
|
||||
if state.aliases[aliasfqm] ~= nil and state.aliases[aliasfqm] ~= fqm then
|
||||
return nil, ("trying to define alias %s for variable %s, but already exist and refer to different variable %s; at %s"):format(aliasfqm, fqm, state.aliases[aliasfqm], line.source)
|
||||
|
|
@ -324,7 +324,7 @@ end
|
|||
|
||||
-- * block: in case of success
|
||||
-- * nil, err: in case of error
|
||||
local function parse_block(indented, state, namespace, parent_function, last_event)
|
||||
local function parse_block(indented, state, namespace, parent_function)
|
||||
local block = { type = "block" }
|
||||
local lastLine -- last line AST
|
||||
for i, l in ipairs(indented) do
|
||||
|
|
@ -338,14 +338,6 @@ local function parse_block(indented, state, namespace, parent_function, last_eve
|
|||
-- add to block AST
|
||||
if not ast.remove_from_block_ast then
|
||||
ast.parent_block = block
|
||||
-- insert flush on event type change
|
||||
if ast.type == "flush" then last_event = nil end
|
||||
if ast.push_event then
|
||||
if last_event and ast.push_event ~= last_event then
|
||||
table.insert(block, { source = l.source, type = "flush_events" })
|
||||
end
|
||||
last_event = ast.push_event
|
||||
end
|
||||
-- add ast node
|
||||
ast.parent_position = #block+1
|
||||
if ast.replace_with then
|
||||
|
|
@ -367,7 +359,7 @@ local function parse_block(indented, state, namespace, parent_function, last_eve
|
|||
if not lastLine.child then
|
||||
return nil, ("line %s (%s) can't have children"):format(lastLine.source, lastLine.type)
|
||||
else
|
||||
local r, e = parse_block(l, state, lastLine.namespace or namespace, lastLine.type == "function" and lastLine or parent_function, last_event)
|
||||
local r, e = parse_block(l, state, lastLine.namespace or namespace, lastLine.type == "function" and lastLine or parent_function)
|
||||
if not r then return r, e end
|
||||
r.parent_line = lastLine
|
||||
lastLine.child = r
|
||||
|
|
@ -395,17 +387,17 @@ local function parse_indent(lines, source, i, indentLevel, insert_empty_line)
|
|||
table.insert(indented, { content = line, source = ("%s:%s"):format(source, i) })
|
||||
elseif #indent > indentLevel then
|
||||
local t
|
||||
t, i = parse_indent(lines, source, i, #indent, insert_empty_line)
|
||||
t, i, insert_empty_line = parse_indent(lines, source, i, #indent, insert_empty_line)
|
||||
table.insert(indented, t)
|
||||
else
|
||||
return indented, i-1
|
||||
return indented, i-1, insert_empty_line
|
||||
end
|
||||
elseif not insert_empty_line then
|
||||
insert_empty_line = i
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
return indented, i-1
|
||||
return indented, i-1, insert_empty_line
|
||||
end
|
||||
|
||||
--- return the list of raw lines of s
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ _[19]={}
|
|||
_[18]={}
|
||||
_[17]={}
|
||||
_[16]={}
|
||||
_[15]={tags=_[21],data="plop"}
|
||||
_[14]={tags=_[20],data="oh"}
|
||||
_[13]={tags=_[19],data="ho"}
|
||||
_[12]={tags=_[18],data="ok"}
|
||||
_[11]={tags=_[17],data="ne"}
|
||||
_[10]={tags=_[16],data="ye"}
|
||||
_[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]}
|
||||
_[9]={_[15]}
|
||||
_[8]={_[13],_[14]}
|
||||
_[7]={_[12]}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ _[14]={}
|
|||
_[13]={}
|
||||
_[12]={}
|
||||
_[11]={}
|
||||
_[10]={tags=_[15],data="ok"}
|
||||
_[9]={tags=_[14],data="neol"}
|
||||
_[8]={tags=_[13],data="oh"}
|
||||
_[7]={tags=_[12],data="neol"}
|
||||
_[6]={tags=_[11],data="ho"}
|
||||
_[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]}
|
||||
_[5]={_[10]}
|
||||
_[4]={_[6],_[7],_[8],_[9]}
|
||||
_[3]={"return"}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ local _={}
|
|||
_[11]={}
|
||||
_[10]={}
|
||||
_[9]={}
|
||||
_[8]={tags=_[11],data="ok"}
|
||||
_[7]={tags=_[10],data="ne"}
|
||||
_[6]={tags=_[9],data="ye"}
|
||||
_[8]={data="ok",tags=_[11]}
|
||||
_[7]={data="ne",tags=_[10]}
|
||||
_[6]={data="ye",tags=_[9]}
|
||||
_[5]={_[8]}
|
||||
_[4]={_[6],_[7]}
|
||||
_[3]={"return"}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ _[17]={}
|
|||
_[16]={}
|
||||
_[15]={}
|
||||
_[14]={}
|
||||
_[13]={tags=_[17],data="parallel: 2"}
|
||||
_[12]={tags=_[16],data="after: 2"}
|
||||
_[11]={tags=_[15],data="parallel: 5"}
|
||||
_[10]={tags=_[14],data="before: 2"}
|
||||
_[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]}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
local _={}
|
||||
_[7]={}
|
||||
_[6]={}
|
||||
_[5]={tags=_[7],data="ok bis"}
|
||||
_[4]={tags=_[6],data="ok"}
|
||||
_[5]={data="ok bis",tags=_[7]}
|
||||
_[4]={data="ok",tags=_[6]}
|
||||
_[3]={_[4],_[5]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={tags=_[5],data="ok"}
|
||||
_[4]={data="ok",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={tags=_[5],data="ok"}
|
||||
_[4]={data="ok",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={tags=_[5],data="ok"}
|
||||
_[4]={data="ok",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={tags=_[5],data="ok"}
|
||||
_[4]={data="ok",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={tags=_[5],data="ok"}
|
||||
_[4]={data="ok",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
local _={}
|
||||
_[8]={}
|
||||
_[7]={}
|
||||
_[6]={tags=_[8],data="ho"}
|
||||
_[5]={tags=_[7],data="ah"}
|
||||
_[6]={data="ho",tags=_[8]}
|
||||
_[5]={data="ah",tags=_[7]}
|
||||
_[4]={_[5],_[6]}
|
||||
_[3]={"return"}
|
||||
_[2]={"text",_[4]}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={tags=_[5],data="a: 5"}
|
||||
_[4]={data="a: 5",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -7,14 +7,14 @@ _[29]={}
|
|||
_[28]={}
|
||||
_[27]={}
|
||||
_[26]={}
|
||||
_[25]={tags=_[33],data="1 = 1"}
|
||||
_[24]={tags=_[32],data="0 = 0"}
|
||||
_[23]={tags=_[31],data="0 = 0"}
|
||||
_[22]={tags=_[30],data="0 = 0"}
|
||||
_[21]={tags=_[29],data="0 = 0"}
|
||||
_[20]={tags=_[28],data="1 = 1"}
|
||||
_[19]={tags=_[27],data="0 = 0"}
|
||||
_[18]={tags=_[26],data="0 = 0"}
|
||||
_[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]}
|
||||
|
|
|
|||
8
test/tests/flush.ans
Normal file
8
test/tests/flush.ans
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
a
|
||||
|
||||
> b
|
||||
~ choose(1)
|
||||
|
||||
c
|
||||
> d
|
||||
~ choose(1)
|
||||
38
test/tests/flush.lua
Normal file
38
test/tests/flush.lua
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
local _={}
|
||||
_[17]={}
|
||||
_[16]={}
|
||||
_[15]={}
|
||||
_[14]={}
|
||||
_[13]={data="d",tags=_[17]}
|
||||
_[12]={data="c",tags=_[16]}
|
||||
_[11]={data="b",tags=_[15]}
|
||||
_[10]={data="a",tags=_[14]}
|
||||
_[9]={_[13]}
|
||||
_[8]={_[12]}
|
||||
_[7]={_[11]}
|
||||
_[6]={_[10]}
|
||||
_[5]={"return"}
|
||||
_[4]={"choice",_[9]}
|
||||
_[3]={"text",_[8]}
|
||||
_[2]={"choice",_[7]}
|
||||
_[1]={"text",_[6]}
|
||||
return {_[1],_[2],_[3],_[4],_[5]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "a",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "choice", { {
|
||||
data = "b",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "c",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "choice", { {
|
||||
data = "d",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
local _={}
|
||||
_[7]={}
|
||||
_[6]={}
|
||||
_[5]={tags=_[7],data="[o, k]"}
|
||||
_[4]={tags=_[6],data="ok"}
|
||||
_[5]={data="[o, k]",tags=_[7]}
|
||||
_[4]={data="ok",tags=_[6]}
|
||||
_[3]={_[4],_[5]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={tags=_[5],data="ok"}
|
||||
_[4]={data="ok",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
local _={}
|
||||
_[7]={}
|
||||
_[6]={}
|
||||
_[5]={tags=_[7],data="[]"}
|
||||
_[4]={tags=_[6],data="ok"}
|
||||
_[5]={data="[]",tags=_[7]}
|
||||
_[4]={data="ok",tags=_[6]}
|
||||
_[3]={_[4],_[5]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
local _={}
|
||||
_[7]={}
|
||||
_[6]={}
|
||||
_[5]={tags=_[7],data="[o, k]"}
|
||||
_[4]={tags=_[6],data="ok"}
|
||||
_[5]={data="[o, k]",tags=_[7]}
|
||||
_[4]={data="ok",tags=_[6]}
|
||||
_[3]={_[4],_[5]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={tags=_[5],data="ok"}
|
||||
_[4]={data="ok",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ _[20]={}
|
|||
_[19]={}
|
||||
_[18]={}
|
||||
_[17]={}
|
||||
_[16]={tags=_[21],data="b"}
|
||||
_[15]={tags=_[20],data="a"}
|
||||
_[14]={tags=_[19],data="c"}
|
||||
_[13]={tags=_[18],data="b"}
|
||||
_[12]={tags=_[17],data="a"}
|
||||
_[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]}
|
||||
_[11]={_[16]}
|
||||
_[10]={_[15]}
|
||||
_[9]={_[14]}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ _[20]={}
|
|||
_[19]={}
|
||||
_[18]={}
|
||||
_[17]={}
|
||||
_[16]={tags=_[21],data="c"}
|
||||
_[15]={tags=_[20],data="c"}
|
||||
_[14]={tags=_[19],data="c"}
|
||||
_[13]={tags=_[18],data="b"}
|
||||
_[12]={tags=_[17],data="a"}
|
||||
_[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]}
|
||||
_[11]={_[16]}
|
||||
_[10]={_[15]}
|
||||
_[9]={_[14]}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ _[20]={}
|
|||
_[19]={}
|
||||
_[18]={}
|
||||
_[17]={}
|
||||
_[16]={tags=_[21],data="a"}
|
||||
_[15]={tags=_[20],data="a"}
|
||||
_[14]={tags=_[19],data="b"}
|
||||
_[13]={tags=_[18],data="a"}
|
||||
_[12]={tags=_[17],data="b"}
|
||||
_[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]}
|
||||
_[11]={_[16]}
|
||||
_[10]={_[15]}
|
||||
_[9]={_[14]}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
local _={}
|
||||
_[7]={}
|
||||
_[6]={}
|
||||
_[5]={tags=_[7],data="2"}
|
||||
_[4]={tags=_[6],data="5"}
|
||||
_[5]={data="2",tags=_[7]}
|
||||
_[4]={data="5",tags=_[6]}
|
||||
_[3]={_[4],_[5]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={tags=_[5],data="5"}
|
||||
_[4]={data="5",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={tags=_[5],data="a: 5"}
|
||||
_[4]={data="a: 5",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
local _={}
|
||||
_[9]={}
|
||||
_[8]={}
|
||||
_[7]={tags=_[9],data="ok"}
|
||||
_[6]={tags=_[8],data="ok"}
|
||||
_[7]={data="ok",tags=_[9]}
|
||||
_[6]={data="ok",tags=_[8]}
|
||||
_[5]={_[7]}
|
||||
_[4]={_[6]}
|
||||
_[3]={"return"}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={tags=_[5],data="ok"}
|
||||
_[4]={data="ok",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={tags=_[5],data="[]"}
|
||||
_[4]={data="[]",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={tags=_[5],data="[o, k]"}
|
||||
_[4]={data="[o, k]",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={tags=_[5],data="ok"}
|
||||
_[4]={data="ok",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ local _={}
|
|||
_[12]={}
|
||||
_[11]={}
|
||||
_[10]={}
|
||||
_[9]={tags=_[12],data="no"}
|
||||
_[8]={tags=_[11],data="in interrupt: 5"}
|
||||
_[7]={tags=_[10],data="before: 2"}
|
||||
_[9]={data="no",tags=_[12]}
|
||||
_[8]={data="in interrupt: 5",tags=_[11]}
|
||||
_[7]={data="before: 2",tags=_[10]}
|
||||
_[6]={_[8],_[9]}
|
||||
_[5]={_[7]}
|
||||
_[4]={"return"}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
local _={}
|
||||
_[10]={}
|
||||
_[9]={}
|
||||
_[8]={tags=_[10],data="in interrupt: 5"}
|
||||
_[7]={tags=_[9],data="before: 2"}
|
||||
_[8]={data="in interrupt: 5",tags=_[10]}
|
||||
_[7]={data="before: 2",tags=_[9]}
|
||||
_[6]={_[8]}
|
||||
_[5]={_[7]}
|
||||
_[4]={"return"}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
local _={}
|
||||
_[10]={}
|
||||
_[9]={}
|
||||
_[8]={tags=_[10],data="in interrupt: 5"}
|
||||
_[7]={tags=_[9],data="before: 2"}
|
||||
_[8]={data="in interrupt: 5",tags=_[10]}
|
||||
_[7]={data="before: 2",tags=_[9]}
|
||||
_[6]={_[8]}
|
||||
_[5]={_[7]}
|
||||
_[4]={"return"}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local _={}
|
||||
_[6]={}
|
||||
_[5]={tags=_[6],data="before: 2"}
|
||||
_[5]={data="before: 2",tags=_[6]}
|
||||
_[4]={_[5]}
|
||||
_[3]={"return",""}
|
||||
_[2]={"wait",0}
|
||||
|
|
|
|||
19
test/tests/nested conditions.ans
Normal file
19
test/tests/nested conditions.ans
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
~ 1
|
||||
yes
|
||||
~ 0
|
||||
no
|
||||
~~
|
||||
nope
|
||||
~ 1
|
||||
hai
|
||||
~ 0
|
||||
still no
|
||||
~~
|
||||
nein
|
||||
|
||||
~ 0
|
||||
nah
|
||||
~~
|
||||
ye
|
||||
~~
|
||||
da
|
||||
27
test/tests/nested conditions.lua
Normal file
27
test/tests/nested conditions.lua
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
local _={}
|
||||
_[11]={}
|
||||
_[10]={}
|
||||
_[9]={}
|
||||
_[8]={data="da",tags=_[11]}
|
||||
_[7]={data="ye",tags=_[10]}
|
||||
_[6]={data="yes",tags=_[9]}
|
||||
_[5]={_[7],_[8]}
|
||||
_[4]={_[6]}
|
||||
_[3]={"return"}
|
||||
_[2]={"text",_[5]}
|
||||
_[1]={"text",_[4]}
|
||||
return {_[1],_[2],_[3]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "yes",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "ye",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "da",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
19
test/tests/nested flush.ans
Normal file
19
test/tests/nested flush.ans
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
~ 1
|
||||
a
|
||||
|
||||
b
|
||||
|
||||
~ 1
|
||||
c
|
||||
d
|
||||
|
||||
~ 1
|
||||
e
|
||||
|
||||
> f
|
||||
~ choose(1)
|
||||
|
||||
~ 1
|
||||
g
|
||||
> h
|
||||
~ choose(1)
|
||||
67
test/tests/nested flush.lua
Normal file
67
test/tests/nested flush.lua
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
local _={}
|
||||
_[31]={}
|
||||
_[30]={}
|
||||
_[29]={}
|
||||
_[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]}
|
||||
_[15]={_[23]}
|
||||
_[14]={_[22]}
|
||||
_[13]={_[21]}
|
||||
_[12]={_[20]}
|
||||
_[11]={_[18],_[19]}
|
||||
_[10]={_[17]}
|
||||
_[9]={_[16]}
|
||||
_[8]={"return"}
|
||||
_[7]={"choice",_[15]}
|
||||
_[6]={"text",_[14]}
|
||||
_[5]={"choice",_[13]}
|
||||
_[4]={"text",_[12]}
|
||||
_[3]={"text",_[11]}
|
||||
_[2]={"text",_[10]}
|
||||
_[1]={"text",_[9]}
|
||||
return {_[1],_[2],_[3],_[4],_[5],_[6],_[7],_[8]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "a",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "b",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "c",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "d",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "e",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "choice", { {
|
||||
data = "f",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "g",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "choice", { {
|
||||
data = "h",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
local _={}
|
||||
_[9]={}
|
||||
_[8]={}
|
||||
_[7]={tags=_[9],data="a.\240\159\145\129\239\184\143: 1"}
|
||||
_[6]={tags=_[8],data="a.\240\159\145\129\239\184\143: 0"}
|
||||
_[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]}
|
||||
_[3]={"return"}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
local _={}
|
||||
_[7]={}
|
||||
_[6]={}
|
||||
_[5]={tags=_[7],data="ok"}
|
||||
_[4]={tags=_[6],data="a.\240\159\145\129\239\184\143: 0"}
|
||||
_[5]={data="ok",tags=_[7]}
|
||||
_[4]={data="a.\240\159\145\129\239\184\143: 0",tags=_[6]}
|
||||
_[3]={_[4],_[5]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={tags=_[5],data="a.\240\159\145\129\239\184\143: 0"}
|
||||
_[4]={data="a.\240\159\145\129\239\184\143: 0",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -7,14 +7,14 @@ _[19]={}
|
|||
_[18]={}
|
||||
_[17]={}
|
||||
_[16]={}
|
||||
_[15]={tags=_[23],data="b"}
|
||||
_[14]={tags=_[22],data="x"}
|
||||
_[13]={tags=_[21],data="Force no checkpoint:"}
|
||||
_[12]={tags=_[20],data="b"}
|
||||
_[11]={tags=_[19],data="a"}
|
||||
_[10]={tags=_[18],data="From checkpoint:"}
|
||||
_[9]={tags=_[17],data="a"}
|
||||
_[8]={tags=_[16],data="Force run checkpoint:"}
|
||||
_[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]}
|
||||
_[7]={_[13],_[14],_[15]}
|
||||
_[6]={_[10],_[11],_[12]}
|
||||
_[5]={_[8],_[9]}
|
||||
|
|
|
|||
|
|
@ -8,15 +8,15 @@ _[20]={}
|
|||
_[19]={}
|
||||
_[18]={}
|
||||
_[17]={}
|
||||
_[16]={tags=_[25],data="b"}
|
||||
_[15]={tags=_[24],data="x"}
|
||||
_[14]={tags=_[23],data="Force no checkpoint:"}
|
||||
_[13]={tags=_[22],data="b"}
|
||||
_[12]={tags=_[21],data="a"}
|
||||
_[11]={tags=_[20],data="From checkpoint:"}
|
||||
_[10]={tags=_[19],data="b"}
|
||||
_[9]={tags=_[18],data="a"}
|
||||
_[8]={tags=_[17],data="Force run from checkpoint:"}
|
||||
_[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]}
|
||||
_[7]={_[14],_[15],_[16]}
|
||||
_[6]={_[11],_[12],_[13]}
|
||||
_[5]={_[8],_[9],_[10]}
|
||||
|
|
|
|||
|
|
@ -8,15 +8,15 @@ _[20]={}
|
|||
_[19]={}
|
||||
_[18]={}
|
||||
_[17]={}
|
||||
_[16]={tags=_[25],data="b"}
|
||||
_[15]={tags=_[24],data="x"}
|
||||
_[14]={tags=_[23],data="Force no checkpoint:"}
|
||||
_[13]={tags=_[22],data="b"}
|
||||
_[12]={tags=_[21],data="a"}
|
||||
_[11]={tags=_[20],data="From checkpoint:"}
|
||||
_[10]={tags=_[19],data="b"}
|
||||
_[9]={tags=_[18],data="x"}
|
||||
_[8]={tags=_[17],data="No checkpoint:"}
|
||||
_[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]}
|
||||
_[7]={_[14],_[15],_[16]}
|
||||
_[6]={_[11],_[12],_[13]}
|
||||
_[5]={_[8],_[9],_[10]}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={tags=_[5],data="b"}
|
||||
_[4]={data="b",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
77
test/tests/resume from paragraph with nested choice.ans
Normal file
77
test/tests/resume from paragraph with nested choice.ans
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
$ f
|
||||
> a
|
||||
-> a
|
||||
§ p
|
||||
> aa
|
||||
-> aa
|
||||
> ab
|
||||
-> ab
|
||||
> b
|
||||
-> b
|
||||
~ choose(2)
|
||||
|
||||
> c
|
||||
-> c
|
||||
~ choose(1)
|
||||
|
||||
~ f
|
||||
|
||||
~ f.p
|
||||
|
||||
$ g
|
||||
> a
|
||||
-> a
|
||||
§ p
|
||||
> aa
|
||||
-> aa
|
||||
> ab
|
||||
-> ab
|
||||
> b
|
||||
-> b
|
||||
~ choose(2)
|
||||
autoflush
|
||||
> c
|
||||
-> c
|
||||
~ choose(1)
|
||||
|
||||
~ g
|
||||
|
||||
~ g.p
|
||||
|
||||
$ h
|
||||
~ 1
|
||||
> a
|
||||
-> a
|
||||
§ p
|
||||
> aa
|
||||
-> aa
|
||||
> ab
|
||||
-> ab
|
||||
~ choose(1)
|
||||
> b
|
||||
-> b
|
||||
> c
|
||||
-> c
|
||||
~ choose(1)
|
||||
|
||||
~ h
|
||||
|
||||
~ h.p
|
||||
|
||||
$ i
|
||||
> a
|
||||
-> a
|
||||
§ p
|
||||
> aa
|
||||
-> aa
|
||||
> ab
|
||||
-> ab
|
||||
> b
|
||||
-> b
|
||||
~ 1
|
||||
> c
|
||||
-> c
|
||||
|
||||
~ i
|
||||
|
||||
~ i.p
|
||||
256
test/tests/resume from paragraph with nested choice.lua
Normal file
256
test/tests/resume from paragraph with nested choice.lua
Normal file
|
|
@ -0,0 +1,256 @@
|
|||
local _={}
|
||||
_[121]={}
|
||||
_[120]={}
|
||||
_[119]={}
|
||||
_[118]={}
|
||||
_[117]={}
|
||||
_[116]={}
|
||||
_[115]={}
|
||||
_[114]={}
|
||||
_[113]={}
|
||||
_[112]={}
|
||||
_[111]={}
|
||||
_[110]={}
|
||||
_[109]={}
|
||||
_[108]={}
|
||||
_[107]={}
|
||||
_[106]={}
|
||||
_[105]={}
|
||||
_[104]={}
|
||||
_[103]={}
|
||||
_[102]={}
|
||||
_[101]={}
|
||||
_[100]={}
|
||||
_[99]={}
|
||||
_[98]={}
|
||||
_[97]={}
|
||||
_[96]={}
|
||||
_[95]={}
|
||||
_[94]={}
|
||||
_[93]={}
|
||||
_[92]={}
|
||||
_[91]={}
|
||||
_[90]={}
|
||||
_[89]={}
|
||||
_[88]={}
|
||||
_[87]={}
|
||||
_[86]={data="c",tags=_[121]}
|
||||
_[85]={data="b",tags=_[120]}
|
||||
_[84]={data="a",tags=_[119]}
|
||||
_[83]={data="-> aa",tags=_[118]}
|
||||
_[82]={data="ab",tags=_[117]}
|
||||
_[81]={data="aa",tags=_[116]}
|
||||
_[80]={data="-> aa",tags=_[115]}
|
||||
_[79]={data="ab",tags=_[114]}
|
||||
_[78]={data="aa",tags=_[113]}
|
||||
_[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]}
|
||||
_[51]={_[84],_[85],_[86]}
|
||||
_[50]={_[83]}
|
||||
_[49]={_[81],_[82]}
|
||||
_[48]={_[80]}
|
||||
_[47]={_[78],_[79]}
|
||||
_[46]={_[77]}
|
||||
_[45]={_[74],_[75],_[76]}
|
||||
_[44]={_[73]}
|
||||
_[43]={_[72]}
|
||||
_[42]={_[71]}
|
||||
_[41]={_[70]}
|
||||
_[40]={_[68],_[69]}
|
||||
_[39]={_[67]}
|
||||
_[38]={_[66]}
|
||||
_[37]={_[65]}
|
||||
_[36]={_[64]}
|
||||
_[35]={_[62],_[63]}
|
||||
_[34]={_[61]}
|
||||
_[33]={_[60]}
|
||||
_[32]={_[59]}
|
||||
_[31]={_[57],_[58]}
|
||||
_[30]={_[56]}
|
||||
_[29]={_[55]}
|
||||
_[28]={_[54]}
|
||||
_[27]={_[52],_[53]}
|
||||
_[26]={"error","invalid choice"}
|
||||
_[25]={"choice",_[51]}
|
||||
_[24]={"text",_[50]}
|
||||
_[23]={"choice",_[49]}
|
||||
_[22]={"text",_[48]}
|
||||
_[21]={"choice",_[47]}
|
||||
_[20]={"text",_[46]}
|
||||
_[19]={"choice",_[45]}
|
||||
_[18]={"text",_[44]}
|
||||
_[17]={"choice",_[43]}
|
||||
_[16]={"text",_[42]}
|
||||
_[15]={"text",_[41]}
|
||||
_[14]={"choice",_[40]}
|
||||
_[13]={"text",_[39]}
|
||||
_[12]={"choice",_[38]}
|
||||
_[11]={"text",_[37]}
|
||||
_[10]={"text",_[36]}
|
||||
_[9]={"choice",_[35]}
|
||||
_[8]={"text",_[34]}
|
||||
_[7]={"choice",_[33]}
|
||||
_[6]={"text",_[32]}
|
||||
_[5]={"choice",_[31]}
|
||||
_[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]}
|
||||
--[[
|
||||
{ "choice", { {
|
||||
data = "a",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "b",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "-> b",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "choice", { {
|
||||
data = "c",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "-> c",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "choice", { {
|
||||
data = "aa",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "ab",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "-> ab",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "choice", { {
|
||||
data = "c",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "-> c",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "choice", { {
|
||||
data = "a",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "b",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "-> b",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "autoflush",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "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 = {}
|
||||
}, {
|
||||
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" }
|
||||
]]--
|
||||
21
test/tests/resume from paragraph with nested condition.ans
Normal file
21
test/tests/resume from paragraph with nested condition.ans
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
$ f
|
||||
~ 1
|
||||
§ p
|
||||
x
|
||||
~~
|
||||
y
|
||||
|
||||
~ f
|
||||
|
||||
~ f.p
|
||||
|
||||
$ g
|
||||
~ 0
|
||||
§ p
|
||||
x
|
||||
~~
|
||||
y
|
||||
|
||||
~ g
|
||||
|
||||
~ g.p
|
||||
38
test/tests/resume from paragraph with nested condition.lua
Normal file
38
test/tests/resume from paragraph with nested condition.lua
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
local _={}
|
||||
_[17]={}
|
||||
_[16]={}
|
||||
_[15]={}
|
||||
_[14]={}
|
||||
_[13]={data="x",tags=_[17]}
|
||||
_[12]={data="y",tags=_[16]}
|
||||
_[11]={data="x",tags=_[15]}
|
||||
_[10]={data="x",tags=_[14]}
|
||||
_[9]={_[13]}
|
||||
_[8]={_[12]}
|
||||
_[7]={_[11]}
|
||||
_[6]={_[10]}
|
||||
_[5]={"return"}
|
||||
_[4]={"text",_[9]}
|
||||
_[3]={"text",_[8]}
|
||||
_[2]={"text",_[7]}
|
||||
_[1]={"text",_[6]}
|
||||
return {_[1],_[2],_[3],_[4],_[5]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "x",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "x",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "y",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "x",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
local _={}
|
||||
_[6]={1}
|
||||
_[5]={tags=_[6],data="bar"}
|
||||
_[4]={tags=_[6],data="foo"}
|
||||
_[5]={data="bar",tags=_[6]}
|
||||
_[4]={data="foo",tags=_[6]}
|
||||
_[3]={_[4],_[5]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ local _={}
|
|||
_[8]={2,3}
|
||||
_[7]={1,a=_[8]}
|
||||
_[6]={1}
|
||||
_[5]={tags=_[7],data="bar"}
|
||||
_[4]={tags=_[6],data="foo"}
|
||||
_[5]={data="bar",tags=_[7]}
|
||||
_[4]={data="foo",tags=_[6]}
|
||||
_[3]={_[4],_[5]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ local _={}
|
|||
_[8]={2,3}
|
||||
_[7]={1,a=_[8]}
|
||||
_[6]={1}
|
||||
_[5]={tags=_[7],data="bar"}
|
||||
_[4]={tags=_[6],data="foo"}
|
||||
_[5]={data="bar",tags=_[7]}
|
||||
_[4]={data="foo",tags=_[6]}
|
||||
_[3]={_[4],_[5]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
local _={}
|
||||
_[6]={1}
|
||||
_[5]={tags=_[6],data="bar"}
|
||||
_[4]={tags=_[6],data="foo"}
|
||||
_[5]={data="bar",tags=_[6]}
|
||||
_[4]={data="foo",tags=_[6]}
|
||||
_[3]={_[4],_[5]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ local _={}
|
|||
_[8]={2,3}
|
||||
_[7]={1,a=_[8]}
|
||||
_[6]={1}
|
||||
_[5]={tags=_[7],data="bar"}
|
||||
_[4]={tags=_[6],data="foo"}
|
||||
_[5]={data="bar",tags=_[7]}
|
||||
_[4]={data="foo",tags=_[6]}
|
||||
_[3]={_[4],_[5]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
local _={}
|
||||
_[7]={}
|
||||
_[6]={}
|
||||
_[5]={tags=_[7],data="b c"}
|
||||
_[4]={tags=_[6],data="a"}
|
||||
_[5]={data="b c",tags=_[7]}
|
||||
_[4]={data="a",tags=_[6]}
|
||||
_[3]={_[4],_[5]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
local _={}
|
||||
_[9]={}
|
||||
_[8]={}
|
||||
_[7]={tags=_[9],data="b c"}
|
||||
_[6]={tags=_[8],data="a"}
|
||||
_[7]={data="b c",tags=_[9]}
|
||||
_[6]={data="a",tags=_[8]}
|
||||
_[5]={_[7]}
|
||||
_[4]={_[6]}
|
||||
_[3]={"return"}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={tags=_[5],data="a: 5"}
|
||||
_[4]={data="a: 5",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={tags=_[5],data="a"}
|
||||
_[4]={data="a",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ _[12]={}
|
|||
_[11]={}
|
||||
_[10]={}
|
||||
_[9]={}
|
||||
_[8]={tags=_[13],data="b"}
|
||||
_[7]={tags=_[12],data="a"}
|
||||
_[6]={tags=_[11],data="b"}
|
||||
_[5]={tags=_[10],data="seen only once"}
|
||||
_[4]={tags=_[9],data="a"}
|
||||
_[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]}
|
||||
_[3]={_[4],_[5],_[6],_[7],_[8]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue