summaryrefslogtreecommitdiff
path: root/lualibs-util-prs.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2014-12-11 21:03:53 +0100
committerPhilipp Gesang <phg42.2a@gmail.com>2014-12-11 21:03:53 +0100
commit281539cf53b8ec43d72e06cbdba874b2de6e758d (patch)
tree9dc539f574e424247458beade553cdffbed59707 /lualibs-util-prs.lua
parentee53358e267a7946608e66775047085b815b8608 (diff)
downloadlualibs-281539cf53b8ec43d72e06cbdba874b2de6e758d.tar.gz
sync with Context as of 2014-12-11
Diffstat (limited to 'lualibs-util-prs.lua')
-rw-r--r--lualibs-util-prs.lua24
1 files changed, 17 insertions, 7 deletions
diff --git a/lualibs-util-prs.lua b/lualibs-util-prs.lua
index f51f6fc..642968c 100644
--- a/lualibs-util-prs.lua
+++ b/lualibs-util-prs.lua
@@ -275,15 +275,25 @@ function parsers.array_to_string(a,separator)
end
end
-function parsers.settings_to_set(str,t) -- tohash? -- todo: lpeg -- duplicate anyway
- t = t or { }
--- for s in gmatch(str,"%s*([^, ]+)") do -- space added
- for s in gmatch(str,"[^, ]+") do -- space added
- t[s] = true
- end
- return t
+-- function parsers.settings_to_set(str,t) -- tohash? -- todo: lpeg -- duplicate anyway
+-- if str then
+-- t = t or { }
+-- for s in gmatch(str,"[^, ]+") do -- space added
+-- t[s] = true
+-- end
+-- return t
+-- else
+-- return { }
+-- end
+-- end
+
+local pattern = Cf(Ct("") * Cg(C((1-S(", "))^1) * S(", ")^0 * Cc(true))^1,rawset)
+
+function utilities.parsers.settings_to_set(str,t)
+ return str and lpegmatch(pattern,str) or { }
end
+
function parsers.simple_hash_to_string(h, separator)
local t, tn = { }, 0
for k, v in sortedhash(h) do