File tree 4 files changed +32
-10
lines changed
4 files changed +32
-10
lines changed Original file line number Diff line number Diff line change @@ -85,18 +85,18 @@ ConstantExpr
85
85
/ ConstantFetch * ByteHorizontalWs
86
86
87
87
ConstantFloat
88
- = [" - " ] 1 * ByteDecDigit * (" _" 1 * ByteDecDigit ) " ." [1 * ByteDecDigit * (" _" 1 * ByteDecDigit )] [ConstantFloatExp ]
89
- / [" - " ] 1 * ByteDecDigit * (" _" 1 * ByteDecDigit ) ConstantFloatExp
90
- / [" - " ] " ." 1 * ByteDecDigit * (" _" 1 * ByteDecDigit ) [ConstantFloatExp ]
88
+ = [ByteNumberSign ] 1 * ByteDecDigit * (" _" 1 * ByteDecDigit ) " ." [1 * ByteDecDigit * (" _" 1 * ByteDecDigit )] [ConstantFloatExp ]
89
+ / [ByteNumberSign ] 1 * ByteDecDigit * (" _" 1 * ByteDecDigit ) ConstantFloatExp
90
+ / [ByteNumberSign ] " ." 1 * ByteDecDigit * (" _" 1 * ByteDecDigit ) [ConstantFloatExp ]
91
91
92
92
ConstantFloatExp
93
- = " e" [" + " / " - " ] 1 * ByteDecDigit * (" _" 1 * ByteDecDigit )
93
+ = " e" [ByteNumberSign ] 1 * ByteDecDigit * (" _" 1 * ByteDecDigit )
94
94
95
95
ConstantInt
96
- = [" - " ] " 0b" 1 * ByteBinDigit * (" _" 1 * ByteBinDigit )
97
- / [" - " ] " 0o" 1 * ByteOctDigit * (" _" 1 * ByteOctDigit )
98
- / [" - " ] " 0x" 1 * ByteHexDigit * (" _" 1 * ByteHexDigit )
99
- / [" - " ] 1 * ByteDecDigit * (" _" 1 * ByteDecDigit )
96
+ = [ByteNumberSign ] " 0b" 1 * ByteBinDigit * (" _" 1 * ByteBinDigit )
97
+ / [ByteNumberSign ] " 0o" 1 * ByteOctDigit * (" _" 1 * ByteOctDigit )
98
+ / [ByteNumberSign ] " 0x" 1 * ByteHexDigit * (" _" 1 * ByteHexDigit )
99
+ / [ByteNumberSign ] 1 * ByteDecDigit * (" _" 1 * ByteDecDigit )
100
100
101
101
ConstantTrue
102
102
= " true"
@@ -213,6 +213,10 @@ ByteHorizontalWs
213
213
= %x 09 ; horizontal tab
214
214
/ %x 20 ; space
215
215
216
+ ByteNumberSign
217
+ = " +"
218
+ / " -"
219
+
216
220
ByteBinDigit
217
221
= %x 30 -31 ; 0-1
218
222
Original file line number Diff line number Diff line change @@ -160,8 +160,8 @@ private function generateRegexp(): string
160
160
self ::TOKEN_PHPDOC_TAG => '@(?:[a-z][a-z0-9- \\\\]+:)?[a-z][a-z0-9- \\\\]*+ ' ,
161
161
self ::TOKEN_PHPDOC_EOL => '\\r?+ \\n[ \\x09 \\x20]*+(?: \\*(?!/) \\x20?+)? ' ,
162
162
163
- self ::TOKEN_FLOAT => '(?:-? [0-9]++(_[0-9]++)* \\.[0-9]*+(_[0-9]++)*(?:e[+-]?[0-9]++(_[0-9]++)*)?)|(?:-? [0-9]*+(_[0-9]++)* \\.[0-9]++(_[0-9]++)*(?:e[+-]?[0-9]++(_[0-9]++)*)?)|(?:-? [0-9]++(_[0-9]++)*e[+-]?[0-9]++(_[0-9]++)*) ' ,
164
- self ::TOKEN_INTEGER => '- ?(?:(?:0b[0-1]++(_[0-1]++)*)|(?:0o[0-7]++(_[0-7]++)*)|(?:0x[0-9a-f]++(_[0-9a-f]++)*)|(?:[0-9]++(_[0-9]++)*)) ' ,
163
+ self ::TOKEN_FLOAT => '[+\-]? (?:(?: [0-9]++(_[0-9]++)* \\.[0-9]*+(_[0-9]++)*(?:e[+\ -]?[0-9]++(_[0-9]++)*)?)|(?:[0-9]*+(_[0-9]++)* \\.[0-9]++(_[0-9]++)*(?:e[+\ -]?[0-9]++(_[0-9]++)*)?)|(?:[0-9]++(_[0-9]++)*e[+\ -]?[0-9]++(_[0-9]++)*) ) ' ,
164
+ self ::TOKEN_INTEGER => '[+\-] ?(?:(?:0b[0-1]++(_[0-1]++)*)|(?:0o[0-7]++(_[0-7]++)*)|(?:0x[0-9a-f]++(_[0-9a-f]++)*)|(?:[0-9]++(_[0-9]++)*)) ' ,
165
165
self ::TOKEN_SINGLE_QUOTED_STRING => '\'(?: \\\\[^ \\r \\n]|[^ \'\\r \\n \\\\])*+ \'' ,
166
166
self ::TOKEN_DOUBLE_QUOTED_STRING => '"(?: \\\\[^ \\r \\n]|[^" \\r \\n \\\\])*+" ' ,
167
167
Original file line number Diff line number Diff line change @@ -152,6 +152,11 @@ public function provideIntegerNodeParseData(): Iterator
152
152
new ConstExprIntegerNode ('123 ' ),
153
153
];
154
154
155
+ yield [
156
+ '+123 ' ,
157
+ new ConstExprIntegerNode ('+123 ' ),
158
+ ];
159
+
155
160
yield [
156
161
'-123 ' ,
157
162
new ConstExprIntegerNode ('-123 ' ),
@@ -236,6 +241,11 @@ public function provideFloatNodeParseData(): Iterator
236
241
new ConstExprFloatNode ('12.3e4 ' ),
237
242
];
238
243
244
+ yield [
245
+ '+123.5 ' ,
246
+ new ConstExprFloatNode ('+123.5 ' ),
247
+ ];
248
+
239
249
yield [
240
250
'-123. ' ,
241
251
new ConstExprFloatNode ('-123. ' ),
Original file line number Diff line number Diff line change @@ -1095,6 +1095,14 @@ public function provideParseData(): array
1095
1095
'123_456.789_012 ' ,
1096
1096
new ConstTypeNode (new ConstExprFloatNode ('123456.789012 ' )),
1097
1097
],
1098
+ [
1099
+ '+0x10_20|+8e+2 | -0b11 ' ,
1100
+ new UnionTypeNode ([
1101
+ new ConstTypeNode (new ConstExprIntegerNode ('+0x1020 ' )),
1102
+ new ConstTypeNode (new ConstExprFloatNode ('+8e+2 ' )),
1103
+ new ConstTypeNode (new ConstExprIntegerNode ('-0b11 ' )),
1104
+ ]),
1105
+ ],
1098
1106
[
1099
1107
'18_446_744_073_709_551_616|8.2023437675747321e-18_446_744_073_709_551_617 ' ,
1100
1108
new UnionTypeNode ([
You can’t perform that action at this time.
0 commit comments