|
43 | 43 | NullSafeInstanceExpression, |
44 | 44 | OffsetExpression, |
45 | 45 | Parameter, |
| 46 | + PipeExpression, |
46 | 47 | Property, |
47 | 48 | ReturnStatement, |
48 | 49 | ScopeExpression, |
@@ -174,6 +175,16 @@ public function __construct() { |
174 | 175 | return new ScopeExpression($scope, $expr, $token->line); |
175 | 176 | }); |
176 | 177 |
|
| 178 | + $this->infix('|>', 40, function($parse, $token, $left) { |
| 179 | + return new PipeExpression($left, $this->expression($parse, 40), $left->line); |
| 180 | + }); |
| 181 | + |
| 182 | + $this->infix('?|>', 40, function($parse, $node, $left) { |
| 183 | + $value= new PipeExpression($left, $this->expression($parse, 40), $left->line); |
| 184 | + $value->kind= 'nullsafepipe'; |
| 185 | + return $value; |
| 186 | + }); |
| 187 | + |
177 | 188 | $this->infix('(', 100, function($parse, $token, $left) { |
178 | 189 |
|
179 | 190 | // Resolve ambiguity by looking ahead: `func(...)` which is a first-class |
@@ -207,7 +218,7 @@ public function __construct() { |
207 | 218 | return new OffsetExpression($left, $expr, $left->line); |
208 | 219 | }); |
209 | 220 |
|
210 | | - $this->infix('?', 80, function($parse, $token, $left) { |
| 221 | + $this->infix('?', 30, function($parse, $token, $left) { |
211 | 222 | $when= $this->expression($parse, 0); |
212 | 223 | $parse->expecting(':', 'ternary'); |
213 | 224 | $else= $this->expression($parse, 0); |
|
0 commit comments