Skip to content

Commit dcd6365

Browse files
committed
Implement logical AND and OR assignment operators (&&=, ||=)
1 parent 6a1a5be commit dcd6365

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/main/php/lang/ast/syntax/PHP.class.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
ArrayLiteral,
55
Annotation,
66
Annotations,
7+
Assignment,
78
Block,
89
Braced,
910
BreakStatement,
@@ -233,8 +234,15 @@ public function __construct() {
233234
$this->assignment('>>=');
234235
$this->assignment('<<=');
235236
$this->assignment('??=');
236-
$this->assignment('&&=');
237-
$this->assignment('||=');
237+
238+
// Logical AND and OR, not supported in PHP
239+
foreach (['&&=', '||='] as $op) {
240+
$this->symbol($op, 10)->led= function($parse, $token, $left) use($op) {
241+
$assign= new Assignment($left, $op, $this->expression($parse, 9), $left->line);
242+
$assign->kind= 'logicalassignment';
243+
return $assign;
244+
};
245+
}
238246

239247
// This is ambiguous:
240248
//

0 commit comments

Comments
 (0)