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