From f74161ca4e7eb3c5af9afcbe92522ae3b58987c1 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 19 Apr 2017 23:04:15 +0000 Subject: context beta/cont-tmf.zip (Apr 16 12:55) git-svn-id: svn://tug.org/texlive/trunk@43931 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/context/base/mkiv/util-prs.lua | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'Master/texmf-dist/tex/context/base/mkiv/util-prs.lua') diff --git a/Master/texmf-dist/tex/context/base/mkiv/util-prs.lua b/Master/texmf-dist/tex/context/base/mkiv/util-prs.lua index 02729dd0ef0..650a7ead6ae 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/util-prs.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/util-prs.lua @@ -83,10 +83,6 @@ local pattern_b = spaces * comma^0 * spaces * (key * ((spaces * equal * spaces * -- "a=1, b=2, c=3, d={a{b,c}d}, e=12345, f=xx{a{b,c}d}xx, g={}" : outer {} removes, leading spaces ignored --- todo: rewrite to fold etc --- --- parse = lpeg.Cf(lpeg.Carg(1) * lpeg.Cg(key * equal * value) * separator^0,rawset)^0 -- lpeg.match(parse,"...",1,hash) - local hash = { } local function set(key,value) @@ -197,6 +193,23 @@ function parsers.settings_to_array(str,strict) end end +function parsers.settings_to_numbers(str) + if not str or str == "" then + return { } + end + if type(str) == "table" then + -- fall through + elseif find(str,",",1,true) then + str = lpegmatch(pattern,str) + else + return { tonumber(str) } + end + for i=1,#str do + str[i] = tonumber(str[i]) + end + return str +end + local value = P(lbrace * C((nobrace + nestedbraces)^0) * rbrace) + C((nestedbraces + nestedbrackets + nestedparents + (1-comma))^0) local pattern = spaces * Ct(value*(separator*value)^0) -- cgit v1.2.3