summaryrefslogtreecommitdiff
path: root/tex/context/base/l-aux.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2007-08-07 01:37:00 +0200
committerHans Hagen <pragma@wxs.nl>2007-08-07 01:37:00 +0200
commitaacdde41ef02392949aee16b2e428a8913d27efe (patch)
tree1ca125418e41b0335ee115a24cf27acb8fa7eae9 /tex/context/base/l-aux.lua
parentdbcaab8b8f76309b9fc4e05bf8a42f6b56e61893 (diff)
downloadcontext-aacdde41ef02392949aee16b2e428a8913d27efe.tar.gz
stable 2007.08.07 01:37
Diffstat (limited to 'tex/context/base/l-aux.lua')
-rw-r--r--tex/context/base/l-aux.lua39
1 files changed, 39 insertions, 0 deletions
diff --git a/tex/context/base/l-aux.lua b/tex/context/base/l-aux.lua
new file mode 100644
index 000000000..59ff42539
--- /dev/null
+++ b/tex/context/base/l-aux.lua
@@ -0,0 +1,39 @@
+-- filename : l-aux.lua
+-- author : Hans Hagen, PRAGMA-ADE, Hasselt NL
+-- copyright: PRAGMA ADE / ConTeXt Development Team
+-- license : see context related readme files
+
+if not versions then versions = { } end versions['l-aux'] = 1.001
+if not aux then aux = { } end
+
+do
+
+ hash = { }
+
+ function set(key,value)
+ hash[key] = value
+ end
+
+ local space = lpeg.S(' ')^0
+ local equal = lpeg.S("=")^1
+ local comma = lpeg.S(",")^0
+ local nonspace = lpeg.P(1-lpeg.S(' '))^1
+ local nonequal = lpeg.P(1-lpeg.S('='))^1
+ local noncomma = lpeg.P(1-lpeg.S(','))^1
+ local nonbrace = lpeg.P(1-lpeg.S('{}'))^1
+ local nested = lpeg.S('{') * lpeg.C(nonbrace^1) * lpeg.S('}')
+
+ local key = lpeg.C(nonequal)
+ local value = nested + lpeg.C(noncomma)
+
+ local pattern = ((space * key * equal * value * comma) / set)^1
+
+ function aux.settings_to_hash(str)
+ hash = { }
+ lpeg.match(pattern,str)
+ return hash
+ end
+
+end
+
+--~ print(table.serialize(aux.settings_to_hash("aaa=bbb, ccc={d,d,d}")))