Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stevedonovan/Penlight.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Melnichenko <mpeterval@gmail.com>2017-09-27 14:51:23 +0300
committerGitHub <noreply@github.com>2017-09-27 14:51:23 +0300
commit2fb9b303f349955597c229f767d421423eaaf2c8 (patch)
tree810ac495aa08e29d0455b48d11003b727ac14812
parente644b725c57062956d338c0fced6985d851b8fd7 (diff)
parentcbdad3e1dafa253ee9932099eead4e0b5a1d71a1 (diff)
Merge pull request #261 from hishamhm/tabs
Convert tabs to spaces in source code
-rw-r--r--lua/pl/Date.lua4
-rw-r--r--lua/pl/List.lua2
-rw-r--r--lua/pl/Map.lua4
-rw-r--r--lua/pl/dir.lua2
-rw-r--r--lua/pl/import_into.lua108
-rw-r--r--lua/pl/path.lua18
-rw-r--r--lua/pl/pretty.lua8
-rw-r--r--lua/pl/stringx.lua2
-rw-r--r--lua/pl/tablex.lua20
-rw-r--r--lua/pl/text.lua20
-rw-r--r--lua/pl/xml.lua24
-rw-r--r--tests/test-array.lua8
-rw-r--r--tests/test-compat.lua10
-rw-r--r--tests/test-func.lua16
-rw-r--r--tests/test-path.lua4
-rw-r--r--tests/test-sip.lua32
-rw-r--r--tests/test-stringx.lua48
-rw-r--r--tests/test-tablex.lua44
-rw-r--r--tests/test-xml.lua112
19 files changed, 243 insertions, 243 deletions
diff --git a/lua/pl/Date.lua b/lua/pl/Date.lua
index 7a5d1ed..44c4b54 100644
--- a/lua/pl/Date.lua
+++ b/lua/pl/Date.lua
@@ -94,9 +94,9 @@ function Date.tzone (ts)
ts = os_time()
elseif type(ts) == "table" then
if getmetatable(ts) == Date then
- ts = ts.time
+ ts = ts.time
else
- ts = Date(ts).time
+ ts = Date(ts).time
end
end
local utc = os_date('!*t',ts)
diff --git a/lua/pl/List.lua b/lua/pl/List.lua
index 95d8c0e..1af3e53 100644
--- a/lua/pl/List.lua
+++ b/lua/pl/List.lua
@@ -441,7 +441,7 @@ end
-- @return the list.
function List:transform (fun,...)
transform(fun,self,...)
- return self
+ return self
end
--- apply a function to elements of two lists.
diff --git a/lua/pl/Map.lua b/lua/pl/Map.lua
index b4c79ec..0d8b5e2 100644
--- a/lua/pl/Map.lua
+++ b/lua/pl/Map.lua
@@ -51,8 +51,8 @@ end
--- return a List of all key-value pairs, sorted by the keys.
function Map:items()
local ls = makelist(tablex.pairmap (function (k,v) return makelist {k,v} end, self))
- ls:sort(function(t1,t2) return t1[1] < t2[1] end)
- return ls
+ ls:sort(function(t1,t2) return t1[1] < t2[1] end)
+ return ls
end
-- Will return the existing value, or if it doesn't exist it will set
diff --git a/lua/pl/dir.lua b/lua/pl/dir.lua
index 6fc9b12..01b3be8 100644
--- a/lua/pl/dir.lua
+++ b/lua/pl/dir.lua
@@ -209,7 +209,7 @@ local function file_op (is_copy,src,dest,flag)
if path.isdir(dest) then
dest = path.join(dest,path.basename(src))
end
- local ret
+ local ret
if is_copy then ret = CopyFile(src,dest,flag)
else ret = MoveFile(src,dest) end
if ret == 0 then
diff --git a/lua/pl/import_into.lua b/lua/pl/import_into.lua
index 7ef54f8..d6bdac0 100644
--- a/lua/pl/import_into.lua
+++ b/lua/pl/import_into.lua
@@ -17,64 +17,64 @@ return function(env)
mod = {}
env = {}
end
- local env = env or {}
+ local env = env or {}
- local modules = {
- utils = true,path=true,dir=true,tablex=true,stringio=true,sip=true,
- input=true,seq=true,lexer=true,stringx=true,
- config=true,pretty=true,data=true,func=true,text=true,
- operator=true,lapp=true,array2d=true,
- comprehension=true,xml=true,types=true,
- test = true, app = true, file = true, class = true, List = true,
- Map = true, Set = true, OrderedMap = true, MultiMap = true,
- Date = true,
- -- classes --
- }
- rawset(env,'utils',require 'pl.utils')
+ local modules = {
+ utils = true,path=true,dir=true,tablex=true,stringio=true,sip=true,
+ input=true,seq=true,lexer=true,stringx=true,
+ config=true,pretty=true,data=true,func=true,text=true,
+ operator=true,lapp=true,array2d=true,
+ comprehension=true,xml=true,types=true,
+ test = true, app = true, file = true, class = true, List = true,
+ Map = true, Set = true, OrderedMap = true, MultiMap = true,
+ Date = true,
+ -- classes --
+ }
+ rawset(env,'utils',require 'pl.utils')
- for name,klass in pairs(env.utils.stdmt) do
- klass.__index = function(t,key)
- return require ('pl.'..name)[key]
- end;
- end
+ for name,klass in pairs(env.utils.stdmt) do
+ klass.__index = function(t,key)
+ return require ('pl.'..name)[key]
+ end;
+ end
- -- ensure that we play nice with libraries that also attach a metatable
- -- to the global table; always forward to a custom __index if we don't
- -- match
+ -- ensure that we play nice with libraries that also attach a metatable
+ -- to the global table; always forward to a custom __index if we don't
+ -- match
- local _hook,_prev_index
- local gmt = {}
- local prevenvmt = getmetatable(env)
- if prevenvmt then
- _prev_index = prevenvmt.__index
- if prevenvmt.__newindex then
- gmt.__index = prevenvmt.__newindex
- end
- end
+ local _hook,_prev_index
+ local gmt = {}
+ local prevenvmt = getmetatable(env)
+ if prevenvmt then
+ _prev_index = prevenvmt.__index
+ if prevenvmt.__newindex then
+ gmt.__index = prevenvmt.__newindex
+ end
+ end
- function gmt.hook(handler)
- _hook = handler
- end
+ function gmt.hook(handler)
+ _hook = handler
+ end
- function gmt.__index(t,name)
- local found = modules[name]
- -- either true, or the name of the module containing this class.
- -- either way, we load the required module and make it globally available.
- if found then
- -- e..g pretty.dump causes pl.pretty to become available as 'pretty'
- rawset(env,name,require('pl.'..name))
- return env[name]
- else
- local res
- if _hook then
- res = _hook(t,name)
- if res then return res end
- end
- if _prev_index then
- return _prev_index(t,name)
- end
- end
- end
+ function gmt.__index(t,name)
+ local found = modules[name]
+ -- either true, or the name of the module containing this class.
+ -- either way, we load the required module and make it globally available.
+ if found then
+ -- e..g pretty.dump causes pl.pretty to become available as 'pretty'
+ rawset(env,name,require('pl.'..name))
+ return env[name]
+ else
+ local res
+ if _hook then
+ res = _hook(t,name)
+ if res then return res end
+ end
+ if _prev_index then
+ return _prev_index(t,name)
+ end
+ end
+ end
if mod then
function gmt.__newindex(t,name,value)
@@ -83,7 +83,7 @@ return function(env)
end
end
- setmetatable(env,gmt)
+ setmetatable(env,gmt)
- return env,mod or env
+ return env,mod or env
end
diff --git a/lua/pl/path.lua b/lua/pl/path.lua
index 7c2fe31..f8f3d78 100644
--- a/lua/pl/path.lua
+++ b/lua/pl/path.lua
@@ -52,7 +52,7 @@ path.chdir = lfs.chdir
--- is this a directory?
-- @string P A file path
function path.isdir(P)
- assert_string(1,P)
+ assert_string(1,P)
if P:match("\\$") then
P = P:sub(1,-2)
end
@@ -62,14 +62,14 @@ end
--- is this a file?.
-- @string P A file path
function path.isfile(P)
- assert_string(1,P)
+ assert_string(1,P)
return attrib(P,'mode') == 'file'
end
-- is this a symbolic link?
-- @string P A file path
function path.islink(P)
- assert_string(1,P)
+ assert_string(1,P)
if link_attrib then
return link_attrib(P,'mode')=='link'
else
@@ -80,7 +80,7 @@ end
--- return size of a file.
-- @string P A file path
function path.getsize(P)
- assert_string(1,P)
+ assert_string(1,P)
return attrib(P,'size')
end
@@ -88,14 +88,14 @@ end
-- @string P A file path
-- @return the file path if it exists, nil otherwise
function path.exists(P)
- assert_string(1,P)
+ assert_string(1,P)
return attrib(P,'mode') ~= nil and P
end
--- Return the time of last access as the number of seconds since the epoch.
-- @string P A file path
function path.getatime(P)
- assert_string(1,P)
+ assert_string(1,P)
return attrib(P,'access')
end
@@ -108,7 +108,7 @@ end
---Return the system's ctime.
-- @string P A file path
function path.getctime(P)
- assert_string(1,P)
+ assert_string(1,P)
return path.attrib(P,'change')
end
@@ -165,7 +165,7 @@ end
-- @string[opt] pwd optional start path to use (default is current dir)
function path.abspath(P,pwd)
assert_string(1,P)
- if pwd then assert_string(2,pwd) end
+ if pwd then assert_string(2,pwd) end
local use_pwd = pwd ~= nil
if not use_pwd and not currentdir then return P end
P = P:gsub('[\\/]$','')
@@ -338,7 +338,7 @@ end
-- @string[opt] start optional start point (default current directory)
function path.relpath (P,start)
assert_string(1,P)
- if start then assert_string(2,start) end
+ if start then assert_string(2,start) end
local split,normcase,min,append = utils.split, path.normcase, math.min, table.insert
P = normcase(path.abspath(P,start))
start = start or currentdir()
diff --git a/lua/pl/pretty.lua b/lua/pl/pretty.lua
index 9de158d..7365ad3 100644
--- a/lua/pl/pretty.lua
+++ b/lua/pl/pretty.lua
@@ -48,9 +48,9 @@ local function save_global_env()
env.hook, env.mask, env.count = debug.gethook()
-- env.hook is "external hook" if is a C hook function
- if env.hook~="external hook" then
- debug.sethook()
- end
+ if env.hook~="external hook" then
+ debug.sethook()
+ end
env.string_mt = getmetatable("")
debug.setmetatable("", nil)
@@ -164,7 +164,7 @@ local function index (numkey,key)
end
---- Create a string representation of a Lua table.
+--- Create a string representation of a Lua table.
-- This function never fails, but may complain by returning an
-- extra value. Normally puts out one item per line, using
-- the provided indent; set the second parameter to an empty string
diff --git a/lua/pl/stringx.lua b/lua/pl/stringx.lua
index f5a27d4..adf1070 100644
--- a/lua/pl/stringx.lua
+++ b/lua/pl/stringx.lua
@@ -192,7 +192,7 @@ function stringx.split(s,re,n)
if re and re ~= '' and find(s,re,-#re,true) then
res[#res+1] = ""
end
- return makelist(res)
+ return makelist(res)
end
--- replace all tabs in s with tabsize spaces. If not specified, tabsize defaults to 8.
diff --git a/lua/pl/tablex.lua b/lua/pl/tablex.lua
index 03ecba9..008da15 100644
--- a/lua/pl/tablex.lua
+++ b/lua/pl/tablex.lua
@@ -455,7 +455,7 @@ end
-- @func fun a function of n arguments
-- @tab ... n tables
-- @usage mapn(function(x,y,z) return x+y+z end, {1,2,3},{10,20,30},{100,200,300}) is {111,222,333}
--- @usage mapn(math.max, {1,20,300},{10,2,3},{100,200,100}) is {100,200,300}
+-- @usage mapn(math.max, {1,20,300},{10,2,3},{100,200,100}) is {100,200,300}
-- @param fun A function that takes as many arguments as there are tables
function tablex.mapn(fun,...)
fun = function_arg(1,fun)
@@ -493,15 +493,15 @@ function tablex.pairmap(fun,t,...)
for k,v in pairs(t) do
local rv,rk = fun(k,v,...)
if rk then
- if res[rk] then
- if type(res[rk]) == 'table' then
- table.insert(res[rk],rv)
- else
- res[rk] = {res[rk], rv}
- end
- else
- res[rk] = rv
- end
+ if res[rk] then
+ if type(res[rk]) == 'table' then
+ table.insert(res[rk],rv)
+ else
+ res[rk] = {res[rk], rv}
+ end
+ else
+ res[rk] = rv
+ end
else
res[#res+1] = rv
end
diff --git a/lua/pl/text.lua b/lua/pl/text.lua
index 7e0e933..d18fcc0 100644
--- a/lua/pl/text.lua
+++ b/lua/pl/text.lua
@@ -176,21 +176,21 @@ function Template:indent_substitute(tbl)
-- then we split that into lines and adjust the indent before inserting.
local function subst(line)
return line:gsub('(%s*)%$([%w_]+)',function(sp,f)
- local subtmpl
+ local subtmpl
local s = tbl[f]
if not s then error("not present in table "..f) end
- if getmetatable(s) == Template then
- subtmpl = s
- s = s.tmpl
- else
- s = tostring(s)
- end
+ if getmetatable(s) == Template then
+ subtmpl = s
+ s = s.tmpl
+ else
+ s = tostring(s)
+ end
if s:find '\n' then
s = _indent(s,sp)
end
- if subtmpl then return _substitute(s,tbl)
- else return s
- end
+ if subtmpl then return _substitute(s,tbl)
+ else return s
+ end
end)
end
local lines = imap(subst,self.strings)
diff --git a/lua/pl/xml.lua b/lua/pl/xml.lua
index c4382e6..ae26f5e 100644
--- a/lua/pl/xml.lua
+++ b/lua/pl/xml.lua
@@ -519,18 +519,18 @@ function _M.walk (doc, depth_first, operation)
end
local html_empty_elements = { --lists all HTML empty (void) elements
- br = true,
- img = true,
- meta = true,
- frame = true,
- area = true,
- hr = true,
- base = true,
- col = true,
- link = true,
- input = true,
- option = true,
- param = true,
+ br = true,
+ img = true,
+ meta = true,
+ frame = true,
+ area = true,
+ hr = true,
+ base = true,
+ col = true,
+ link = true,
+ input = true,
+ option = true,
+ param = true,
isindex = true,
embed = true,
}
diff --git a/tests/test-array.lua b/tests/test-array.lua
index 9ed5bde..ab8f41e 100644
--- a/tests/test-array.lua
+++ b/tests/test-array.lua
@@ -3,10 +3,10 @@ local asserteq = require('pl.test').asserteq
local L = require 'pl.utils'. string_lambda
local A = {
- {1,2,3,4},
- {10,20,30,40},
- {100,200,300,400},
- {1000,2000,3000,4000},
+ {1,2,3,4},
+ {10,20,30,40},
+ {100,200,300,400},
+ {1000,2000,3000,4000},
}
asserteq(array.column(A,2),{2,20,200,2000})
diff --git a/tests/test-compat.lua b/tests/test-compat.lua
index a52c6d4..af3956c 100644
--- a/tests/test-compat.lua
+++ b/tests/test-compat.lua
@@ -5,11 +5,11 @@ local compat = require "pl.compat"
local coroutine = require "coroutine"
local code_generator = coroutine.wrap(function()
- local result = {"ret", "urn \"Hello World!\""}
- for _,v in ipairs(result) do
- coroutine.yield(v)
- end
- coroutine.yield(nil)
+ local result = {"ret", "urn \"Hello World!\""}
+ for _,v in ipairs(result) do
+ coroutine.yield(v)
+ end
+ coroutine.yield(nil)
end)
local f, err = compat.load(code_generator)
diff --git a/tests/test-func.lua b/tests/test-func.lua
index c8606d0..5d90bbe 100644
--- a/tests/test-func.lua
+++ b/tests/test-func.lua
@@ -11,18 +11,18 @@ function pprint (t)
end
function test (e)
- local v = {}
- print('test',collect_values(e,v))
- if #v > 0 then pprint(v) end
- local rep = repr(e)
+ local v = {}
+ print('test',collect_values(e,v))
+ if #v > 0 then pprint(v) end
+ local rep = repr(e)
print(rep)
end
function teste (e,rs,ve)
- local v = {}
- collect_values(e,v)
- if #v > 0 then asserteq(v,ve,nil,2) end
- local rep = repr(e)
+ local v = {}
+ collect_values(e,v)
+ if #v > 0 then asserteq(v,ve,nil,2) end
+ local rep = repr(e)
asserteq(rep,rs)
end
diff --git a/tests/test-path.lua b/tests/test-path.lua
index 43d9228..56e14cc 100644
--- a/tests/test-path.lua
+++ b/tests/test-path.lua
@@ -2,11 +2,11 @@ local path = require 'pl.path'
asserteq = require 'pl.test'.asserteq
function quote(s)
- return '"'..s..'"'
+ return '"'..s..'"'
end
function print2(s1,s2)
- print(quote(s1),quote(s2))
+ print(quote(s1),quote(s2))
end
function testpath(pth,p1,p2,p3)
diff --git a/tests/test-sip.lua b/tests/test-sip.lua
index ea4c19a..cf4b344 100644
--- a/tests/test-sip.lua
+++ b/tests/test-sip.lua
@@ -52,13 +52,13 @@ check('just a string', 'not that string')
local months={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}
local function adjust_year(res)
- if res.year < 100 then
- if res.year < 70 then
- res.year = res.year + 2000
- else
- res.year = res.year + 1900
- end
- end
+ if res.year < 100 then
+ if res.year < 70 then
+ res.year = res.year + 2000
+ else
+ res.year = res.year + 1900
+ end
+ end
end
local shortdate = sip.compile('$d{day}/$d{month}/$d{year}')
@@ -71,17 +71,17 @@ local function dcheck (d1,d2)
end
local function dates(str,tbl)
- local res = {}
- if shortdate(str,res) then
- dcheck(res,tbl)
+ local res = {}
+ if shortdate(str,res) then
+ dcheck(res,tbl)
elseif isodate(str,res) then
dcheck(res,tbl)
- elseif longdate(str,res) then
- res.month = tablex.find(months,res.month)
- dcheck(res,tbl)
- else
- assert(tbl == nil)
- end
+ elseif longdate(str,res) then
+ res.month = tablex.find(months,res.month)
+ dcheck(res,tbl)
+ else
+ assert(tbl == nil)
+ end
end
dates ('10/12/2007',{year=2007,month=12,day=10})
diff --git a/tests/test-stringx.lua b/tests/test-stringx.lua
index 7802eb4..8ee0f87 100644
--- a/tests/test-stringx.lua
+++ b/tests/test-stringx.lua
@@ -292,30 +292,30 @@ asserteq(stringx.rstrip('--[hello] -- - ','-[] '),'--[hello')
local assert_str_round_trip = function(s)
- local qs = stringx.quote_string(s)
- local compiled, err = utils.load("return "..qs)
-
- if not compiled then
- print(
- ("stringx.quote_string assert failed: invalid string created: Received:\n%s\n\nCompiled to\n%s\n\nError:\t%s\n"):
- format(s, qs, err)
- )
- error()
- else
- compiled = compiled()
- end
-
- if compiled ~= s then
- print("strinx.quote_string assert Failed: String compiled but did not round trip.")
- print("input string:\t\t",s, #s)
- print("compiled string:\t", compiled, #compiled)
- print("output string:\t\t",qs, #qs)
- error()
- else
- -- print("input string:\t\t",s)
- -- print("compiled string:\t", compiled)
- -- print("output string:\t\t",qs)
- end
+ local qs = stringx.quote_string(s)
+ local compiled, err = utils.load("return "..qs)
+
+ if not compiled then
+ print(
+ ("stringx.quote_string assert failed: invalid string created: Received:\n%s\n\nCompiled to\n%s\n\nError:\t%s\n"):
+ format(s, qs, err)
+ )
+ error()
+ else
+ compiled = compiled()
+ end
+
+ if compiled ~= s then
+ print("strinx.quote_string assert Failed: String compiled but did not round trip.")
+ print("input string:\t\t",s, #s)
+ print("compiled string:\t", compiled, #compiled)
+ print("output string:\t\t",qs, #qs)
+ error()
+ else
+ -- print("input string:\t\t",s)
+ -- print("compiled string:\t", compiled)
+ -- print("output string:\t\t",qs)
+ end
end
assert_str_round_trip( "normal string with nothing weird.")
diff --git a/tests/test-tablex.lua b/tests/test-tablex.lua
index 59213d5..db33757 100644
--- a/tests/test-tablex.lua
+++ b/tests/test-tablex.lua
@@ -16,49 +16,49 @@ end
asserteq(
- copy {10,20,30},
- {10,20,30}
+ copy {10,20,30},
+ {10,20,30}
)
asserteq(
- deepcopy {10,20,{30,40}},
- {10,20,{30,40}}
+ deepcopy {10,20,{30,40}},
+ {10,20,{30,40}}
)
asserteq(
- pairmap(function(i,v) return v end,{10,20,30}),
- {10,20,30}
+ pairmap(function(i,v) return v end,{10,20,30}),
+ {10,20,30}
)
asserteq_no_order(
- pairmap(L'_',{fred=10,bonzo=20}),
- {'fred','bonzo'}
+ pairmap(L'_',{fred=10,bonzo=20}),
+ {'fred','bonzo'}
)
asserteq_no_order(
- pairmap(function(k,v) return v end,{fred=10,bonzo=20}),
- {10,20}
+ pairmap(function(k,v) return v end,{fred=10,bonzo=20}),
+ {10,20}
)
asserteq_no_order(
- pairmap(function(i,v) return v,i end,{10,20,30}),
- {10,20,30}
+ pairmap(function(i,v) return v,i end,{10,20,30}),
+ {10,20,30}
)
asserteq(
- pairmap(function(k,v) return {k,v},k end,{one=1,two=2}),
- {one={'one',1},two={'two',2}}
+ pairmap(function(k,v) return {k,v},k end,{one=1,two=2}),
+ {one={'one',1},two={'two',2}}
)
-- same as above, using string lambdas
asserteq(
- pairmap(L'|k,v|{k,v},k',{one=1,two=2}),
- {one={'one',1},two={'two',2}}
+ pairmap(L'|k,v|{k,v},k',{one=1,two=2}),
+ {one={'one',1},two={'two',2}}
)
asserteq(
- map(function(v) return v*v end,{10,20,30}),
- {100,400,900}
+ map(function(v) return v*v end,{10,20,30}),
+ {100,400,900}
)
-- extra arguments to map() are passed to the function; can use
@@ -81,13 +81,13 @@ asserteq(
-- mapn operates over an arbitrary number of input tables (but use map2 for n=2)
asserteq(
- mapn(function(x,y,z) return x+y+z end, {1,2,3},{10,20,30},{100,200,300}),
- {111,222,333}
+ mapn(function(x,y,z) return x+y+z end, {1,2,3},{10,20,30},{100,200,300}),
+ {111,222,333}
)
asserteq(
- mapn(math.max, {1,20,300},{10,2,3},{100,200,100}),
- {100,200,300}
+ mapn(math.max, {1,20,300},{10,2,3},{100,200,100}),
+ {100,200,300}
)
asserteq(
diff --git a/tests/test-xml.lua b/tests/test-xml.lua
index 5e32eab..cd8253a 100644
--- a/tests/test-xml.lua
+++ b/tests/test-xml.lua
@@ -7,11 +7,11 @@ local dump = require 'pl.pretty'.dump
d = xml.new 'top' : addtag 'child' : text 'alice' : up() : addtag 'child' : text 'bob'
d = xml.new 'children' :
- addtag 'child' :
- addtag 'name' : text 'alice' : up() : addtag 'age' : text '5' : up() : addtag('toy',{type='fluffy'}) : up() :
- up() :
- addtag 'child':
- addtag 'name' : text 'bob' : up() : addtag 'age' : text '6' : up() : addtag('toy',{type='squeaky'})
+ addtag 'child' :
+ addtag 'name' : text 'alice' : up() : addtag 'age' : text '5' : up() : addtag('toy',{type='fluffy'}) : up() :
+ up() :
+ addtag 'child':
+ addtag 'name' : text 'bob' : up() : addtag 'age' : text '6' : up() : addtag('toy',{type='squeaky'})
asserteq(
xml.tostring(d,'',' '),
@@ -133,8 +133,8 @@ t1 = [[
match(t1,{
- condition = "Clear",
- temp = "24",
+ condition = "Clear",
+ temp = "24",
} )
t2 = [[
@@ -149,30 +149,30 @@ t2 = [[
]]
local conditions = {
- {
- low = "60",
- high = "89",
- day = "Sat",
- condition = "Clear",
- },
- {
- low = "53",
- high = "86",
- day = "Sun",
- condition = "Clear",
- },
- {
- low = "57",
- high = "87",
- day = "Mon",
- condition = "Clear",
- },
- {
- low = "60",
- high = "84",
- day = "Tue",
- condition = "Clear",
- }
+ {
+ low = "60",
+ high = "89",
+ day = "Sat",
+ condition = "Clear",
+ },
+ {
+ low = "53",
+ high = "86",
+ day = "Sun",
+ condition = "Clear",
+ },
+ {
+ low = "57",
+ high = "87",
+ day = "Mon",
+ condition = "Clear",
+ },
+ {
+ low = "60",
+ high = "84",
+ day = "Tue",
+ condition = "Clear",
+ }
}
match(t2,conditions)
@@ -195,9 +195,9 @@ match([[
{{<key->$value</key->}}
</config>
]],{
- {key="alpha", value = "1.3"},
- {key="beta", value = "10"},
- {key="name",value = "bozo"},
+ {key="alpha", value = "1.3"},
+ {key="beta", value = "10"},
+ {key="name",value = "bozo"},
})
-- can be numerical indices
match([[
@@ -205,9 +205,9 @@ match([[
{{<1->$2</1->}}
</config>
]],{
- {"alpha","1.3"},
- {"beta","10"},
- {"name","bozo"},
+ {"alpha","1.3"},
+ {"beta","10"},
+ {"name","bozo"},
})
-- _ is special; means 'this value is key of captured table'
match([[
@@ -215,9 +215,9 @@ match([[
{{<_->$1</_->}}
</config>
]],{
- alpha = {"1.3"},
- beta = {"10"},
- name = {"bozo"},
+ alpha = {"1.3"},
+ beta = {"10"},
+ name = {"bozo"},
})
-- the numerical index 0 is special: a capture of {[0]=val} becomes simply the value val
@@ -226,9 +226,9 @@ match([[
{{<_->$0</_->}}
</config>
]],{
- alpha = "1.3",
- name = "bozo",
- beta = "10"
+ alpha = "1.3",
+ name = "bozo",
+ beta = "10"
})
-- this can of course also work with attributes, but then we don't want to collapse!
@@ -248,9 +248,9 @@ match([[
{{<_- type='$1'>$2</_->}}
</config>
]],{
- alpha = {"number","1.3"},
- beta = {"number","10"},
- name = {"string","bozo"},
+ alpha = {"number","1.3"},
+ beta = {"number","10"},
+ name = {"string","bozo"},
})
d,err = parse [[
@@ -279,16 +279,16 @@ res,err = d:match [[
]]
asserteq(res,{
- HOST = "windows-unknown-linux-gnu",
- COPYRIGHT = "Copyright (C) 1999-2009 ImageMagick Studio LLC",
- NAME = "ImageMagick",
- LIB_VERSION = "0x651",
- VERSION = "6.5.1",
- RELEASE_DATE = "2009-05-01",
- WEBSITE = "http://www.imagemagick.org",
- LIB_VERSION_NUMBER = "6,5,1,3",
- CC = "vs7",
- DELEGATES = "bzlib freetype jpeg jp2 lcms png tiff x11 xml wmf zlib"
+ HOST = "windows-unknown-linux-gnu",
+ COPYRIGHT = "Copyright (C) 1999-2009 ImageMagick Studio LLC",
+ NAME = "ImageMagick",
+ LIB_VERSION = "0x651",
+ VERSION = "6.5.1",
+ RELEASE_DATE = "2009-05-01",
+ WEBSITE = "http://www.imagemagick.org",
+ LIB_VERSION_NUMBER = "6,5,1,3",
+ CC = "vs7",
+ DELEGATES = "bzlib freetype jpeg jp2 lcms png tiff x11 xml wmf zlib"
})
-- short excerpt from