1 | <?php |
||
9 | class Lexer implements LexerInterface |
||
10 | { |
||
11 | /** @var callable[] */ |
||
12 | private $postFunctions = []; |
||
13 | |||
14 | /** @var LexerTokenFactory */ |
||
15 | private $lexerTokenFactory; |
||
16 | |||
17 | 18 | public function __construct() |
|
21 | |||
22 | /** |
||
23 | * @param callable $postFunction |
||
24 | * @return $this |
||
25 | */ |
||
26 | 9 | public function registerPostFunction(callable $postFunction) |
|
31 | |||
32 | /** |
||
33 | * @param TokenMap $tokenMap |
||
34 | * @return string |
||
35 | */ |
||
36 | 18 | protected function buildRegex(TokenMap $tokenMap) |
|
47 | |||
48 | /** |
||
49 | * @param string $token |
||
50 | * @param string $match |
||
51 | * @return string |
||
52 | */ |
||
53 | 18 | protected function applyPostFunctions($token, $match) |
|
61 | |||
62 | /** |
||
63 | * @param string $conditionString |
||
64 | * @param string $regex |
||
65 | * @return \Traversable <LexerToken> |
||
66 | * @throws LexerException |
||
67 | */ |
||
68 | 18 | protected function getTokenStreamWithRegex($conditionString, $regex) |
|
83 | |||
84 | /** |
||
85 | * @param string $conditionString |
||
86 | * @param TokenMap $tokenMap |
||
87 | * @return \Traversable <string> |
||
88 | */ |
||
89 | 18 | public function getTokenStream($conditionString, TokenMap $tokenMap) { |
|
92 | |||
93 | /** |
||
94 | * @param $matches |
||
95 | * @return array |
||
96 | */ |
||
97 | 18 | protected function extractMatch($matches) |
|
107 | |||
108 | /** |
||
109 | * @param $conditionString |
||
110 | * @param $match |
||
111 | * @param $offSet |
||
112 | * @throws LexerException |
||
113 | */ |
||
114 | 18 | protected function checkMatchOffset($conditionString, $match, $offSet) |
|
124 | } |
||
125 |