Skip to content

Commit be4b3a4

Browse files
committed
Don't hide unexpected token error in case of no matches
1 parent eae50a3 commit be4b3a4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/GrammarProcessing/LexicalGrammar.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ public function parseSource(string $source): TokenStream
4242
throw new UnexpectedTokenException("Can't parse source: " . preg_last_error_msg(), null);
4343
}
4444

45-
if ($matches === []) {
46-
return new TokenStream([]);
47-
}
48-
4945
$getLocation = function (int $offset) use ($source): Location {
5046
$precedingText = substr($source, 0, $offset);
5147

@@ -76,6 +72,10 @@ public function parseSource(string $source): TokenStream
7672
);
7773
}
7874

75+
if ($matches === []) {
76+
return new TokenStream([]);
77+
}
78+
7979
if ($this->ignoredTokenSymbols !== []) {
8080
if (count($this->ignoredTokenSymbols) === 1) {
8181
$matches = array_values(

0 commit comments

Comments
 (0)