Skip to content

Commit f52d546

Browse files
committed
CS formatting
1 parent b4e9c9c commit f52d546

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

src/Lexer.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,18 @@ public function __construct()
7474
*/
7575
public function tokenize($input)
7676
{
77-
if ($input === '') {
77+
$tokens = [];
78+
$chars = str_split($input);
79+
80+
if (!$chars) {
7881
goto eof;
7982
}
8083

81-
$chars = str_split($input);
82-
$tokens = [];
83-
8484
consume:
8585

8686
$current = current($chars);
8787

88+
// Terminal condition
8889
if ($current === false) {
8990
goto eof;
9091
}
@@ -193,14 +194,15 @@ public function tokenize($input)
193194

194195
goto consume;
195196

196-
eof: {
197-
$tokens[] = [
198-
'type' => 'eof',
199-
'pos' => strlen($input),
200-
'value' => null
201-
];
202-
return $tokens;
203-
}
197+
eof:
198+
199+
$tokens[] = [
200+
'type' => 'eof',
201+
'pos' => strlen($input),
202+
'value' => null
203+
];
204+
205+
return $tokens;
204206
}
205207

206208
/**
@@ -255,23 +257,20 @@ private function inside(array &$chars, $delim, $type)
255257
$buffer = '';
256258

257259
while ($current !== $delim) {
258-
259260
if ($current === '\\') {
260261
$buffer .= '\\';
261262
$current = next($chars);
262263
}
263-
264264
if ($current === false) {
265+
// Unclosed delimiter
265266
return [
266267
'type' => 'unknown',
267268
'value' => $buffer,
268269
'pos' => $position
269270
];
270271
}
271-
272272
$buffer .= $current;
273273
$current = next($chars);
274-
275274
}
276275

277276
next($chars);

0 commit comments

Comments
 (0)