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