Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/css-selector/Parser/Tokenizer/TokenizerPatterns.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 1fec387a4317 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 /* | |
4 * This file is part of the Symfony package. | |
5 * | |
6 * (c) Fabien Potencier <fabien@symfony.com> | |
7 * | |
8 * For the full copyright and license information, please view the LICENSE | |
9 * file that was distributed with this source code. | |
10 */ | |
11 | |
12 namespace Symfony\Component\CssSelector\Parser\Tokenizer; | |
13 | |
14 /** | |
15 * CSS selector tokenizer patterns builder. | |
16 * | |
17 * This component is a port of the Python cssselect library, | |
18 * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. | |
19 * | |
20 * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com> | |
21 * | |
22 * @internal | |
23 */ | |
24 class TokenizerPatterns | |
25 { | |
26 /** | |
27 * @var string | |
28 */ | |
29 private $unicodeEscapePattern; | |
30 | |
31 /** | |
32 * @var string | |
33 */ | |
34 private $simpleEscapePattern; | |
35 | |
36 /** | |
37 * @var string | |
38 */ | |
39 private $newLineEscapePattern; | |
40 | |
41 /** | |
42 * @var string | |
43 */ | |
44 private $escapePattern; | |
45 | |
46 /** | |
47 * @var string | |
48 */ | |
49 private $stringEscapePattern; | |
50 | |
51 /** | |
52 * @var string | |
53 */ | |
54 private $nonAsciiPattern; | |
55 | |
56 /** | |
57 * @var string | |
58 */ | |
59 private $nmCharPattern; | |
60 | |
61 /** | |
62 * @var string | |
63 */ | |
64 private $nmStartPattern; | |
65 | |
66 /** | |
67 * @var string | |
68 */ | |
69 private $identifierPattern; | |
70 | |
71 /** | |
72 * @var string | |
73 */ | |
74 private $hashPattern; | |
75 | |
76 /** | |
77 * @var string | |
78 */ | |
79 private $numberPattern; | |
80 | |
81 /** | |
82 * @var string | |
83 */ | |
84 private $quotedStringPattern; | |
85 | |
86 /** | |
87 * Constructor. | |
88 */ | |
89 public function __construct() | |
90 { | |
91 $this->unicodeEscapePattern = '\\\\([0-9a-f]{1,6})(?:\r\n|[ \n\r\t\f])?'; | |
92 $this->simpleEscapePattern = '\\\\(.)'; | |
93 $this->newLineEscapePattern = '\\\\(?:\n|\r\n|\r|\f)'; | |
94 $this->escapePattern = $this->unicodeEscapePattern.'|\\\\[^\n\r\f0-9a-f]'; | |
95 $this->stringEscapePattern = $this->newLineEscapePattern.'|'.$this->escapePattern; | |
96 $this->nonAsciiPattern = '[^\x00-\x7F]'; | |
97 $this->nmCharPattern = '[_a-z0-9-]|'.$this->escapePattern.'|'.$this->nonAsciiPattern; | |
98 $this->nmStartPattern = '[_a-z]|'.$this->escapePattern.'|'.$this->nonAsciiPattern; | |
99 $this->identifierPattern = '(?:'.$this->nmStartPattern.')(?:'.$this->nmCharPattern.')*'; | |
100 $this->hashPattern = '#((?:'.$this->nmCharPattern.')+)'; | |
101 $this->numberPattern = '[+-]?(?:[0-9]*\.[0-9]+|[0-9]+)'; | |
102 $this->quotedStringPattern = '([^\n\r\f%s]|'.$this->stringEscapePattern.')*'; | |
103 } | |
104 | |
105 /** | |
106 * @return string | |
107 */ | |
108 public function getNewLineEscapePattern() | |
109 { | |
110 return '~^'.$this->newLineEscapePattern.'~'; | |
111 } | |
112 | |
113 /** | |
114 * @return string | |
115 */ | |
116 public function getSimpleEscapePattern() | |
117 { | |
118 return '~^'.$this->simpleEscapePattern.'~'; | |
119 } | |
120 | |
121 /** | |
122 * @return string | |
123 */ | |
124 public function getUnicodeEscapePattern() | |
125 { | |
126 return '~^'.$this->unicodeEscapePattern.'~i'; | |
127 } | |
128 | |
129 /** | |
130 * @return string | |
131 */ | |
132 public function getIdentifierPattern() | |
133 { | |
134 return '~^'.$this->identifierPattern.'~i'; | |
135 } | |
136 | |
137 /** | |
138 * @return string | |
139 */ | |
140 public function getHashPattern() | |
141 { | |
142 return '~^'.$this->hashPattern.'~i'; | |
143 } | |
144 | |
145 /** | |
146 * @return string | |
147 */ | |
148 public function getNumberPattern() | |
149 { | |
150 return '~^'.$this->numberPattern.'~'; | |
151 } | |
152 | |
153 /** | |
154 * @param string $quote | |
155 * | |
156 * @return string | |
157 */ | |
158 public function getQuotedStringPattern($quote) | |
159 { | |
160 return '~^'.sprintf($this->quotedStringPattern, $quote).'~i'; | |
161 } | |
162 } |