diff options
author | Marius <mariausol@gmail.com> | 2011-07-19 12:00:13 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2011-07-19 12:00:13 +0300 |
commit | d2b92bb7de0e604d78557c52618d090863d4224c (patch) | |
tree | bd470fc88e304ae44df08c52a1b14f838aa4a3da /scripts/context/stubs | |
parent | a8d0a863d99794b231e58c0e8945448c19bd6215 (diff) | |
download | context-d2b92bb7de0e604d78557c52618d090863d4224c.tar.gz |
beta 2011.07.19 10:35
Diffstat (limited to 'scripts/context/stubs')
-rw-r--r-- | scripts/context/stubs/mswin/mtxrun.lua | 18 | ||||
-rw-r--r-- | scripts/context/stubs/unix/mtxrun | 18 |
2 files changed, 28 insertions, 8 deletions
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 04f8c21c4..29665417e 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -4443,9 +4443,9 @@ if not modules then modules = { } end modules ['util-prs'] = { license = "see context related readme files" } -local P, R, V, C, Ct, Carg = lpeg.P, lpeg.R, lpeg.V, lpeg.C, lpeg.Ct, lpeg.Carg +local P, R, V, C, Ct, Cs, Carg = lpeg.P, lpeg.R, lpeg.V, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.Carg local lpegmatch = lpeg.match -local concat, format, gmatch = table.concat, string.format, string.gmatch +local concat, format, gmatch, find = table.concat, string.format, string.gmatch, string.find local tostring, type, next = tostring, type, next utilities = utilities or {} @@ -4473,8 +4473,12 @@ local rbrace = P("}") local nobrace = 1 - (lbrace+rbrace) local nested = P { lbrace * (nobrace + V(1))^0 * rbrace } local spaces = space^0 +local argument = Cs((lbrace/"") * ((nobrace + nested)^0) * (rbrace/"")) +local content = (1-P(-1))^0 -lpeg.patterns.nested = nested +lpeg.patterns.nested = nested -- no capture +lpeg.patterns.argument = argument -- argument after e.g. = +lpeg.patterns.content = content -- rest after e.g = local value = P(lbrace * C((nobrace + nested)^0) * rbrace) + C((nested + (1-comma))^0) @@ -4555,9 +4559,15 @@ parsers.patterns.settings_to_array = pattern -- we could use a weak table as cache -function parsers.settings_to_array(str) +function parsers.settings_to_array(str,strict) if not str or str == "" then return { } + elseif strict then + if find(str,"{") then + return lpegmatch(pattern,str) + else + return { str } + end else return lpegmatch(pattern,str) end diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 04f8c21c4..29665417e 100644 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -4443,9 +4443,9 @@ if not modules then modules = { } end modules ['util-prs'] = { license = "see context related readme files" } -local P, R, V, C, Ct, Carg = lpeg.P, lpeg.R, lpeg.V, lpeg.C, lpeg.Ct, lpeg.Carg +local P, R, V, C, Ct, Cs, Carg = lpeg.P, lpeg.R, lpeg.V, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.Carg local lpegmatch = lpeg.match -local concat, format, gmatch = table.concat, string.format, string.gmatch +local concat, format, gmatch, find = table.concat, string.format, string.gmatch, string.find local tostring, type, next = tostring, type, next utilities = utilities or {} @@ -4473,8 +4473,12 @@ local rbrace = P("}") local nobrace = 1 - (lbrace+rbrace) local nested = P { lbrace * (nobrace + V(1))^0 * rbrace } local spaces = space^0 +local argument = Cs((lbrace/"") * ((nobrace + nested)^0) * (rbrace/"")) +local content = (1-P(-1))^0 -lpeg.patterns.nested = nested +lpeg.patterns.nested = nested -- no capture +lpeg.patterns.argument = argument -- argument after e.g. = +lpeg.patterns.content = content -- rest after e.g = local value = P(lbrace * C((nobrace + nested)^0) * rbrace) + C((nested + (1-comma))^0) @@ -4555,9 +4559,15 @@ parsers.patterns.settings_to_array = pattern -- we could use a weak table as cache -function parsers.settings_to_array(str) +function parsers.settings_to_array(str,strict) if not str or str == "" then return { } + elseif strict then + if find(str,"{") then + return lpegmatch(pattern,str) + else + return { str } + end else return lpegmatch(pattern,str) end |