summaryrefslogtreecommitdiff
path: root/lualibs-util-prs.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-09-15 21:15:17 +0200
committerPhilipp Gesang <phg42.2a@gmail.com>2013-09-15 21:15:17 +0200
commit96ba331ed3395bd61f377e5c176b372d38e078da (patch)
treeacd09ab82fe6fbbab851e9e6a5d10afca411dc79 /lualibs-util-prs.lua
parent9613f4348a811be2f2751873cd98072a9378c9d4 (diff)
downloadlualibs-96ba331ed3395bd61f377e5c176b372d38e078da.tar.gz
sync with Context as of 2013-09-15
Diffstat (limited to 'lualibs-util-prs.lua')
-rw-r--r--lualibs-util-prs.lua12
1 files changed, 11 insertions, 1 deletions
diff --git a/lualibs-util-prs.lua b/lualibs-util-prs.lua
index 7fe1e70..7a8c3ce 100644
--- a/lualibs-util-prs.lua
+++ b/lualibs-util-prs.lua
@@ -261,6 +261,16 @@ function parsers.simple_hash_to_string(h, separator)
return concat(t,separator or ",")
end
+-- for mtx-context etc: aaaa bbbb cccc=dddd eeee=ffff
+
+local str = C((1-whitespace-equal)^1)
+local setting = Cf( Carg(1) * (whitespace^0 * Cg(str * whitespace^0 * (equal * whitespace^0 * str + Cc(""))))^1,rawset)
+local splitter = setting^1
+
+function utilities.parsers.options_to_hash(str,target)
+ return str and lpegmatch(splitter,str,1,target or { }) or { }
+end
+
-- for chem (currently one level)
local value = P(lbrace * C((nobrace + nestedbraces)^0) * rbrace)
@@ -569,7 +579,7 @@ local function fetch(t,name)
return t[name] or { }
end
-function process(result,more)
+local function process(result,more)
for k, v in next, more do
result[k] = v
end