diff options
author | Philipp Gesang <phg42.2a@gmail.com> | 2013-09-15 12:26:37 -0700 |
---|---|---|
committer | Philipp Gesang <phg42.2a@gmail.com> | 2013-09-15 12:26:37 -0700 |
commit | 49880e8803d8f813aebcb15a5ecb6dc70d0caa17 (patch) | |
tree | f3335969fae3d526b4d9e968a374dd54cc87926b /lualibs-util-prs.lua | |
parent | 08311ca818df220f8e59fc0ff5835d18913daa89 (diff) | |
parent | 08563510e0f4328d9e893f17fc1fd37bac00dbc7 (diff) | |
download | lualibs-49880e8803d8f813aebcb15a5ecb6dc70d0caa17.tar.gz |
Merge pull request #18 from phi-gamma/master
sync
Diffstat (limited to 'lualibs-util-prs.lua')
-rw-r--r-- | lualibs-util-prs.lua | 12 |
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 |