#
3bd38c5b |
| 25-Feb-2023 |
Nikita Popov |
Properly support prefix operator precedence printing The pretty printer is supposed to produce a minimal-parentheses printing for expressions. However, for prefix operators, we were
Properly support prefix operator precedence printing The pretty printer is supposed to produce a minimal-parentheses printing for expressions. However, for prefix operators, we were failing to do so in ways that are practically meaningful, e.g. $a = yield from $b produced redundant parentheses around the yield from. For prefix operators, the precedence of the direct parent operator is not actually relevant: What matters is the precedence of any infix operator whose LHS it appears on. For example, $a . include $b does not require parentheses, but (include $a) . $b does. To handle this, keep separate track of the parent operator precedence, and a special LHS precedence which is used for unary operator printing only. Because the LHS precedence may not come from the direct parent, we have to pass it down the call stack. And if we do that, we may as well do the same for the parent precedence. This also fixes an integration test failure with php-src, because arrow function precedence was previously not respected (and would be ugly to respect without this change).
show more ...
|
Revision tags: v4.3.0, v4.2.5, v4.2.4, v4.2.3, v4.2.2, v4.2.1, v4.2.0, v4.1.1, v4.1.0, v4.0.4, v4.0.3, v4.0.2, v4.0.1, v4.0.0, v3.1.5, v4.0.0beta1, v3.1.4, v4.0.0alpha3, v3.1.3, v4.0.0alpha2, v3.1.2, v4.0.0alpha1, v3.1.1, v3.1.0, v3.0.6, v3.0.5, v3.0.4, v3.0.3, v3.0.2, v3.0.1, v3.0.0, v3.0.0beta2, v3.0.0beta1, v2.1.1, v3.0.0alpha1, v2.1.0, v2.0.1, v2.0.0, v2.0.0beta1 |
|
#
e4b837e0 |
| 02-Oct-2015 |
Nikita Popov |
Split up pretty printer test in stmt/expr The list was getting unweildly. Also improve error message when parsing fails in pretty printer test and extend some tests.
|