Support strtotime strings for date search

This commit is contained in:
Frederic Guillot
2016-05-25 21:00:01 -04:00
parent 774734a820
commit 74a84a28e3
4 changed files with 112 additions and 9 deletions

View File

@@ -26,9 +26,10 @@ class Lexer
*/
private $tokenMap = array(
"/^(\s+)/" => 'T_WHITESPACE',
'/^([<=>]{0,2}[0-9]{4}-[0-9]{2}-[0-9]{2})/' => 'T_DATE',
'/^(yesterday|tomorrow|today)/' => 'T_DATE',
'/^("(.*?)")/' => 'T_STRING',
'/^([<=>]{0,2}[0-9]{4}-[0-9]{2}-[0-9]{2})/' => 'T_STRING',
'/^([<=>]{1,2}\w+)/' => 'T_STRING',
'/^([<=>]{1,2}".+")/' => 'T_STRING',
'/^("(.+)")/' => 'T_STRING',
"/^(\w+)/" => 'T_STRING',
"/^(#\d+)/" => 'T_STRING',
);
@@ -107,7 +108,7 @@ class Lexer
$this->offset += strlen($matches[1]);
return array(
'match' => trim($matches[1], '"'),
'match' => str_replace('"', '', $matches[1]),
'token' => $name,
);
}
@@ -134,7 +135,7 @@ class Lexer
} else {
$next = next($tokens);
if ($next !== false && in_array($next['token'], array('T_STRING', 'T_DATE'))) {
if ($next !== false && $next['token'] === 'T_STRING') {
$map[$token['token']][] = $next['match'];
}
}