Skip to content

Commit 6ad6c7c

Browse files
committed
case sensitive literals
1 parent cf39706 commit 6ad6c7c

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

src/Tokenizer.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,11 @@ private function createWordToken(\Graphpinator\Common\Location $location) : void
199199
TokenType::SCALAR => new \Graphpinator\Tokenizer\Token(TokenType::SCALAR, $location),
200200
TokenType::IMPLEMENTS => new \Graphpinator\Tokenizer\Token(TokenType::IMPLEMENTS, $location),
201201
TokenType::REPEATABLE => new \Graphpinator\Tokenizer\Token(TokenType::REPEATABLE, $location),
202-
default => match (\strtolower($value)) { // case insensitive
203-
TokenType::NULL => new \Graphpinator\Tokenizer\Token(TokenType::NULL, $location),
204-
TokenType::TRUE => new \Graphpinator\Tokenizer\Token(TokenType::TRUE, $location),
205-
TokenType::FALSE => new \Graphpinator\Tokenizer\Token(TokenType::FALSE, $location),
206-
default => new \Graphpinator\Tokenizer\Token(TokenType::NAME, $location, $value),
207-
},
202+
// literals
203+
TokenType::NULL => new \Graphpinator\Tokenizer\Token(TokenType::NULL, $location),
204+
TokenType::TRUE => new \Graphpinator\Tokenizer\Token(TokenType::TRUE, $location),
205+
TokenType::FALSE => new \Graphpinator\Tokenizer\Token(TokenType::FALSE, $location),
206+
default => new \Graphpinator\Tokenizer\Token(TokenType::NAME, $location, $value),
208207
};
209208
}
210209

tests/Unit/TokenizerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public function simpleDataProvider() : array
276276
[
277277
'NULL',
278278
[
279-
new \Graphpinator\Tokenizer\Token(TokenType::NULL, new \Graphpinator\Common\Location(1, 1)),
279+
new \Graphpinator\Tokenizer\Token(TokenType::NAME, new \Graphpinator\Common\Location(1, 1), 'NULL'),
280280
],
281281
],
282282
[
@@ -306,7 +306,7 @@ public function simpleDataProvider() : array
306306
[
307307
'FALSE true',
308308
[
309-
new \Graphpinator\Tokenizer\Token(TokenType::FALSE, new \Graphpinator\Common\Location(1, 1)),
309+
new \Graphpinator\Tokenizer\Token(TokenType::NAME, new \Graphpinator\Common\Location(1, 1), 'FALSE'),
310310
new \Graphpinator\Tokenizer\Token(TokenType::TRUE, new \Graphpinator\Common\Location(1, 7)),
311311
],
312312
],

0 commit comments

Comments
 (0)