Fix handling of empty input

Fixes #967.
This commit is contained in:
Nikita Popov 2023-12-20 21:51:46 +01:00
parent f82a6365a5
commit f7d484aa0e
2 changed files with 7 additions and 1 deletions

View File

@ -76,7 +76,7 @@ class Lexer {
$numTokens = \count($tokens);
if ($numTokens === 0) {
// Empty input edge case: Just add the sentinel token.
$tokens[] = [new Token(0, "\0", 1, 0)];
$tokens[] = new Token(0, "\0", 1, 0);
return;
}

View File

@ -0,0 +1,6 @@
Empty file
-----
-----
array(
)