Conditions | 6 |
Paths | 4 |
Total Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
28 | protected function parse(string $string, int $lineNumber, string $filename): array |
||
29 | { |
||
30 | $i = 0; |
||
31 | $length = \mb_strlen($string); |
||
32 | $buffer = ''; |
||
33 | $tokens = []; |
||
34 | |||
35 | while ($i < $length) { |
||
36 | if (Utils::isSymChar($string[$i])) { |
||
37 | do { |
||
38 | $buffer .= $string[$i++]; |
||
39 | } while ($i < $length && Utils::isSymChar($string[$i])); |
||
40 | |||
41 | $type = \ctype_digit($buffer) ? Token::T_NUMBER : Token::T_NAME; |
||
42 | $tokens[] = new Token($type, $buffer, $lineNumber, $filename); |
||
43 | $buffer = ''; |
||
44 | } else { |
||
45 | $tokens[] = new Token(Token::T_UNKNOWN, $string[$i++], $lineNumber, $filename); |
||
46 | } |
||
47 | } |
||
48 | |||
49 | return $tokens; |
||
50 | } |
||
51 | |||
70 |