summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua')
-rw-r--r--Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua144
1 files changed, 138 insertions, 6 deletions
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua
index 4df0eb6f9cd..fe87e8a09b8 100644
--- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua
+++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua
@@ -1,6 +1,6 @@
-- merged file : lualibs-extended-merged.lua
-- parent file : lualibs-extended.lua
--- merge date : Thu May 9 16:30:14 2013
+-- merge date : Sat May 18 12:25:20 2013
do -- begin closure to overcome local limits and interference
@@ -1066,7 +1066,9 @@ patterns.settings_to_hash_a=pattern_a_s
patterns.settings_to_hash_b=pattern_b_s
patterns.settings_to_hash_c=pattern_c_s
function parsers.make_settings_to_hash_pattern(set,how)
- if how=="strict" then
+ if type(str)=="table" then
+ return set
+ elseif how=="strict" then
return (pattern_c/set)^1
elseif how=="tolerant" then
return (pattern_b/set)^1
@@ -1075,7 +1077,16 @@ function parsers.make_settings_to_hash_pattern(set,how)
end
end
function parsers.settings_to_hash(str,existing)
- if str and str~="" then
+ if type(str)=="table" then
+ if existing then
+ for k,v in next,str do
+ existing[k]=v
+ end
+ return exiting
+ else
+ return str
+ end
+ elseif str and str~="" then
hash=existing or {}
lpegmatch(pattern_a_s,str)
return hash
@@ -1084,7 +1095,16 @@ function parsers.settings_to_hash(str,existing)
end
end
function parsers.settings_to_hash_tolerant(str,existing)
- if str and str~="" then
+ if type(str)=="table" then
+ if existing then
+ for k,v in next,str do
+ existing[k]=v
+ end
+ return exiting
+ else
+ return str
+ end
+ elseif str and str~="" then
hash=existing or {}
lpegmatch(pattern_b_s,str)
return hash
@@ -1093,7 +1113,16 @@ function parsers.settings_to_hash_tolerant(str,existing)
end
end
function parsers.settings_to_hash_strict(str,existing)
- if str and str~="" then
+ if type(str)=="table" then
+ if existing then
+ for k,v in next,str do
+ existing[k]=v
+ end
+ return exiting
+ else
+ return str
+ end
+ elseif str and str~="" then
hash=existing or {}
lpegmatch(pattern_c_s,str)
return next(hash) and hash
@@ -1106,7 +1135,9 @@ local value=P(lbrace*C((nobrace+nestedbraces)^0)*rbrace)+C((nestedbraces+(1-comm
local pattern=spaces*Ct(value*(separator*value)^0)
patterns.settings_to_array=pattern
function parsers.settings_to_array(str,strict)
- if not str or str=="" then
+ if type(str)=="table" then
+ return str
+ elseif not str or str=="" then
return {}
elseif strict then
if find(str,"{") then
@@ -1594,6 +1625,107 @@ end -- closure
do -- begin closure to overcome local limits and interference
+if not modules then modules={} end modules ['util-jsn']={
+ version=1.001,
+ comment="companion to m-json.mkiv",
+ author="Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright="PRAGMA ADE / ConTeXt Development Team",
+ license="see context related readme files"
+}
+local P,V,R,S,C,Cc,Cs,Ct,Cf,Cg=lpeg.P,lpeg.V,lpeg.R,lpeg.S,lpeg.C,lpeg.Cc,lpeg.Cs,lpeg.Ct,lpeg.Cf,lpeg.Cg
+local lpegmatch=lpeg.match
+local format=string.format
+local utfchar=utf.char
+local concat=table.concat
+local tonumber,tostring,rawset,type=tonumber,tostring,rawset,type
+local json=utilities.json or {}
+utilities.json=json
+local lbrace=P("{")
+local rbrace=P("}")
+local lparent=P("[")
+local rparent=P("]")
+local comma=P(",")
+local colon=P(":")
+local dquote=P('"')
+local whitespace=lpeg.patterns.whitespace
+local optionalws=whitespace^0
+local escape=C(P("\\u")/"0x"*S("09","AF","af"))/function(s) return utfchar(tonumber(s)) end
+local jstring=dquote*Cs((escape+(1-dquote))^0)*dquote
+local jtrue=P("true")*Cc(true)
+local jfalse=P("false")*Cc(false)
+local jnull=P("null")*Cc(nil)
+local jnumber=(1-whitespace-rparent-rbrace-comma)^1/tonumber
+local key=jstring
+local jsonconverter={ "value",
+ object=lbrace*Cf(Ct("")*V("pair")*(comma*V("pair"))^0,rawset)*rbrace,
+ pair=Cg(optionalws*key*optionalws*colon*V("value")),
+ array=Ct(lparent*V("value")*(comma*V("value"))^0*rparent),
+ value=optionalws*(jstring+V("object")+V("array")+jtrue+jfalse+jnull+jnumber+#rparent)*optionalws,
+}
+function json.tolua(str)
+ return lpegmatch(jsonconverter,str)
+end
+local function tojson(value,t)
+ local kind=type(value)
+ if kind=="table" then
+ local done=false
+ local size=#value
+ if size==0 then
+ for k,v in next,value do
+ if done then
+ t[#t+1]=","
+ else
+ t[#t+1]="{"
+ done=true
+ end
+ t[#t+1]=format("%q:",k)
+ tojson(v,t)
+ end
+ if done then
+ t[#t+1]="}"
+ else
+ t[#t+1]="{}"
+ end
+ elseif size==1 then
+ t[#t+1]="["
+ tojson(value[1],t)
+ t[#t+1]="]"
+ else
+ for i=1,size do
+ if done then
+ t[#t+1]=","
+ else
+ t[#t+1]="["
+ done=true
+ end
+ tojson(value[i],t)
+ end
+ t[#t+1]="]"
+ end
+ elseif kind=="string" then
+ t[#t+1]=format("%q",value)
+ elseif kind=="number" then
+ t[#t+1]=value
+ elseif kind=="boolean" then
+ t[#t+1]=tostring(value)
+ end
+ return t
+end
+function json.tostring(value)
+ local kind=type(value)
+ if kind=="table" then
+ return concat(tojson(value,{}),"")
+ elseif kind=="string" or kind=="number" then
+ return value
+ else
+ return tostring(value)
+ end
+end
+
+end -- closure
+
+do -- begin closure to overcome local limits and interference
+
if not modules then modules={} end modules ['trac-inf']={
version=1.001,
comment="companion to trac-inf.mkiv",