1 | <?php |
||
19 | abstract class Lexer implements LexerInterface |
||
20 | { |
||
21 | /** |
||
22 | * @var array|string[] |
||
23 | */ |
||
24 | protected $skipped = []; |
||
25 | |||
26 | /** |
||
27 | * @var array|string[] |
||
28 | */ |
||
29 | protected $tokens = []; |
||
30 | |||
31 | /** |
||
32 | 17 | * @param Readable $input |
|
33 | * @return \Traversable|TokenInterface[] |
||
34 | 17 | */ |
|
35 | public function lex(Readable $input): \Traversable |
||
43 | |||
44 | /** |
||
45 | * @param string $token |
||
46 | 17 | * @param string $pcre |
|
47 | * @return LexerInterface |
||
48 | 17 | */ |
|
49 | 17 | public function add(string $token, string $pcre): LexerInterface |
|
55 | |||
56 | /** |
||
57 | * @param string $name |
||
58 | * @return LexerInterface |
||
59 | 2 | */ |
|
60 | public function skip(string $name): LexerInterface |
||
66 | |||
67 | /** |
||
68 | * @param Readable $file |
||
69 | * @return \Traversable|TokenInterface[] |
||
70 | */ |
||
71 | abstract protected function exec(Readable $file): \Traversable; |
||
72 | } |
||
73 |