Match case-insensitively

Sun, 21 Jun 2009 22:55:34 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Sun, 21 Jun 2009 22:55:34 +0100
changeset 13
f59a3859363e
parent 12
a127265f3257
child 14
f5bbdcb5b148

Match case-insensitively

ndp.lua file | annotate | diff | comparison | revisions
--- a/ndp.lua	Sun Jun 21 22:54:45 2009 +0100
+++ b/ndp.lua	Sun Jun 21 22:55:34 2009 +0100
@@ -110,19 +110,19 @@
 
 function when(str, relative_to)
 	local time = relative_to or os.time();
-	local P = lpeg.P;
+	local P, Pi = lpeg.P, lpeg.Pi;
 	
 	local patterns = 
 	{ 
-		{ P"tomorrow" /
+		{ Pi"tomorrow" /
 			function ()
 				time = time + seconds_in_a.day;
 			end };
-		{ P"next week" /
+		{ Pi"next week" /
 			function ()
 				time = time + seconds_in_a.week;
 			end };
-		{ P"next year" /
+		{ Pi"next year" /
 			function ()
 				time = adjust_time(time, "year", get_time_part(time, "year") + 1);
 			end };
@@ -130,15 +130,15 @@
 			function (year)
 				time = adjust_time(time, "year", tonumber(year));
 			end };
-		{ P"in "^0 * month_name /
+		{ Pi"in "^0 * month_name /
 			function (month_name)
 				time = find_next_month_by_name(time, month_name:match("%S+$"));
 			end };
-		{ P"on "^0 * day_name /
+		{ Pi"on "^0 * day_name /
 			function (day_name)
 				time = find_next_day_by_name(time, day_name:match("%S+$"));
 			end };
-		{ P"in "^0 * ( quantity * P" " * unit_of_time ) * (P"s"^-1) /
+		{ Pi"in "^0 * ( quantity * P" " * unit_of_time ) * (P"s"^-1) /
 			function (number_and_unit)
 				local number, unit = number_and_unit:gsub("^in ", ""):match("^(.+)%s+(.-)s?$");
 				

mercurial