1: <?php
2: class Horde_Date_Parser_Locale_Base_Separator
3: {
4: public $commaScanner = array(
5: '/^,$/' => 'comma',
6: );
7:
8: public $slashOrDashScanner = array(
9: '/^-$/' => 'dash',
10: '/^\/$/' => 'slash',
11: );
12:
13: public $atScanner = array(
14: '/^(at|@)$/' => 'at',
15: );
16:
17: public $inScanner = array(
18: '/^in$/' => 'in',
19: );
20:
21: public function scan($tokens)
22: {
23: foreach ($tokens as &$token) {
24: if ($t = $this->scanForCommas($token)) {
25: $token->tag('separator_comma', $t);
26: } elseif ($t = $this->scanForSlashOrDash($token)) {
27: $token->tag('separator_slash_or_dash', $t);
28: } elseif ($t = $this->scanForAt($token)) {
29: $token->tag('separator_at', $t);
30: } elseif ($t = $this->scanForIn($token)) {
31: $token->tag('separator_in', $t);
32: }
33: }
34: return $tokens;
35: }
36:
37: public function scanForCommas($token)
38: {
39: foreach ($this->commaScanner as $scannerItem => $scannerTag) {
40: if (preg_match($scannerItem, $token->word)) {
41: return $scannerTag;
42: }
43: }
44: }
45:
46: public function scanForSlashOrDash($token)
47: {
48: foreach ($this->slashOrDashScanner as $scannerItem => $scannerTag) {
49: if (preg_match($scannerItem, $token->word)) {
50: return $scannerTag;
51: }
52: }
53: }
54:
55: public function scanForAt($token)
56: {
57: foreach ($this->atScanner as $scannerItem => $scannerTag) {
58: if (preg_match($scannerItem, $token->word)) {
59: return $scannerTag;
60: }
61: }
62: }
63:
64: public function scanForIn($token)
65: {
66: foreach ($this->inScanner as $scannerItem => $scannerTag) {
67: if (preg_match($scannerItem, $token->word)) {
68: return $scannerTag;
69: }
70: }
71: }
72:
73: }
74: