From 5c50596feec805177512475bec24b1abea0183df Mon Sep 17 00:00:00 2001 From: Mauro Iazzi Date: Wed, 8 Apr 2009 21:05:09 +0200 Subject: [PATCH] changed some named captures --- mime.lua | 12 +++++------- test.lua | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/mime.lua b/mime.lua index c26f373..c3daa26 100644 --- a/mime.lua +++ b/mime.lua @@ -201,11 +201,10 @@ local lex_tokens = function () } end -local show = function(t) for k, v in next,t do print(k,v)end end +local show = my.show local deb = function(...) for i=1,select('#',...) do local v=select(i,...)print(type(v), v)end end -local date_time = function (format) - format = format or join +local date_time = function () setfenv(1, lpeg) return { -- date and time specification @@ -213,7 +212,7 @@ local date_time = function (format) -- this grammar does not enforce this yet ["date-time"] = Cs(( V"day-of-week" * P"," )^-1 * V"date" * V"FWS" * V"time" * V"CFWS"^-1), -- RFC 2822 Section 3.3 ["day-of-week"] = ( V"FWS"^-1 * V"day-name" ) + V"obs-day-of-week", -- RFC 2822 Section 3.3 - ["day-name"] = P"Mon" + P"Tue" + P"Wed" + P"Thu" + P"Fri" + P"Sat" + P"Sun", -- RFC 2822 Section 3.3 + ["day-name"] = Cg(P"Mon" + P"Tue" + P"Wed" + P"Thu" + P"Fri" + P"Sat" + P"Sun", "weekday"), -- RFC 2822 Section 3.3 ["date"] = V"day" * V"month" * V"year", -- RFC 2822 Section 3.3 ["year"] = Cg(C(V"DIGIT"^4), "year") + V"obs-year", -- RFC 2822 Section 3.3 ["month"] = (V"FWS" * V"month-name" * V"FWS") + V"obs-month", -- RFC 2822 Section 3.3 @@ -224,12 +223,11 @@ local date_time = function (format) ["hour"] = Cg(C(V"DIGIT" * V"DIGIT"), "hour") + V"obs-hour", -- RFC 2822 Section 3.3 ["minute"] = Cg((V"DIGIT" * V"DIGIT"), "minute") + V"obs-minute", -- RFC 2822 Section 3.3 ["second"] = Cg((V"DIGIT" * V"DIGIT"), "second") + V"obs-second", -- RFC 2822 Section 3.3 - ["zone"] = ( (P"+" + P"-") * V"DIGIT" * V"DIGIT" * V"DIGIT" * V"DIGIT" ) + V"obs-zone", -- RFC 2822 Section 3.3 + ["zone"] = Cg( (P"+" + P"-") * V"DIGIT" * V"DIGIT" * V"DIGIT" * V"DIGIT", "zone" ) + V"obs-zone", -- RFC 2822 Section 3.3 } end -local address = function (format) - format = format or join +local address = function () setfenv(1, lpeg) return { -- address specification diff --git a/test.lua b/test.lua index fc255e4..e96b945 100644 --- a/test.lua +++ b/test.lua @@ -38,7 +38,7 @@ end for i, t in ipairs(tests) do local s, r, m, c = t.string, t.rule, t.match, t.capture - gr[1] = lpeg.V(r) / gather * lpeg.Cp() + gr[1] = (lpeg.V(r)) / gather * lpeg.Cp() local patt = lpeg.P(gr) print('performing test ' .. i .. ' on rule ' .. r) local ret, n = dee(patt:match(s)) -- 2.11.4.GIT