diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/util-prs.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/util-prs.lua | 35 |
1 files changed, 7 insertions, 28 deletions
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 08401f22275..48d59a9f3f7 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/util-prs.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/util-prs.lua @@ -31,7 +31,6 @@ utilities.parsers.hashes = hashes local digit = R("09") local space = P(' ') local equal = P("=") -local colon = P(":") local comma = P(",") local lbrace = P("{") local rbrace = P("}") @@ -73,13 +72,11 @@ lpegpatterns.nested = nestedbraces -- no capture lpegpatterns.argument = argument -- argument after e.g. = lpegpatterns.content = content -- rest after e.g = -local value = lbrace * C((nobrace + nestedbraces)^0) * rbrace - + C((nestedbraces + (1-comma))^0) +local value = P(lbrace * C((nobrace + nestedbraces)^0) * rbrace) + C((nestedbraces + (1-comma))^0) local key = C((1-equal-comma)^1) local pattern_a = (space+comma)^0 * (key * equal * value + key * C("")) local pattern_c = (space+comma)^0 * (key * equal * value) -local pattern_d = (space+comma)^0 * (key * (equal+colon) * value + key * C("")) local key = C((1-space-equal-comma)^1) local pattern_b = spaces * comma^0 * spaces * (key * ((spaces * equal * spaces * value) + C(""))) @@ -95,12 +92,10 @@ end local pattern_a_s = (pattern_a/set)^1 local pattern_b_s = (pattern_b/set)^1 local pattern_c_s = (pattern_c/set)^1 -local pattern_d_s = (pattern_d/set)^1 patterns.settings_to_hash_a = pattern_a_s patterns.settings_to_hash_b = pattern_b_s patterns.settings_to_hash_c = pattern_c_s -patterns.settings_to_hash_d = pattern_d_s function parsers.make_settings_to_hash_pattern(set,how) if how == "strict" then @@ -131,18 +126,6 @@ function parsers.settings_to_hash(str,existing) end end -function parsers.settings_to_hash_colon_too(str) - if not str or str == "" then - return { } - elseif type(str) == "table" then - return str - else - hash = { } - lpegmatch(pattern_d_s,str) - return hash - end -end - function parsers.settings_to_hash_tolerant(str,existing) if not str or str == "" then return { } @@ -182,7 +165,7 @@ function parsers.settings_to_hash_strict(str,existing) end local separator = comma * space^0 -local value = lbrace * C((nobrace + nestedbraces)^0) * rbrace +local value = P(lbrace * C((nobrace + nestedbraces)^0) * rbrace) + C((nestedbraces + (1-comma))^0) local pattern = spaces * Ct(value*(separator*value)^0) @@ -227,7 +210,7 @@ function parsers.settings_to_numbers(str) return str end -local value = lbrace * C((nobrace + nestedbraces)^0) * rbrace +local value = P(lbrace * C((nobrace + nestedbraces)^0) * rbrace) + C((nestedbraces + nestedbrackets + nestedparents + (1-comma))^0) local pattern = spaces * Ct(value*(separator*value)^0) @@ -259,7 +242,7 @@ function parsers.groupedsplitat(symbol,withaction) if not pattern then local symbols = S(symbol) local separator = space^0 * symbols * space^0 - local value = lbrace * C((nobrace + nestedbraces)^0) * rbrace + local value = P(lbrace * C((nobrace + nestedbraces)^0) * rbrace) + C((nestedbraces + (1-(space^0*(symbols+P(-1)))))^0) if withaction then local withvalue = Carg(1) * value / function(f,s) return f(s) end @@ -308,9 +291,7 @@ end function parsers.hash_to_string(h,separator,yes,no,strict,omit) if h then - local t = { } - local tn = 0 - local s = sortedkeys(h) + local t, tn, s = { }, 0, sortedkeys(h) omit = omit and tohash(omit) for i=1,#s do local key = s[i] @@ -376,8 +357,7 @@ end) getmetatable(hashes.settings_to_set).__mode = "kv" -- could be an option (maybe sharing makes sense) function parsers.simple_hash_to_string(h, separator) - local t = { } - local tn = 0 + local t, tn = { }, 0 for k, v in sortedhash(h) do if v then tn = tn + 1 @@ -418,8 +398,7 @@ local function repeater(n,str) if n == 1 then return unpack(s) else - local t = { } - local tn = 0 + local t, tn = { }, 0 for i=1,n do for j=1,#s do tn = tn + 1 |