Skip to content

Commit

Permalink
case sensitive literals
Browse files Browse the repository at this point in the history
  • Loading branch information
peldax committed Jun 1, 2021
1 parent cf39706 commit 6ad6c7c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions src/Tokenizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,11 @@ private function createWordToken(\Graphpinator\Common\Location $location) : void
TokenType::SCALAR => new \Graphpinator\Tokenizer\Token(TokenType::SCALAR, $location),
TokenType::IMPLEMENTS => new \Graphpinator\Tokenizer\Token(TokenType::IMPLEMENTS, $location),
TokenType::REPEATABLE => new \Graphpinator\Tokenizer\Token(TokenType::REPEATABLE, $location),
default => match (\strtolower($value)) { // case insensitive
TokenType::NULL => new \Graphpinator\Tokenizer\Token(TokenType::NULL, $location),
TokenType::TRUE => new \Graphpinator\Tokenizer\Token(TokenType::TRUE, $location),
TokenType::FALSE => new \Graphpinator\Tokenizer\Token(TokenType::FALSE, $location),
default => new \Graphpinator\Tokenizer\Token(TokenType::NAME, $location, $value),
},
// literals
TokenType::NULL => new \Graphpinator\Tokenizer\Token(TokenType::NULL, $location),
TokenType::TRUE => new \Graphpinator\Tokenizer\Token(TokenType::TRUE, $location),
TokenType::FALSE => new \Graphpinator\Tokenizer\Token(TokenType::FALSE, $location),
default => new \Graphpinator\Tokenizer\Token(TokenType::NAME, $location, $value),
};
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/TokenizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public function simpleDataProvider() : array
[
'NULL',
[
new \Graphpinator\Tokenizer\Token(TokenType::NULL, new \Graphpinator\Common\Location(1, 1)),
new \Graphpinator\Tokenizer\Token(TokenType::NAME, new \Graphpinator\Common\Location(1, 1), 'NULL'),
],
],
[
Expand Down Expand Up @@ -306,7 +306,7 @@ public function simpleDataProvider() : array
[
'FALSE true',
[
new \Graphpinator\Tokenizer\Token(TokenType::FALSE, new \Graphpinator\Common\Location(1, 1)),
new \Graphpinator\Tokenizer\Token(TokenType::NAME, new \Graphpinator\Common\Location(1, 1), 'FALSE'),
new \Graphpinator\Tokenizer\Token(TokenType::TRUE, new \Graphpinator\Common\Location(1, 7)),
],
],
Expand Down

0 comments on commit 6ad6c7c

Please sign in to comment.