mirror of
https://github.com/Reuh/anselme.git
synced 2025-12-14 04:09:08 +00:00
Rewrite
This commit is contained in:
parent
7a5a05ff34
commit
b233d7fa1e
138 changed files with 4369 additions and 1611 deletions
334
test/inspect.lua
Normal file
334
test/inspect.lua
Normal file
|
|
@ -0,0 +1,334 @@
|
|||
local inspect ={
|
||||
_VERSION = 'inspect.lua 3.1.0',
|
||||
_URL = 'http://github.com/kikito/inspect.lua',
|
||||
_DESCRIPTION = 'human-readable representations of tables',
|
||||
_LICENSE = [[
|
||||
MIT LICENSE
|
||||
|
||||
Copyright (c) 2013 Enrique García Cota
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
]]
|
||||
}
|
||||
|
||||
local tostring = tostring
|
||||
|
||||
inspect.KEY = setmetatable({}, {__tostring = function() return 'inspect.KEY' end})
|
||||
inspect.METATABLE = setmetatable({}, {__tostring = function() return 'inspect.METATABLE' end})
|
||||
|
||||
local function rawpairs(t)
|
||||
return next, t, nil
|
||||
end
|
||||
|
||||
-- Apostrophizes the string if it has quotes, but not aphostrophes
|
||||
-- Otherwise, it returns a regular quoted string
|
||||
local function smartQuote(str)
|
||||
if str:match('"') and not str:match("'") then
|
||||
return "'" .. str .. "'"
|
||||
end
|
||||
return '"' .. str:gsub('"', '\\"') .. '"'
|
||||
end
|
||||
|
||||
-- \a => '\\a', \0 => '\\0', 31 => '\31'
|
||||
local shortControlCharEscapes = {
|
||||
["\a"] = "\\a", ["\b"] = "\\b", ["\f"] = "\\f", ["\n"] = "\\n",
|
||||
["\r"] = "\\r", ["\t"] = "\\t", ["\v"] = "\\v"
|
||||
}
|
||||
local longControlCharEscapes = {} -- \a => nil, \0 => \000, 31 => \031
|
||||
for i=0, 31 do
|
||||
local ch = string.char(i)
|
||||
if not shortControlCharEscapes[ch] then
|
||||
shortControlCharEscapes[ch] = "\\"..i
|
||||
longControlCharEscapes[ch] = string.format("\\%03d", i)
|
||||
end
|
||||
end
|
||||
|
||||
local function escape(str)
|
||||
return (str:gsub("\\", "\\\\")
|
||||
:gsub("(%c)%f[0-9]", longControlCharEscapes)
|
||||
:gsub("%c", shortControlCharEscapes))
|
||||
end
|
||||
|
||||
local function isIdentifier(str)
|
||||
return type(str) == 'string' and str:match( "^[_%a][_%a%d]*$" )
|
||||
end
|
||||
|
||||
local function isSequenceKey(k, sequenceLength)
|
||||
return type(k) == 'number'
|
||||
and 1 <= k
|
||||
and k <= sequenceLength
|
||||
and math.floor(k) == k
|
||||
end
|
||||
|
||||
local defaultTypeOrders = {
|
||||
['number'] = 1, ['boolean'] = 2, ['string'] = 3, ['table'] = 4,
|
||||
['function'] = 5, ['userdata'] = 6, ['thread'] = 7
|
||||
}
|
||||
|
||||
local function sortKeys(a, b)
|
||||
local ta, tb = type(a), type(b)
|
||||
|
||||
-- strings and numbers are sorted numerically/alphabetically
|
||||
if ta == tb and (ta == 'string' or ta == 'number') then return a < b end
|
||||
|
||||
local dta, dtb = defaultTypeOrders[ta], defaultTypeOrders[tb]
|
||||
-- Two default types are compared according to the defaultTypeOrders table
|
||||
if dta and dtb then return defaultTypeOrders[ta] < defaultTypeOrders[tb]
|
||||
elseif dta then return true -- default types before custom ones
|
||||
elseif dtb then return false -- custom types after default ones
|
||||
end
|
||||
|
||||
-- custom types are sorted out alphabetically
|
||||
return ta < tb
|
||||
end
|
||||
|
||||
-- For implementation reasons, the behavior of rawlen & # is "undefined" when
|
||||
-- tables aren't pure sequences. So we implement our own # operator.
|
||||
local function getSequenceLength(t)
|
||||
local len = 1
|
||||
local v = rawget(t,len)
|
||||
while v ~= nil do
|
||||
len = len + 1
|
||||
v = rawget(t,len)
|
||||
end
|
||||
return len - 1
|
||||
end
|
||||
|
||||
local function getNonSequentialKeys(t)
|
||||
local keys, keysLength = {}, 0
|
||||
local sequenceLength = getSequenceLength(t)
|
||||
for k,_ in rawpairs(t) do
|
||||
if not isSequenceKey(k, sequenceLength) then
|
||||
keysLength = keysLength + 1
|
||||
keys[keysLength] = k
|
||||
end
|
||||
end
|
||||
table.sort(keys, sortKeys)
|
||||
return keys, keysLength, sequenceLength
|
||||
end
|
||||
|
||||
local function countTableAppearances(t, tableAppearances)
|
||||
tableAppearances = tableAppearances or {}
|
||||
|
||||
if type(t) == 'table' then
|
||||
if not tableAppearances[t] then
|
||||
tableAppearances[t] = 1
|
||||
for k,v in rawpairs(t) do
|
||||
countTableAppearances(k, tableAppearances)
|
||||
countTableAppearances(v, tableAppearances)
|
||||
end
|
||||
countTableAppearances(getmetatable(t), tableAppearances)
|
||||
else
|
||||
tableAppearances[t] = tableAppearances[t] + 1
|
||||
end
|
||||
end
|
||||
|
||||
return tableAppearances
|
||||
end
|
||||
|
||||
local copySequence = function(s)
|
||||
local copy, len = {}, #s
|
||||
for i=1, len do copy[i] = s[i] end
|
||||
return copy, len
|
||||
end
|
||||
|
||||
local function makePath(path, ...)
|
||||
local keys = {...}
|
||||
local newPath, len = copySequence(path)
|
||||
for i=1, #keys do
|
||||
newPath[len + i] = keys[i]
|
||||
end
|
||||
return newPath
|
||||
end
|
||||
|
||||
local function processRecursive(process, item, path, visited)
|
||||
if item == nil then return nil end
|
||||
if visited[item] then return visited[item] end
|
||||
|
||||
local processed = process(item, path)
|
||||
if type(processed) == 'table' then
|
||||
local processedCopy = {}
|
||||
visited[item] = processedCopy
|
||||
local processedKey
|
||||
|
||||
for k,v in rawpairs(processed) do
|
||||
processedKey = processRecursive(process, k, makePath(path, k, inspect.KEY), visited)
|
||||
if processedKey ~= nil then
|
||||
processedCopy[processedKey] = processRecursive(process, v, makePath(path, processedKey), visited)
|
||||
end
|
||||
end
|
||||
|
||||
local mt = processRecursive(process, getmetatable(processed), makePath(path, inspect.METATABLE), visited)
|
||||
if type(mt) ~= 'table' then mt = nil end -- ignore not nil/table __metatable field
|
||||
setmetatable(processedCopy, mt)
|
||||
processed = processedCopy
|
||||
end
|
||||
return processed
|
||||
end
|
||||
|
||||
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
||||
local Inspector = {}
|
||||
local Inspector_mt = {__index = Inspector}
|
||||
|
||||
function Inspector:puts(...)
|
||||
local args = {...}
|
||||
local buffer = self.buffer
|
||||
local len = #buffer
|
||||
for i=1, #args do
|
||||
len = len + 1
|
||||
buffer[len] = args[i]
|
||||
end
|
||||
end
|
||||
|
||||
function Inspector:down(f)
|
||||
self.level = self.level + 1
|
||||
f()
|
||||
self.level = self.level - 1
|
||||
end
|
||||
|
||||
function Inspector:tabify()
|
||||
self:puts(self.newline, string.rep(self.indent, self.level))
|
||||
end
|
||||
|
||||
function Inspector:alreadyVisited(v)
|
||||
return self.ids[v] ~= nil
|
||||
end
|
||||
|
||||
function Inspector:getId(v)
|
||||
local id = self.ids[v]
|
||||
if not id then
|
||||
local tv = type(v)
|
||||
id = (self.maxIds[tv] or 0) + 1
|
||||
self.maxIds[tv] = id
|
||||
self.ids[v] = id
|
||||
end
|
||||
return tostring(id)
|
||||
end
|
||||
|
||||
function Inspector:putKey(k)
|
||||
if isIdentifier(k) then return self:puts(k) end
|
||||
self:puts("[")
|
||||
self:putValue(k)
|
||||
self:puts("]")
|
||||
end
|
||||
|
||||
function Inspector:putTable(t)
|
||||
if t == inspect.KEY or t == inspect.METATABLE then
|
||||
self:puts(tostring(t))
|
||||
elseif self:alreadyVisited(t) then
|
||||
self:puts('<table ', self:getId(t), '>')
|
||||
elseif self.level >= self.depth then
|
||||
self:puts('{...}')
|
||||
else
|
||||
if self.tableAppearances[t] > 1 then self:puts('<', self:getId(t), '>') end
|
||||
|
||||
local nonSequentialKeys, nonSequentialKeysLength, sequenceLength = getNonSequentialKeys(t)
|
||||
local mt = getmetatable(t)
|
||||
|
||||
self:puts('{')
|
||||
self:down(function()
|
||||
local count = 0
|
||||
for i=1, sequenceLength do
|
||||
if count > 0 then self:puts(',') end
|
||||
self:puts(' ')
|
||||
self:putValue(t[i])
|
||||
count = count + 1
|
||||
end
|
||||
|
||||
for i=1, nonSequentialKeysLength do
|
||||
local k = nonSequentialKeys[i]
|
||||
if count > 0 then self:puts(',') end
|
||||
self:tabify()
|
||||
self:putKey(k)
|
||||
self:puts(' = ')
|
||||
self:putValue(t[k])
|
||||
count = count + 1
|
||||
end
|
||||
|
||||
if type(mt) == 'table' then
|
||||
if count > 0 then self:puts(',') end
|
||||
self:tabify()
|
||||
self:puts('<metatable> = ')
|
||||
self:putValue(mt)
|
||||
end
|
||||
end)
|
||||
|
||||
if nonSequentialKeysLength > 0 or type(mt) == 'table' then -- result is multi-lined. Justify closing }
|
||||
self:tabify()
|
||||
elseif sequenceLength > 0 then -- array tables have one extra space before closing }
|
||||
self:puts(' ')
|
||||
end
|
||||
|
||||
self:puts('}')
|
||||
end
|
||||
end
|
||||
|
||||
function Inspector:putValue(v)
|
||||
local tv = type(v)
|
||||
|
||||
if tv == 'string' then
|
||||
self:puts(smartQuote(escape(v)))
|
||||
elseif tv == 'number' or tv == 'boolean' or tv == 'nil' or
|
||||
tv == 'cdata' or tv == 'ctype' then
|
||||
self:puts(tostring(v))
|
||||
elseif tv == 'table' then
|
||||
self:putTable(v)
|
||||
else
|
||||
self:puts('<', tv, ' ', self:getId(v), '>')
|
||||
end
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
||||
function inspect.inspect(root, options)
|
||||
options = options or {}
|
||||
|
||||
local depth = options.depth or math.huge
|
||||
local newline = options.newline or '\n'
|
||||
local indent = options.indent or ' '
|
||||
local process = options.process
|
||||
|
||||
if process then
|
||||
root = processRecursive(process, root, {}, {})
|
||||
end
|
||||
|
||||
local inspector = setmetatable({
|
||||
depth = depth,
|
||||
level = 0,
|
||||
buffer = {},
|
||||
ids = {},
|
||||
maxIds = {},
|
||||
newline = newline,
|
||||
indent = indent,
|
||||
tableAppearances = countTableAppearances(root)
|
||||
}, Inspector_mt)
|
||||
|
||||
inspector:putValue(root)
|
||||
|
||||
return table.concat(inspector.buffer)
|
||||
end
|
||||
|
||||
setmetatable(inspect, { __call = function(_, ...) return inspect.inspect(...) end })
|
||||
|
||||
return inspect
|
||||
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
LOOL
|
||||
|
||||
~ test yep
|
||||
204
test/run.lua
Normal file
204
test/run.lua
Normal file
|
|
@ -0,0 +1,204 @@
|
|||
local lfs = require("lfs")
|
||||
local anselme = require("anselme")
|
||||
local ser = require("test.ser")
|
||||
local inspect = require("test.inspect")
|
||||
|
||||
local function format_text(t, prefix)
|
||||
prefix = prefix or " "
|
||||
local r = ""
|
||||
for _, l in ipairs(t) do
|
||||
r = r .. prefix
|
||||
local tags = ""
|
||||
for k, v in ipairs(l.tags) do
|
||||
tags = tags .. ("[%q]=%q"):format(k, v)
|
||||
end
|
||||
if tags ~= "" then
|
||||
r = r .. ("[%s]%s"):format(tags, l.data)
|
||||
else
|
||||
r = r .. l.data
|
||||
end
|
||||
end
|
||||
return r
|
||||
end
|
||||
|
||||
local function compare(a, b)
|
||||
if type(a) == "table" and type(b) == "table" then
|
||||
for k, v in pairs(a) do
|
||||
if not compare(v, b[k]) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
for k, v in pairs(b) do
|
||||
if not compare(v, a[k]) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
else
|
||||
return a == b
|
||||
end
|
||||
end
|
||||
|
||||
-- parse args
|
||||
local args = {}
|
||||
local i=1
|
||||
while i <= #arg do
|
||||
if arg[i+1] and not arg[i+1]:match("^%-%-") then
|
||||
args[arg[i]:gsub("^%-%-", "")] = arg[i+1]
|
||||
i = i + 2
|
||||
else
|
||||
args[arg[i]:gsub("^%-%-", "")] = true
|
||||
i = i + 1
|
||||
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
|
||||
end
|
||||
table.sort(files)
|
||||
|
||||
-- test script
|
||||
if args.script then
|
||||
local vm = anselme()
|
||||
local state, err = vm:loadfile("test.ans", "test")
|
||||
if state then
|
||||
local istate, e = vm:run("test")
|
||||
if not istate then
|
||||
print("error", e)
|
||||
else
|
||||
repeat
|
||||
local t, d = istate:step()
|
||||
if t == "text" then
|
||||
print(format_text(d))
|
||||
elseif t == "choice" then
|
||||
print(format_text(d, "\n> "))
|
||||
istate:choose(io.read())
|
||||
else
|
||||
print(t, inspect(d))
|
||||
end
|
||||
until t == "return" or t == "error"
|
||||
end
|
||||
else
|
||||
print("error", err)
|
||||
end
|
||||
-- run tests
|
||||
else
|
||||
local total, success = #files, 0
|
||||
for _, file in ipairs(files) do
|
||||
local filebase = file:match("^(.*)%.ans$")
|
||||
local namespace = filebase:match("([^/]*)$")
|
||||
math.randomseed(0)
|
||||
local vm = anselme()
|
||||
vm:loadalias {
|
||||
seen = "👁️",
|
||||
checkpoint = "🏁"
|
||||
}
|
||||
vm:loadfunction {
|
||||
-- custom event test
|
||||
["wait"] = {
|
||||
{
|
||||
arity = 1, types = { "number" },
|
||||
value = function(duration)
|
||||
coroutine.yield("wait", duration)
|
||||
end
|
||||
}
|
||||
},
|
||||
-- run another function in parallel
|
||||
["run"] = {
|
||||
{
|
||||
arity = 1, types = { "string" },
|
||||
value = function(str)
|
||||
local istate, e = anselme.running.vm:run(str, anselme.running:current_namespace())
|
||||
if not istate then coroutine.yield("error", e) end
|
||||
local event, data = istate:step()
|
||||
coroutine.yield(event, data)
|
||||
end
|
||||
}
|
||||
},
|
||||
-- manual choice
|
||||
choose = {
|
||||
{
|
||||
arity = 1, types = { "number" },
|
||||
value = function(c)
|
||||
anselme.running:choose(c)
|
||||
end
|
||||
}
|
||||
},
|
||||
-- manual interrupt
|
||||
interrupt = {
|
||||
{
|
||||
arity = 1, types = { "string" },
|
||||
value = function(str)
|
||||
anselme.running:interrupt(str)
|
||||
coroutine.yield("wait", 0)
|
||||
end
|
||||
},
|
||||
{
|
||||
arity = 0,
|
||||
value = function()
|
||||
anselme.running:interrupt()
|
||||
coroutine.yield("wait", 0)
|
||||
end
|
||||
}
|
||||
}
|
||||
}
|
||||
local state, err = vm:loadfile(file, namespace)
|
||||
|
||||
local result = {}
|
||||
if state then
|
||||
local istate, e = vm:run(namespace)
|
||||
if not istate then
|
||||
table.insert(result, { "error", e })
|
||||
else
|
||||
repeat
|
||||
local t, d = istate:step()
|
||||
table.insert(result, { t, d })
|
||||
until t == "return" or t == "error"
|
||||
end
|
||||
else
|
||||
table.insert(result, { "error", err })
|
||||
end
|
||||
|
||||
if args.write then
|
||||
local o = assert(io.open(filebase..".lua", "w"))
|
||||
o:write(ser(result))
|
||||
o:write("\n--[[\n")
|
||||
for _, v in ipairs(result) do
|
||||
o:write(inspect(v).."\n")
|
||||
end
|
||||
o:write("]]--")
|
||||
o:close()
|
||||
else
|
||||
local o, e = loadfile(filebase..".lua")
|
||||
if o then
|
||||
local output = o()
|
||||
if not compare(result, output) then
|
||||
if not args.silent then
|
||||
print("> "..namespace)
|
||||
print(inspect(result))
|
||||
print("is not equal to")
|
||||
print(inspect(output))
|
||||
end
|
||||
else
|
||||
success = success + 1
|
||||
end
|
||||
else
|
||||
if not args.silent then
|
||||
print("> "..namespace)
|
||||
print(e)
|
||||
print("result was:")
|
||||
print(inspect(result))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if args.write then
|
||||
print("Wrote test results.")
|
||||
else
|
||||
print(("%s/%s tests success."):format(success, total))
|
||||
end
|
||||
end
|
||||
143
test/ser.lua
Normal file
143
test/ser.lua
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
--[[
|
||||
Copyright (c) 2011,2013 Robin Wellner
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
]]
|
||||
|
||||
local pairs, ipairs, tostring, type, concat, dump, floor, format = pairs, ipairs, tostring, type, table.concat, string.dump, math.floor, string.format
|
||||
|
||||
local function getchr(c)
|
||||
return "\\" .. c:byte()
|
||||
end
|
||||
|
||||
local function make_safe(text)
|
||||
return ("%q"):format(text):gsub('\n', 'n'):gsub("[\128-\255]", getchr)
|
||||
end
|
||||
|
||||
local oddvals = {[tostring(1/0)] = '1/0', [tostring(-1/0)] = '-1/0', [tostring(-(0/0))] = '-(0/0)', [tostring(0/0)] = '0/0'}
|
||||
local function write(t, memo, rev_memo)
|
||||
local ty = type(t)
|
||||
if ty == 'number' then
|
||||
t = format("%.17g", t)
|
||||
return oddvals[t] or t
|
||||
elseif ty == 'boolean' or ty == 'nil' then
|
||||
return tostring(t)
|
||||
elseif ty == 'string' then
|
||||
return make_safe(t)
|
||||
elseif ty == 'table' or ty == 'function' then
|
||||
if not memo[t] then
|
||||
local index = #rev_memo + 1
|
||||
memo[t] = index
|
||||
rev_memo[index] = t
|
||||
end
|
||||
return '_[' .. memo[t] .. ']'
|
||||
else
|
||||
error("Trying to serialize unsupported type " .. ty)
|
||||
end
|
||||
end
|
||||
|
||||
local kw = {['and'] = true, ['break'] = true, ['do'] = true, ['else'] = true,
|
||||
['elseif'] = true, ['end'] = true, ['false'] = true, ['for'] = true,
|
||||
['function'] = true, ['goto'] = true, ['if'] = true, ['in'] = true,
|
||||
['local'] = true, ['nil'] = true, ['not'] = true, ['or'] = true,
|
||||
['repeat'] = true, ['return'] = true, ['then'] = true, ['true'] = true,
|
||||
['until'] = true, ['while'] = true}
|
||||
local function write_key_value_pair(k, v, memo, rev_memo, name)
|
||||
if type(k) == 'string' and k:match '^[_%a][_%w]*$' and not kw[k] then
|
||||
return (name and name .. '.' or '') .. k ..'=' .. write(v, memo, rev_memo)
|
||||
else
|
||||
return (name or '') .. '[' .. write(k, memo, rev_memo) .. ']=' .. write(v, memo, rev_memo)
|
||||
end
|
||||
end
|
||||
|
||||
-- fun fact: this function is not perfect
|
||||
-- it has a few false positives sometimes
|
||||
-- but no false negatives, so that's good
|
||||
local function is_cyclic(memo, sub, super)
|
||||
local m = memo[sub]
|
||||
local p = memo[super]
|
||||
return m and p and m < p
|
||||
end
|
||||
|
||||
local function write_table_ex(t, memo, rev_memo, srefs, name)
|
||||
if type(t) == 'function' then
|
||||
return '_[' .. name .. ']=loadstring' .. make_safe(dump(t))
|
||||
end
|
||||
local m = {}
|
||||
local mi = 1
|
||||
for i = 1, #t do -- don't use ipairs here, we need the gaps
|
||||
local v = t[i]
|
||||
if v == t or is_cyclic(memo, v, t) then
|
||||
srefs[#srefs + 1] = {name, i, v}
|
||||
m[mi] = 'nil'
|
||||
mi = mi + 1
|
||||
else
|
||||
m[mi] = write(v, memo, rev_memo)
|
||||
mi = mi + 1
|
||||
end
|
||||
end
|
||||
for k,v in pairs(t) do
|
||||
if type(k) ~= 'number' or floor(k) ~= k or k < 1 or k > #t then
|
||||
if v == t or k == t or is_cyclic(memo, v, t) or is_cyclic(memo, k, t) then
|
||||
srefs[#srefs + 1] = {name, k, v}
|
||||
else
|
||||
m[mi] = write_key_value_pair(k, v, memo, rev_memo)
|
||||
mi = mi + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
return '_[' .. name .. ']={' .. concat(m, ',') .. '}'
|
||||
end
|
||||
|
||||
return function(t)
|
||||
local memo = {[t] = 0}
|
||||
local rev_memo = {[0] = t}
|
||||
local srefs = {}
|
||||
local result = {}
|
||||
|
||||
-- phase 1: recursively descend the table structure
|
||||
local n = 0
|
||||
while rev_memo[n] do
|
||||
result[n + 1] = write_table_ex(rev_memo[n], memo, rev_memo, srefs, n)
|
||||
n = n + 1
|
||||
end
|
||||
|
||||
-- phase 2: reverse order
|
||||
for i = 1, n*.5 do
|
||||
local j = n - i + 1
|
||||
result[i], result[j] = result[j], result[i]
|
||||
end
|
||||
|
||||
-- phase 3: add all the tricky cyclic stuff
|
||||
for i, v in ipairs(srefs) do
|
||||
n = n + 1
|
||||
result[n] = write_key_value_pair(v[2], v[3], memo, rev_memo, '_[' .. v[1] .. ']')
|
||||
end
|
||||
|
||||
-- phase 4: add something about returning the main table
|
||||
if result[n]:sub(1, 5) == '_[0]=' then
|
||||
result[n] = 'return ' .. result[n]:sub(6)
|
||||
else
|
||||
result[n + 1] = 'return _[0]'
|
||||
end
|
||||
|
||||
-- phase 5: just concatenate everything
|
||||
result = concat(result, '\n')
|
||||
return n > 1 and 'local _={}\n' .. result or result
|
||||
end
|
||||
11
test/tests/choice block.ans
Normal file
11
test/tests/choice block.ans
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
> ye
|
||||
no
|
||||
> ne
|
||||
ok
|
||||
~ choose(2)
|
||||
|
||||
> ho
|
||||
plop
|
||||
> oh
|
||||
plup
|
||||
~ choose(1)
|
||||
48
test/tests/choice block.lua
Normal file
48
test/tests/choice block.lua
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
local _={}
|
||||
_[21]={}
|
||||
_[20]={}
|
||||
_[19]={}
|
||||
_[18]={}
|
||||
_[17]={}
|
||||
_[16]={}
|
||||
_[15]={data="plop",tags=_[21]}
|
||||
_[14]={data="oh",tags=_[20]}
|
||||
_[13]={data="ho",tags=_[19]}
|
||||
_[12]={data="ok",tags=_[18]}
|
||||
_[11]={data="ne",tags=_[17]}
|
||||
_[10]={data="ye",tags=_[16]}
|
||||
_[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", { {
|
||||
data = "ye",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "ne",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "ok",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "choice", { {
|
||||
data = "ho",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "oh",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "plop",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
11
test/tests/choice function.ans
Normal file
11
test/tests/choice function.ans
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
$ f
|
||||
> neol
|
||||
nah
|
||||
|
||||
> ho
|
||||
plop
|
||||
~ f
|
||||
> oh
|
||||
ok
|
||||
~ f
|
||||
~ choose(3)
|
||||
37
test/tests/choice function.lua
Normal file
37
test/tests/choice function.lua
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
local _={}
|
||||
_[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]}
|
||||
_[5]={_[10]}
|
||||
_[4]={_[6],_[7],_[8],_[9]}
|
||||
_[3]={"return"}
|
||||
_[2]={"text",_[5]}
|
||||
_[1]={"choice",_[4]}
|
||||
return {_[1],_[2],_[3]}
|
||||
--[[
|
||||
{ "choice", { {
|
||||
data = "ho",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "neol",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "oh",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "neol",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "ok",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
5
test/tests/choice simple.ans
Normal file
5
test/tests/choice simple.ans
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
> ye
|
||||
no
|
||||
> ne
|
||||
ok
|
||||
~ choose(2)
|
||||
27
test/tests/choice simple.lua
Normal file
27
test/tests/choice simple.lua
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
local _={}
|
||||
_[11]={}
|
||||
_[10]={}
|
||||
_[9]={}
|
||||
_[8]={data="ok",tags=_[11]}
|
||||
_[7]={data="ne",tags=_[10]}
|
||||
_[6]={data="ye",tags=_[9]}
|
||||
_[5]={_[8]}
|
||||
_[4]={_[6],_[7]}
|
||||
_[3]={"return"}
|
||||
_[2]={"text",_[5]}
|
||||
_[1]={"choice",_[4]}
|
||||
return {_[1],_[2],_[3]}
|
||||
--[[
|
||||
{ "choice", { {
|
||||
data = "ye",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "ne",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "ok",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
7
test/tests/comment block.ans
Normal file
7
test/tests/comment block.ans
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
(hey couic + 5)
|
||||
other stuff
|
||||
|
||||
CHAZOUM
|
||||
OO
|
||||
|
||||
k
|
||||
6
test/tests/comment block.lua
Normal file
6
test/tests/comment block.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
local _={}
|
||||
_[1]={"return"}
|
||||
return {_[1]}
|
||||
--[[
|
||||
{ "return" }
|
||||
]]--
|
||||
1
test/tests/comment.ans
Normal file
1
test/tests/comment.ans
Normal file
|
|
@ -0,0 +1 @@
|
|||
(hey couic + 5)
|
||||
6
test/tests/comment.lua
Normal file
6
test/tests/comment.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
local _={}
|
||||
_[1]={"return"}
|
||||
return {_[1]}
|
||||
--[[
|
||||
{ "return" }
|
||||
]]--
|
||||
20
test/tests/commit.ans
Normal file
20
test/tests/commit.ans
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
$ bar
|
||||
:5 var
|
||||
|
||||
~ var := 2
|
||||
|
||||
before: {var}
|
||||
|
||||
~ run("parallel")
|
||||
|
||||
§ foo
|
||||
checkpoint
|
||||
|
||||
after: {var}
|
||||
|
||||
~ run("parallel")
|
||||
|
||||
$ parallel
|
||||
parallel: {bar.var}
|
||||
|
||||
~ bar
|
||||
38
test/tests/commit.lua
Normal file
38
test/tests/commit.lua
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
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]}
|
||||
_[5]={"return"}
|
||||
_[4]={"text",_[9]}
|
||||
_[3]={"text",_[8]}
|
||||
_[2]={"text",_[7]}
|
||||
_[1]={"text",_[6]}
|
||||
return {_[1],_[2],_[3],_[4],_[5]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "before: 2",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "parallel: 5",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "after: 2",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "parallel: 2",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
3
test/tests/condition decorator.ans
Normal file
3
test/tests/condition decorator.ans
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
ko ~ 0
|
||||
ok ~ 1
|
||||
ok bis ~
|
||||
19
test/tests/condition decorator.lua
Normal file
19
test/tests/condition decorator.lua
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
local _={}
|
||||
_[7]={}
|
||||
_[6]={}
|
||||
_[5]={data="ok bis",tags=_[7]}
|
||||
_[4]={data="ok",tags=_[6]}
|
||||
_[3]={_[4],_[5]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "ok",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "ok bis",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
6
test/tests/condition else false.ans
Normal file
6
test/tests/condition else false.ans
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
:5 a
|
||||
|
||||
~ a = 2
|
||||
ko
|
||||
~~
|
||||
ok
|
||||
14
test/tests/condition else false.lua
Normal file
14
test/tests/condition else false.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={data="ok",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "ok",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
6
test/tests/condition else true.ans
Normal file
6
test/tests/condition else true.ans
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
:5 a
|
||||
|
||||
~ a = 5
|
||||
ok
|
||||
~~
|
||||
ko
|
||||
14
test/tests/condition else true.lua
Normal file
14
test/tests/condition else true.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={data="ok",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "ok",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
8
test/tests/condition elseif false.ans
Normal file
8
test/tests/condition elseif false.ans
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
:5 a
|
||||
|
||||
~ a = 2
|
||||
ko
|
||||
~~ 0
|
||||
ko
|
||||
~~
|
||||
ok
|
||||
14
test/tests/condition elseif false.lua
Normal file
14
test/tests/condition elseif false.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={data="ok",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "ok",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
8
test/tests/condition elseif true.ans
Normal file
8
test/tests/condition elseif true.ans
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
:5 a
|
||||
|
||||
~ a = 2
|
||||
ko
|
||||
~~ 1
|
||||
ok
|
||||
~~
|
||||
ko
|
||||
14
test/tests/condition elseif true.lua
Normal file
14
test/tests/condition elseif true.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={data="ok",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "ok",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
4
test/tests/condition false.ans
Normal file
4
test/tests/condition false.ans
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
:5 a
|
||||
|
||||
~ a = 2
|
||||
ko
|
||||
6
test/tests/condition false.lua
Normal file
6
test/tests/condition false.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
local _={}
|
||||
_[1]={"return"}
|
||||
return {_[1]}
|
||||
--[[
|
||||
{ "return" }
|
||||
]]--
|
||||
4
test/tests/condition true.ans
Normal file
4
test/tests/condition true.ans
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
:5 a
|
||||
|
||||
~ a = 5
|
||||
ok
|
||||
14
test/tests/condition true.lua
Normal file
14
test/tests/condition true.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={data="ok",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "ok",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
3
test/tests/custom event.ans
Normal file
3
test/tests/custom event.ans
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
ah
|
||||
~ wait(5)
|
||||
ho
|
||||
21
test/tests/custom event.lua
Normal file
21
test/tests/custom event.lua
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
local _={}
|
||||
_[8]={}
|
||||
_[7]={}
|
||||
_[6]={data="ho",tags=_[8]}
|
||||
_[5]={data="ah",tags=_[7]}
|
||||
_[4]={_[5],_[6]}
|
||||
_[3]={"return"}
|
||||
_[2]={"text",_[4]}
|
||||
_[1]={"wait",5}
|
||||
return {_[1],_[2],_[3]}
|
||||
--[[
|
||||
{ "wait", 5 }
|
||||
{ "text", { {
|
||||
data = "ah",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "ho",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
3
test/tests/define override function.ans
Normal file
3
test/tests/define override function.ans
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
$ a
|
||||
|
||||
:2 a
|
||||
6
test/tests/define override function.lua
Normal file
6
test/tests/define override function.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
local _={}
|
||||
_[1]={"error","trying to define variable define override function.a, but a function with the same name exists; at line 3"}
|
||||
return {_[1]}
|
||||
--[[
|
||||
{ "error", "trying to define variable define override function.a, but a function with the same name exists; at line 3" }
|
||||
]]--
|
||||
3
test/tests/define override variable.ans
Normal file
3
test/tests/define override variable.ans
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
:2 a
|
||||
|
||||
$ a
|
||||
6
test/tests/define override variable.lua
Normal file
6
test/tests/define override variable.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
local _={}
|
||||
_[1]={"error","trying to define function define override variable.a, but a variable with the same name exists; at line 3"}
|
||||
return {_[1]}
|
||||
--[[
|
||||
{ "error", "trying to define function define override variable.a, but a variable with the same name exists; at line 3" }
|
||||
]]--
|
||||
5
test/tests/define override.ans
Normal file
5
test/tests/define override.ans
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
:5 a
|
||||
|
||||
:2 a
|
||||
|
||||
a: {a}
|
||||
14
test/tests/define override.lua
Normal file
14
test/tests/define override.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={data="a: 5",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "a: 5",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
1
test/tests/define.ans
Normal file
1
test/tests/define.ans
Normal file
|
|
@ -0,0 +1 @@
|
|||
:5 a
|
||||
6
test/tests/define.lua
Normal file
6
test/tests/define.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
local _={}
|
||||
_[1]={"return"}
|
||||
return {_[1]}
|
||||
--[[
|
||||
{ "return" }
|
||||
]]--
|
||||
5
test/tests/function arg vararg.ans
Normal file
5
test/tests/function arg vararg.ans
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
$ f(a, l...)
|
||||
{a}
|
||||
{l}
|
||||
|
||||
~ f("ok", "o", "k")
|
||||
19
test/tests/function arg vararg.lua
Normal file
19
test/tests/function arg vararg.lua
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
local _={}
|
||||
_[7]={}
|
||||
_[6]={}
|
||||
_[5]={data="[o, k]",tags=_[7]}
|
||||
_[4]={data="ok",tags=_[6]}
|
||||
_[3]={_[4],_[5]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "ok",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "[o, k]",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
4
test/tests/function arg.ans
Normal file
4
test/tests/function arg.ans
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$ f(a)
|
||||
{a}
|
||||
|
||||
~ f("ok")
|
||||
14
test/tests/function arg.lua
Normal file
14
test/tests/function arg.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={data="ok",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "ok",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
4
test/tests/function args arity check fail.ans
Normal file
4
test/tests/function args arity check fail.ans
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$ f(a, b)
|
||||
{a}{b}
|
||||
|
||||
~ f("ok")
|
||||
6
test/tests/function args arity check fail.lua
Normal file
6
test/tests/function args arity check fail.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
local _={}
|
||||
_[1]={"error","function \"function args arity check fail.f\" expected 2 arguments but received 1; at line 4"}
|
||||
return {_[1]}
|
||||
--[[
|
||||
{ "error", 'function "function args arity check fail.f" expected 2 arguments but received 1; at line 4' }
|
||||
]]--
|
||||
5
test/tests/function args vararg empty.ans
Normal file
5
test/tests/function args vararg empty.ans
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
$ f(a, b, l...)
|
||||
{a}{b}
|
||||
{l}
|
||||
|
||||
~ f("o","k")
|
||||
19
test/tests/function args vararg empty.lua
Normal file
19
test/tests/function args vararg empty.lua
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
local _={}
|
||||
_[7]={}
|
||||
_[6]={}
|
||||
_[5]={data="[]",tags=_[7]}
|
||||
_[4]={data="ok",tags=_[6]}
|
||||
_[3]={_[4],_[5]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "ok",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "[]",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
5
test/tests/function args vararg.ans
Normal file
5
test/tests/function args vararg.ans
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
$ f(a, b, l...)
|
||||
{a}{b}
|
||||
{l}
|
||||
|
||||
~ f("o", "k", "o", "k")
|
||||
19
test/tests/function args vararg.lua
Normal file
19
test/tests/function args vararg.lua
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
local _={}
|
||||
_[7]={}
|
||||
_[6]={}
|
||||
_[5]={data="[o, k]",tags=_[7]}
|
||||
_[4]={data="ok",tags=_[6]}
|
||||
_[3]={_[4],_[5]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "ok",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "[o, k]",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
4
test/tests/function args.ans
Normal file
4
test/tests/function args.ans
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$ f(a, b)
|
||||
{a}{b}
|
||||
|
||||
~ f("o", "k")
|
||||
14
test/tests/function args.lua
Normal file
14
test/tests/function args.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={data="ok",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "ok",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
5
test/tests/function arity conflict.ans
Normal file
5
test/tests/function arity conflict.ans
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
$ f(a, b)
|
||||
|
||||
$ f(x)
|
||||
|
||||
$ f(u, v)
|
||||
6
test/tests/function arity conflict.lua
Normal file
6
test/tests/function arity conflict.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
local _={}
|
||||
_[1]={"error","trying to define function function arity conflict.f with arity [2;2], but another function with the arity exist; at line 5"}
|
||||
return {_[1]}
|
||||
--[[
|
||||
{ "error", "trying to define function function arity conflict.f with arity [2;2], but another function with the arity exist; at line 5" }
|
||||
]]--
|
||||
14
test/tests/function cycle.ans
Normal file
14
test/tests/function cycle.ans
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
$ f
|
||||
$ a
|
||||
a
|
||||
$ b
|
||||
b
|
||||
$ c
|
||||
c
|
||||
~ cycle("a","b","c")
|
||||
|
||||
~ f
|
||||
~ f
|
||||
~ f
|
||||
~ f
|
||||
~ f
|
||||
46
test/tests/function cycle.lua
Normal file
46
test/tests/function cycle.lua
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
local _={}
|
||||
_[21]={}
|
||||
_[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]}
|
||||
_[11]={_[16]}
|
||||
_[10]={_[15]}
|
||||
_[9]={_[14]}
|
||||
_[8]={_[13]}
|
||||
_[7]={_[12]}
|
||||
_[6]={"return"}
|
||||
_[5]={"text",_[11]}
|
||||
_[4]={"text",_[10]}
|
||||
_[3]={"text",_[9]}
|
||||
_[2]={"text",_[8]}
|
||||
_[1]={"text",_[7]}
|
||||
return {_[1],_[2],_[3],_[4],_[5],_[6]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "a",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "b",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "c",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "a",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "b",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
14
test/tests/function next.ans
Normal file
14
test/tests/function next.ans
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
$ f
|
||||
$ a
|
||||
a
|
||||
$ b
|
||||
b
|
||||
$ c
|
||||
c
|
||||
~ next("a","b","c")
|
||||
|
||||
~ f
|
||||
~ f
|
||||
~ f
|
||||
~ f
|
||||
~ f
|
||||
46
test/tests/function next.lua
Normal file
46
test/tests/function next.lua
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
local _={}
|
||||
_[21]={}
|
||||
_[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]}
|
||||
_[11]={_[16]}
|
||||
_[10]={_[15]}
|
||||
_[9]={_[14]}
|
||||
_[8]={_[13]}
|
||||
_[7]={_[12]}
|
||||
_[6]={"return"}
|
||||
_[5]={"text",_[11]}
|
||||
_[4]={"text",_[10]}
|
||||
_[3]={"text",_[9]}
|
||||
_[2]={"text",_[8]}
|
||||
_[1]={"text",_[7]}
|
||||
return {_[1],_[2],_[3],_[4],_[5],_[6]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "a",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "b",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "c",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "c",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "c",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
14
test/tests/function random.ans
Normal file
14
test/tests/function random.ans
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
$ f
|
||||
$ a
|
||||
a
|
||||
$ b
|
||||
b
|
||||
$ c
|
||||
c
|
||||
~ random("a","b","c")
|
||||
|
||||
~ f
|
||||
~ f
|
||||
~ f
|
||||
~ f
|
||||
~ f
|
||||
46
test/tests/function random.lua
Normal file
46
test/tests/function random.lua
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
local _={}
|
||||
_[21]={}
|
||||
_[20]={}
|
||||
_[19]={}
|
||||
_[18]={}
|
||||
_[17]={}
|
||||
_[16]={data="a",tags=_[21]}
|
||||
_[15]={data="c",tags=_[20]}
|
||||
_[14]={data="c",tags=_[19]}
|
||||
_[13]={data="c",tags=_[18]}
|
||||
_[12]={data="b",tags=_[17]}
|
||||
_[11]={_[16]}
|
||||
_[10]={_[15]}
|
||||
_[9]={_[14]}
|
||||
_[8]={_[13]}
|
||||
_[7]={_[12]}
|
||||
_[6]={"return"}
|
||||
_[5]={"text",_[11]}
|
||||
_[4]={"text",_[10]}
|
||||
_[3]={"text",_[9]}
|
||||
_[2]={"text",_[8]}
|
||||
_[1]={"text",_[7]}
|
||||
return {_[1],_[2],_[3],_[4],_[5],_[6]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "b",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "c",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "c",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "c",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "a",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
7
test/tests/function return nested.ans
Normal file
7
test/tests/function return nested.ans
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
$ hey
|
||||
§ foo
|
||||
@2
|
||||
@5
|
||||
|
||||
{hey}
|
||||
{hey.foo}
|
||||
19
test/tests/function return nested.lua
Normal file
19
test/tests/function return nested.lua
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
local _={}
|
||||
_[7]={}
|
||||
_[6]={}
|
||||
_[5]={data="2",tags=_[7]}
|
||||
_[4]={data="5",tags=_[6]}
|
||||
_[3]={_[4],_[5]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "5",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "2",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
4
test/tests/function return.ans
Normal file
4
test/tests/function return.ans
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$ hey
|
||||
@5
|
||||
|
||||
{hey}
|
||||
14
test/tests/function return.lua
Normal file
14
test/tests/function return.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={data="5",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "5",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
4
test/tests/function scope wrong.ans
Normal file
4
test/tests/function scope wrong.ans
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$ a
|
||||
:5 b
|
||||
|
||||
a: {b}
|
||||
6
test/tests/function scope wrong.lua
Normal file
6
test/tests/function scope wrong.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
local _={}
|
||||
_[1]={"error","unknown identifier \"b\"; at line 4"}
|
||||
return {_[1]}
|
||||
--[[
|
||||
{ "error", 'unknown identifier "b"; at line 4' }
|
||||
]]--
|
||||
4
test/tests/function scope.ans
Normal file
4
test/tests/function scope.ans
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$ a
|
||||
:5 b
|
||||
|
||||
a: {a.b}
|
||||
14
test/tests/function scope.lua
Normal file
14
test/tests/function scope.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={data="a: 5",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "a: 5",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
4
test/tests/function ufcs arg.ans
Normal file
4
test/tests/function ufcs arg.ans
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$ f(a)
|
||||
{a}
|
||||
|
||||
~ "ok".f()
|
||||
14
test/tests/function ufcs arg.lua
Normal file
14
test/tests/function ufcs arg.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={data="ok",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "ok",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
4
test/tests/function ufcs args.ans
Normal file
4
test/tests/function ufcs args.ans
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$ f(a, b)
|
||||
{a}{b}
|
||||
|
||||
~ "o".f("k")
|
||||
14
test/tests/function ufcs args.lua
Normal file
14
test/tests/function ufcs args.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={data="ok",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "ok",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
4
test/tests/function vararg empty.ans
Normal file
4
test/tests/function vararg empty.ans
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$ f(l...)
|
||||
{l}
|
||||
|
||||
~ f()
|
||||
14
test/tests/function vararg empty.lua
Normal file
14
test/tests/function vararg empty.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={data="[]",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "[]",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
4
test/tests/function vararg.ans
Normal file
4
test/tests/function vararg.ans
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$ f(l...)
|
||||
{l}
|
||||
|
||||
~ f("o", "k")
|
||||
14
test/tests/function vararg.lua
Normal file
14
test/tests/function vararg.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={data="[o, k]",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "[o, k]",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
4
test/tests/function.ans
Normal file
4
test/tests/function.ans
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$ f
|
||||
ok
|
||||
|
||||
~ f
|
||||
14
test/tests/function.lua
Normal file
14
test/tests/function.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={data="ok",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "ok",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
19
test/tests/interrupt callback nested paragraph.ans
Normal file
19
test/tests/interrupt callback nested paragraph.ans
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
$ oh
|
||||
§ leave
|
||||
in interrupt: {bar.var}
|
||||
no
|
||||
$ bar
|
||||
:5 var
|
||||
|
||||
~ var := 2
|
||||
|
||||
before: {var}
|
||||
|
||||
~ interrupt("leave")
|
||||
|
||||
§ foo
|
||||
checkpoint
|
||||
|
||||
after: {var}
|
||||
|
||||
~ oh.bar
|
||||
29
test/tests/interrupt callback nested paragraph.lua
Normal file
29
test/tests/interrupt callback nested paragraph.lua
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
local _={}
|
||||
_[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]}
|
||||
_[4]={"return"}
|
||||
_[3]={"text",_[6]}
|
||||
_[2]={"wait",0}
|
||||
_[1]={"text",_[5]}
|
||||
return {_[1],_[2],_[3],_[4]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "before: 2",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "wait", 0 }
|
||||
{ "text", { {
|
||||
data = "in interrupt: 5",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "no",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
20
test/tests/interrupt callback nested.ans
Normal file
20
test/tests/interrupt callback nested.ans
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
$ leave
|
||||
in interrupt: {oh.bar.var}
|
||||
|
||||
$ oh
|
||||
no
|
||||
$ bar
|
||||
:5 var
|
||||
|
||||
~ var := 2
|
||||
|
||||
before: {var}
|
||||
|
||||
~ interrupt("leave")
|
||||
|
||||
§ foo
|
||||
checkpoint
|
||||
|
||||
after: {var}
|
||||
|
||||
~ oh.bar
|
||||
24
test/tests/interrupt callback nested.lua
Normal file
24
test/tests/interrupt callback nested.lua
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
local _={}
|
||||
_[10]={}
|
||||
_[9]={}
|
||||
_[8]={data="in interrupt: 5",tags=_[10]}
|
||||
_[7]={data="before: 2",tags=_[9]}
|
||||
_[6]={_[8]}
|
||||
_[5]={_[7]}
|
||||
_[4]={"return"}
|
||||
_[3]={"text",_[6]}
|
||||
_[2]={"wait",0}
|
||||
_[1]={"text",_[5]}
|
||||
return {_[1],_[2],_[3],_[4]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "before: 2",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "wait", 0 }
|
||||
{ "text", { {
|
||||
data = "in interrupt: 5",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
18
test/tests/interrupt callback.ans
Normal file
18
test/tests/interrupt callback.ans
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
$ bar
|
||||
:5 var
|
||||
|
||||
~ var := 2
|
||||
|
||||
$ leave
|
||||
in interrupt: {var}
|
||||
|
||||
before: {var}
|
||||
|
||||
~ interrupt("leave")
|
||||
|
||||
§ foo
|
||||
checkpoint
|
||||
|
||||
after: {var}
|
||||
|
||||
~ bar
|
||||
24
test/tests/interrupt callback.lua
Normal file
24
test/tests/interrupt callback.lua
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
local _={}
|
||||
_[10]={}
|
||||
_[9]={}
|
||||
_[8]={data="in interrupt: 5",tags=_[10]}
|
||||
_[7]={data="before: 2",tags=_[9]}
|
||||
_[6]={_[8]}
|
||||
_[5]={_[7]}
|
||||
_[4]={"return"}
|
||||
_[3]={"text",_[6]}
|
||||
_[2]={"wait",0}
|
||||
_[1]={"text",_[5]}
|
||||
return {_[1],_[2],_[3],_[4]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "before: 2",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "wait", 0 }
|
||||
{ "text", { {
|
||||
data = "in interrupt: 5",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
18
test/tests/interrupt no callback.ans
Normal file
18
test/tests/interrupt no callback.ans
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
$ bar
|
||||
:5 var
|
||||
|
||||
~ var := 2
|
||||
|
||||
$ leave
|
||||
in interrupt: {var}
|
||||
|
||||
before: {var}
|
||||
|
||||
~ interrupt()
|
||||
|
||||
§ foo
|
||||
checkpoint
|
||||
|
||||
after: {var}
|
||||
|
||||
~ bar
|
||||
16
test/tests/interrupt no callback.lua
Normal file
16
test/tests/interrupt no callback.lua
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
local _={}
|
||||
_[6]={}
|
||||
_[5]={data="before: 2",tags=_[6]}
|
||||
_[4]={_[5]}
|
||||
_[3]={"return",""}
|
||||
_[2]={"wait",0}
|
||||
_[1]={"text",_[4]}
|
||||
return {_[1],_[2],_[3]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "before: 2",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "wait", 0 }
|
||||
{ "return", "" }
|
||||
]]--
|
||||
3
test/tests/paragraph decorator scope explicit call.ans
Normal file
3
test/tests/paragraph decorator scope explicit call.ans
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
a.👁️: {a.👁️} § a
|
||||
|
||||
~ a()
|
||||
22
test/tests/paragraph decorator scope explicit call.lua
Normal file
22
test/tests/paragraph decorator scope explicit call.lua
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
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]}
|
||||
_[3]={"return"}
|
||||
_[2]={"text",_[5]}
|
||||
_[1]={"text",_[4]}
|
||||
return {_[1],_[2],_[3]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "a.👁️: 0",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "a.👁️: 1",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
6
test/tests/paragraph decorator scope implicit call.ans
Normal file
6
test/tests/paragraph decorator scope implicit call.ans
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
$ f
|
||||
ko
|
||||
a.👁️: {a.👁️} § a
|
||||
ok
|
||||
|
||||
~ f.a
|
||||
19
test/tests/paragraph decorator scope implicit call.lua
Normal file
19
test/tests/paragraph decorator scope implicit call.lua
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
local _={}
|
||||
_[7]={}
|
||||
_[6]={}
|
||||
_[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]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "a.👁️: 0",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "ok",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
1
test/tests/paragraph decorator scope.ans
Normal file
1
test/tests/paragraph decorator scope.ans
Normal file
|
|
@ -0,0 +1 @@
|
|||
a.👁️: {a.👁️} § a
|
||||
14
test/tests/paragraph decorator scope.lua
Normal file
14
test/tests/paragraph decorator scope.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={data="a.\240\159\145\129\239\184\143: 0",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "a.👁️: 0",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
14
test/tests/paragraph run force.ans
Normal file
14
test/tests/paragraph run force.ans
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
$ f
|
||||
x
|
||||
§ p
|
||||
a
|
||||
b
|
||||
|
||||
Force run checkpoint:
|
||||
~ f.p()
|
||||
|
||||
From checkpoint:
|
||||
~ f
|
||||
|
||||
Force no checkpoint:
|
||||
~ f()
|
||||
55
test/tests/paragraph run force.lua
Normal file
55
test/tests/paragraph run force.lua
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
local _={}
|
||||
_[23]={}
|
||||
_[22]={}
|
||||
_[21]={}
|
||||
_[20]={}
|
||||
_[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]}
|
||||
_[7]={_[13],_[14],_[15]}
|
||||
_[6]={_[10],_[11],_[12]}
|
||||
_[5]={_[8],_[9]}
|
||||
_[4]={"return"}
|
||||
_[3]={"text",_[7]}
|
||||
_[2]={"text",_[6]}
|
||||
_[1]={"text",_[5]}
|
||||
return {_[1],_[2],_[3],_[4]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "Force run checkpoint:",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "a",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "From checkpoint:",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "a",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "b",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "Force no checkpoint:",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "x",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "b",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
14
test/tests/paragraph run from.ans
Normal file
14
test/tests/paragraph run from.ans
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
$ f
|
||||
x
|
||||
§ p
|
||||
a
|
||||
b
|
||||
|
||||
Force run from checkpoint:
|
||||
~ f.p
|
||||
|
||||
From checkpoint:
|
||||
~ f
|
||||
|
||||
Force no checkpoint:
|
||||
~ f()
|
||||
60
test/tests/paragraph run from.lua
Normal file
60
test/tests/paragraph run from.lua
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
local _={}
|
||||
_[25]={}
|
||||
_[24]={}
|
||||
_[23]={}
|
||||
_[22]={}
|
||||
_[21]={}
|
||||
_[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]}
|
||||
_[7]={_[14],_[15],_[16]}
|
||||
_[6]={_[11],_[12],_[13]}
|
||||
_[5]={_[8],_[9],_[10]}
|
||||
_[4]={"return"}
|
||||
_[3]={"text",_[7]}
|
||||
_[2]={"text",_[6]}
|
||||
_[1]={"text",_[5]}
|
||||
return {_[1],_[2],_[3],_[4]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "Force run from checkpoint:",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "a",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "b",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "From checkpoint:",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "a",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "b",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "Force no checkpoint:",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "x",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "b",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
14
test/tests/paragraph run.ans
Normal file
14
test/tests/paragraph run.ans
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
$ f
|
||||
x
|
||||
§ p
|
||||
a
|
||||
b
|
||||
|
||||
No checkpoint:
|
||||
~ f
|
||||
|
||||
From checkpoint:
|
||||
~ f
|
||||
|
||||
Force no checkpoint:
|
||||
~ f()
|
||||
60
test/tests/paragraph run.lua
Normal file
60
test/tests/paragraph run.lua
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
local _={}
|
||||
_[25]={}
|
||||
_[24]={}
|
||||
_[23]={}
|
||||
_[22]={}
|
||||
_[21]={}
|
||||
_[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]}
|
||||
_[7]={_[14],_[15],_[16]}
|
||||
_[6]={_[11],_[12],_[13]}
|
||||
_[5]={_[8],_[9],_[10]}
|
||||
_[4]={"return"}
|
||||
_[3]={"text",_[7]}
|
||||
_[2]={"text",_[6]}
|
||||
_[1]={"text",_[5]}
|
||||
return {_[1],_[2],_[3],_[4]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "No checkpoint:",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "x",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "b",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "From checkpoint:",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "a",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "b",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "text", { {
|
||||
data = "Force no checkpoint:",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "x",
|
||||
tags = {}
|
||||
}, {
|
||||
data = "b",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
3
test/tests/paragraph.ans
Normal file
3
test/tests/paragraph.ans
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
§ p
|
||||
a
|
||||
b
|
||||
14
test/tests/paragraph.lua
Normal file
14
test/tests/paragraph.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local _={}
|
||||
_[5]={}
|
||||
_[4]={data="b",tags=_[5]}
|
||||
_[3]={_[4]}
|
||||
_[2]={"return"}
|
||||
_[1]={"text",_[3]}
|
||||
return {_[1],_[2]}
|
||||
--[[
|
||||
{ "text", { {
|
||||
data = "b",
|
||||
tags = {}
|
||||
} } }
|
||||
{ "return" }
|
||||
]]--
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue