File tree Expand file tree Collapse file tree 4 files changed +32
-10
lines changed Expand file tree Collapse file tree 4 files changed +32
-10
lines changed Original file line number Diff line number Diff line change @@ -85,18 +85,18 @@ ConstantExpr
8585 / ConstantFetch * ByteHorizontalWs
8686
8787ConstantFloat
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 ]
9191
9292ConstantFloatExp
93- = " e" [" + " / " - " ] 1 * ByteDecDigit * (" _" 1 * ByteDecDigit )
93+ = " e" [ByteNumberSign ] 1 * ByteDecDigit * (" _" 1 * ByteDecDigit )
9494
9595ConstantInt
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 )
100100
101101ConstantTrue
102102 = " true"
@@ -213,6 +213,10 @@ ByteHorizontalWs
213213 = %x 09 ; horizontal tab
214214 / %x 20 ; space
215215
216+ ByteNumberSign
217+ = " +"
218+ / " -"
219+
216220ByteBinDigit
217221 = %x 30 -31 ; 0-1
218222
Original file line number Diff line number Diff line change @@ -160,8 +160,8 @@ private function generateRegexp(): string
160160 self ::TOKEN_PHPDOC_TAG => '@(?:[a-z][a-z0-9- \\\\]+:)?[a-z][a-z0-9- \\\\]*+ ' ,
161161 self ::TOKEN_PHPDOC_EOL => '\\r?+ \\n[ \\x09 \\x20]*+(?: \\*(?!/) \\x20?+)? ' ,
162162
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]++)*)) ' ,
165165 self ::TOKEN_SINGLE_QUOTED_STRING => '\'(?: \\\\[^ \\r \\n]|[^ \'\\r \\n \\\\])*+ \'' ,
166166 self ::TOKEN_DOUBLE_QUOTED_STRING => '"(?: \\\\[^ \\r \\n]|[^" \\r \\n \\\\])*+" ' ,
167167
Original file line number Diff line number Diff line change @@ -152,6 +152,11 @@ public function provideIntegerNodeParseData(): Iterator
152152 new ConstExprIntegerNode ('123 ' ),
153153 ];
154154
155+ yield [
156+ '+123 ' ,
157+ new ConstExprIntegerNode ('+123 ' ),
158+ ];
159+
155160 yield [
156161 '-123 ' ,
157162 new ConstExprIntegerNode ('-123 ' ),
@@ -236,6 +241,11 @@ public function provideFloatNodeParseData(): Iterator
236241 new ConstExprFloatNode ('12.3e4 ' ),
237242 ];
238243
244+ yield [
245+ '+123.5 ' ,
246+ new ConstExprFloatNode ('+123.5 ' ),
247+ ];
248+
239249 yield [
240250 '-123. ' ,
241251 new ConstExprFloatNode ('-123. ' ),
Original file line number Diff line number Diff line change @@ -1095,6 +1095,14 @@ public function provideParseData(): array
10951095 '123_456.789_012 ' ,
10961096 new ConstTypeNode (new ConstExprFloatNode ('123456.789012 ' )),
10971097 ],
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+ ],
10981106 [
10991107 '18_446_744_073_709_551_616|8.2023437675747321e-18_446_744_073_709_551_617 ' ,
11001108 new UnionTypeNode ([
You can’t perform that action at this time.
0 commit comments