This repository was archived by the owner on Mar 29, 2023. It is now read-only.
File tree 8 files changed +756
-33
lines changed
8 files changed +756
-33
lines changed Original file line number Diff line number Diff line change @@ -106,26 +106,13 @@ module.exports = {
106
106
if ( this . token === "@" ) return this . node ( "silent" ) ( this . next ( ) . read_expr ( ) ) ;
107
107
if ( this . token === "+" )
108
108
return this . node ( "unary" ) ( "+" , this . next ( ) . read_expr ( ) ) ;
109
+ if ( this . token === "-" )
110
+ return this . node ( "unary" ) ( "-" , this . next ( ) . read_expr ( ) ) ;
109
111
if ( this . token === "!" )
110
112
return this . node ( "unary" ) ( "!" , this . next ( ) . read_expr ( ) ) ;
111
113
if ( this . token === "~" )
112
114
return this . node ( "unary" ) ( "~" , this . next ( ) . read_expr ( ) ) ;
113
115
114
- if ( this . token === "-" ) {
115
- result = this . node ( ) ;
116
- this . next ( ) ;
117
- if (
118
- this . token === this . tok . T_LNUMBER ||
119
- this . token === this . tok . T_DNUMBER
120
- ) {
121
- // negative number
122
- result = result ( "number" , "-" + this . text ( ) , null ) ;
123
- this . next ( ) ;
124
- return result ;
125
- }
126
- return result ( "unary" , "-" , this . read_expr ( ) ) ;
127
- }
128
-
129
116
if ( this . token === "(" ) {
130
117
expr = this . next ( ) . read_expr ( ) ;
131
118
expr . parenthesizedExpression = true ;
Original file line number Diff line number Diff line change @@ -2735,22 +2735,39 @@ Program {
2735
2735
},
2736
2736
},
2737
2737
" operator" : " =" ,
2738
- " right" : Number {
2739
- " kind" : " number " ,
2738
+ " right" : Unary {
2739
+ " kind" : " unary " ,
2740
2740
" loc" : Location {
2741
2741
" end" : Position {
2742
- " column" : 14 ,
2742
+ " column" : 15 ,
2743
2743
" line" : 82 ,
2744
- " offset" : 1657 ,
2744
+ " offset" : 1658 ,
2745
2745
},
2746
- " source" : " -" ,
2746
+ " source" : " -1 " ,
2747
2747
" start" : Position {
2748
2748
" column" : 13 ,
2749
2749
" line" : 82 ,
2750
2750
" offset" : 1656 ,
2751
2751
},
2752
2752
},
2753
- " value" : " -1" ,
2753
+ " type" : " -" ,
2754
+ " what" : Number {
2755
+ " kind" : " number" ,
2756
+ " loc" : Location {
2757
+ " end" : Position {
2758
+ " column" : 15 ,
2759
+ " line" : 82 ,
2760
+ " offset" : 1658 ,
2761
+ },
2762
+ " source" : " 1" ,
2763
+ " start" : Position {
2764
+ " column" : 14 ,
2765
+ " line" : 82 ,
2766
+ " offset" : 1657 ,
2767
+ },
2768
+ },
2769
+ " value" : " 1" ,
2770
+ },
2754
2771
},
2755
2772
},
2756
2773
" kind" : " expressionstatement" ,
Original file line number Diff line number Diff line change @@ -232,9 +232,13 @@ Program {
232
232
ExpressionStatement {
233
233
" expression" : Exit {
234
234
" kind" : " exit" ,
235
- " status" : Number {
236
- " kind" : " number" ,
237
- " value" : " -1" ,
235
+ " status" : Unary {
236
+ " kind" : " unary" ,
237
+ " type" : " -" ,
238
+ " what" : Number {
239
+ " kind" : " number" ,
240
+ " value" : " 1" ,
241
+ },
238
242
},
239
243
" useDie" : false ,
240
244
},
Original file line number Diff line number Diff line change @@ -6171,8 +6171,8 @@ exports[`Test locations negative number 1`] = `
6171
6171
Program {
6172
6172
" children" : Array [
6173
6173
ExpressionStatement {
6174
- " expression" : Number {
6175
- " kind" : " number " ,
6174
+ " expression" : Unary {
6175
+ " kind" : " unary " ,
6176
6176
" loc" : Location {
6177
6177
" end" : Position {
6178
6178
" column" : 6 ,
@@ -6186,7 +6186,24 @@ Program {
6186
6186
" offset" : 0 ,
6187
6187
},
6188
6188
},
6189
- " value" : " -2112" ,
6189
+ " type" : " -" ,
6190
+ " what" : Number {
6191
+ " kind" : " number" ,
6192
+ " loc" : Location {
6193
+ " end" : Position {
6194
+ " column" : 5 ,
6195
+ " line" : 1 ,
6196
+ " offset" : 5 ,
6197
+ },
6198
+ " source" : " 2112" ,
6199
+ " start" : Position {
6200
+ " column" : 1 ,
6201
+ " line" : 1 ,
6202
+ " offset" : 1 ,
6203
+ },
6204
+ },
6205
+ " value" : " 2112" ,
6206
+ },
6190
6207
},
6191
6208
" kind" : " expressionstatement" ,
6192
6209
" loc" : Location {
Original file line number Diff line number Diff line change @@ -13,9 +13,13 @@ Program {
13
13
" name" : " a" ,
14
14
},
15
15
" operator" : " =" ,
16
- " right" : Number {
17
- " kind" : " number" ,
18
- " value" : " -1.5" ,
16
+ " right" : Unary {
17
+ " kind" : " unary" ,
18
+ " type" : " -" ,
19
+ " what" : Number {
20
+ " kind" : " number" ,
21
+ " value" : " 1.5" ,
22
+ },
19
23
},
20
24
},
21
25
" kind" : " expressionstatement" ,
Original file line number Diff line number Diff line change @@ -15,9 +15,13 @@ Program {
15
15
" operator" : " =" ,
16
16
" right" : OffsetLookup {
17
17
" kind" : " offsetlookup" ,
18
- " offset" : Number {
19
- " kind" : " number" ,
20
- " value" : " -5" ,
18
+ " offset" : Unary {
19
+ " kind" : " unary" ,
20
+ " type" : " -" ,
21
+ " what" : Number {
22
+ " kind" : " number" ,
23
+ " value" : " 5" ,
24
+ },
21
25
},
22
26
" what" : StaticLookup {
23
27
" kind" : " staticlookup" ,
You can’t perform that action at this time.
0 commit comments