Skip to content

Commit e678017

Browse files
committed
TASK: Move Scanner::isEnd into $lookAhead->type() and make it nullable
1 parent ac90fc2 commit e678017

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

src/Parser/Ast/ExpressionNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static function fromTokens(\Iterator &$tokens, Precedence $precedence = P
6363
$lookAhead->shift();
6464

6565
while (true) {
66-
switch (Scanner::isEnd($lookAhead->tokens) ?: $lookAhead->type()) {
66+
switch ($lookAhead->type()) {
6767
case TokenType::STRING:
6868
case TokenType::COLON:
6969
case TokenType::COMMA:

src/Parser/Tokenizer/LookAhead.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,11 @@ public function shift(): void
7070
Scanner::skipOne($this->tokens);
7171
}
7272

73-
public function type(): TokenType
73+
public function type(): ?TokenType
7474
{
75+
if (Scanner::isEnd($this->tokens)) {
76+
return null;
77+
}
7578
return Scanner::type($this->tokens);
7679
}
7780
}

0 commit comments

Comments
 (0)