We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 07c49b0 commit 5aaeb83Copy full SHA for 5aaeb83
src/Lexer/Lexer.php
@@ -105,16 +105,11 @@ public function tokenize(string $s): array
105
assert($this->regexp !== null);
106
assert($this->types !== null);
107
108
- preg_match_all($this->regexp, $s, $tokens, PREG_SET_ORDER);
109
-
110
- $count = count($this->types);
111
- foreach ($tokens as &$match) {
112
- for ($i = 1; $i <= $count; $i++) {
113
- if ($match[$i] !== null && $match[$i] !== '') {
114
- $match = [$match[0], $this->types[$i - 1]];
115
- break;
116
- }
117
+ preg_match_all($this->regexp, $s, $matches, PREG_SET_ORDER);
+
+ $tokens = [];
+ foreach ($matches as $match) {
+ $tokens[] = [$match[0], $this->types[count($match) - 2]];
118
}
119
120
$tokens[] = ['', self::TOKEN_END];
0 commit comments