KoboldAI-Client/extern/lualibs/pl/input.lua
Gnome Ann 35966b2007 Upload bridge.lua, default.lua and some Lua libs
base64
inspect
json.lua
Lua-hashings
Lua-nums
Moses
mt19937ar-lua
Penlight
Serpent
2021-12-10 19:45:57 -05:00

7 lines
2.8 KiB
Lua

-- Penlight 1.11.0-1 | /lua/pl/input.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- 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 a=string.find;local b=string.sub;local c=string.match;local d=require'pl.utils'local e=d.unpack;local pairs,type,tonumber=pairs,type,tonumber;local f=d.patterns;local io=io;local g={}function g.alltokens(h,i,j)local k=h()local l=1;return function()while k do local m,n=a(k,i,l)if m then l=n+1;local o=b(k,m,n)if j then o=j(o)end;return o else k=h()l=1 end end;return nil end end;local p=g.alltokens;function g.create_getter(q)if q then if type(q)=='string'then local r=d.split(q,'\n')local s,t=0,#r;return function()s=s+1;if s>t then return nil end;return r[s]end else if not q.read then error('not a file-like object')end;return function()return q:read()end end else return io.read end end;function g.numbers(q)return p(g.create_getter(q),'('..f.FLOAT..')',tonumber)end;function g.words(q)return p(g.create_getter(q),"%w+")end;local function u(v,...)local w={...}for s=1,#w do local t=tonumber(w[s])if t==nil then if not v then return nil,w[s]end else w[s]=t end end;return w end;function g.fields(x,y,q,z)local A;local m;local h=g.create_getter(q)local v=z and z.no_fail;local B=z and z.no_convert;if not y or y==' 'then y='%s'A='%s+'m='%s*'else A=y;m=''end;local C=0;if type(x)=='table'then for s,D in pairs(x)do if D>C then C=D end end else C=x;x={}for s=1,C do x[#x+1]=s end end;local E='[^'..y..']*'local F=1;for s=1,C do if x[F]==s then F=F+1;m=m..'('..E..')'else m=m..E end;if s<C then m=m..A end end;local G=1;return function()local k,H,I;repeat k=h()G=G+1;if not k then return nil end;if B then H={c(k,m)}else H,I=u(v,c(k,m))if not H then d.quit("line "..G-1 ..": cannot convert '"..I.."' to number")end end until#H>0;return e(H)end end;return g