Skip to content

Commit 54a4fc4

Browse files
committed
Hyphen in names
1 parent 9e5c60c commit 54a4fc4

File tree

4 files changed

+68
-1
lines changed

4 files changed

+68
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
- Order of array elements in result corresponds to order of indexes in filter.
1010
- Order of object properties in result corresponds to order of properties in filter.
1111
- Slices with negative steps are returned in reversed order.
12+
- Names now allow hyphen symbol (`U+002D`) as non-starting symbol.
1213

1314
## [0.7.1] - 2019-02-17
1415
### Added

generated/TokenMatcher.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,10 @@ public function match(CharBufferInterface $buffer, TokenFactoryInterface $tokenF
262262
$context->getBuffer()->nextSymbol();
263263
goto state38;
264264
}
265+
if (0x2D == $char) {
266+
$context->getBuffer()->nextSymbol();
267+
goto state38;
268+
}
265269
if (0x6E == $char) {
266270
$context->getBuffer()->nextSymbol();
267271
goto state38;
@@ -336,6 +340,10 @@ public function match(CharBufferInterface $buffer, TokenFactoryInterface $tokenF
336340
$context->getBuffer()->nextSymbol();
337341
goto state38;
338342
}
343+
if (0x2D == $char) {
344+
$context->getBuffer()->nextSymbol();
345+
goto state38;
346+
}
339347
if (0x6E == $char) {
340348
$context->getBuffer()->nextSymbol();
341349
goto state38;
@@ -410,6 +418,10 @@ public function match(CharBufferInterface $buffer, TokenFactoryInterface $tokenF
410418
$context->getBuffer()->nextSymbol();
411419
goto state38;
412420
}
421+
if (0x2D == $char) {
422+
$context->getBuffer()->nextSymbol();
423+
goto state38;
424+
}
413425
if (0x6E == $char) {
414426
$context->getBuffer()->nextSymbol();
415427
goto state38;
@@ -484,6 +496,10 @@ public function match(CharBufferInterface $buffer, TokenFactoryInterface $tokenF
484496
$context->getBuffer()->nextSymbol();
485497
goto state38;
486498
}
499+
if (0x2D == $char) {
500+
$context->getBuffer()->nextSymbol();
501+
goto state38;
502+
}
487503
if (0x6E == $char) {
488504
$context->getBuffer()->nextSymbol();
489505
goto state38;
@@ -667,6 +683,10 @@ public function match(CharBufferInterface $buffer, TokenFactoryInterface $tokenF
667683
$context->getBuffer()->nextSymbol();
668684
goto state38;
669685
}
686+
if (0x2D == $char) {
687+
$context->getBuffer()->nextSymbol();
688+
goto state38;
689+
}
670690
if (0x6E == $char) {
671691
$context->getBuffer()->nextSymbol();
672692
goto state38;
@@ -741,6 +761,10 @@ public function match(CharBufferInterface $buffer, TokenFactoryInterface $tokenF
741761
$context->getBuffer()->nextSymbol();
742762
goto state38;
743763
}
764+
if (0x2D == $char) {
765+
$context->getBuffer()->nextSymbol();
766+
goto state38;
767+
}
744768
if (0x6E == $char) {
745769
$context->getBuffer()->nextSymbol();
746770
goto state38;
@@ -815,6 +839,10 @@ public function match(CharBufferInterface $buffer, TokenFactoryInterface $tokenF
815839
$context->getBuffer()->nextSymbol();
816840
goto state38;
817841
}
842+
if (0x2D == $char) {
843+
$context->getBuffer()->nextSymbol();
844+
goto state38;
845+
}
818846
if (0x6E == $char) {
819847
$context->getBuffer()->nextSymbol();
820848
goto state38;
@@ -889,6 +917,10 @@ public function match(CharBufferInterface $buffer, TokenFactoryInterface $tokenF
889917
$context->getBuffer()->nextSymbol();
890918
goto state38;
891919
}
920+
if (0x2D == $char) {
921+
$context->getBuffer()->nextSymbol();
922+
goto state38;
923+
}
892924
if (0x6E == $char) {
893925
$context->getBuffer()->nextSymbol();
894926
goto state38;
@@ -963,6 +995,10 @@ public function match(CharBufferInterface $buffer, TokenFactoryInterface $tokenF
963995
$context->getBuffer()->nextSymbol();
964996
goto state38;
965997
}
998+
if (0x2D == $char) {
999+
$context->getBuffer()->nextSymbol();
1000+
goto state38;
1001+
}
9661002
if (0x6E == $char) {
9671003
$context->getBuffer()->nextSymbol();
9681004
goto state38;
@@ -1035,6 +1071,10 @@ public function match(CharBufferInterface $buffer, TokenFactoryInterface $tokenF
10351071
$context->getBuffer()->nextSymbol();
10361072
goto state38;
10371073
}
1074+
if (0x2D == $char) {
1075+
$context->getBuffer()->nextSymbol();
1076+
goto state38;
1077+
}
10381078
if (0x6E == $char) {
10391079
$context->getBuffer()->nextSymbol();
10401080
goto state38;
@@ -1109,6 +1149,10 @@ public function match(CharBufferInterface $buffer, TokenFactoryInterface $tokenF
11091149
$context->getBuffer()->nextSymbol();
11101150
goto state38;
11111151
}
1152+
if (0x2D == $char) {
1153+
$context->getBuffer()->nextSymbol();
1154+
goto state38;
1155+
}
11121156
if (0x6E == $char) {
11131157
$context->getBuffer()->nextSymbol();
11141158
goto state38;
@@ -1183,6 +1227,10 @@ public function match(CharBufferInterface $buffer, TokenFactoryInterface $tokenF
11831227
$context->getBuffer()->nextSymbol();
11841228
goto state38;
11851229
}
1230+
if (0x2D == $char) {
1231+
$context->getBuffer()->nextSymbol();
1232+
goto state38;
1233+
}
11861234
if (0x6E == $char) {
11871235
$context->getBuffer()->nextSymbol();
11881236
goto state38;
@@ -1255,6 +1303,10 @@ public function match(CharBufferInterface $buffer, TokenFactoryInterface $tokenF
12551303
$context->getBuffer()->nextSymbol();
12561304
goto state38;
12571305
}
1306+
if (0x2D == $char) {
1307+
$context->getBuffer()->nextSymbol();
1308+
goto state38;
1309+
}
12581310
if (0x6E == $char) {
12591311
$context->getBuffer()->nextSymbol();
12601312
goto state38;
@@ -1329,6 +1381,10 @@ public function match(CharBufferInterface $buffer, TokenFactoryInterface $tokenF
13291381
$context->getBuffer()->nextSymbol();
13301382
goto state38;
13311383
}
1384+
if (0x2D == $char) {
1385+
$context->getBuffer()->nextSymbol();
1386+
goto state38;
1387+
}
13321388
if (0x6E == $char) {
13331389
$context->getBuffer()->nextSymbol();
13341390
goto state38;
@@ -1403,6 +1459,10 @@ public function match(CharBufferInterface $buffer, TokenFactoryInterface $tokenF
14031459
$context->getBuffer()->nextSymbol();
14041460
goto state38;
14051461
}
1462+
if (0x2D == $char) {
1463+
$context->getBuffer()->nextSymbol();
1464+
goto state38;
1465+
}
14061466
if (0x6E == $char) {
14071467
$context->getBuffer()->nextSymbol();
14081468
goto state38;

spec/LexerSpec.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
$context->setNewToken(TokenType::FALSE);
8787

8888
/**
89-
* @lexToken /[a-zA-Z_][a-zA-Z_\$@0-9]*()/
89+
* @lexToken /[a-zA-Z_][a-zA-Z_\$\-@0-9]*()/
9090
*/
9191
$context
9292
->setNewToken(TokenType::NAME)

tests/Parser/TranslationSchemeTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ public function providerParser(): array
114114
['true'],
115115
true,
116116
],
117+
'Dot-notation property with dash' => [
118+
(object) ['a-b' => true],
119+
'$.a-b',
120+
['true'],
121+
true,
122+
],
117123
'Dot-notation predicate' => [
118124
[1, 2, [3]],
119125
'$.[0]',

0 commit comments

Comments
 (0)