Skip to content

Commit

Permalink
Merge pull request #51 from xp-framework/feature/logical-assignment
Browse files Browse the repository at this point in the history
Logical Operators and Assignment Expressions
  • Loading branch information
thekid authored Mar 23, 2024
2 parents 399900f + a4b51f2 commit 6924a08
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/php/lang/ast/Tokens.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class Tokens {
'>' => ['>>=', '>=', '>>'],
'=' => ['===', '=>', '=='],
'!' => ['!==', '!='],
'&' => ['&&', '&='],
'|' => ['||', '|='],
'&' => ['&&=', '&&', '&='],
'|' => ['||=', '||', '|='],
'^' => ['^='],
'+' => ['+=', '++'],
'-' => ['-=', '--', '->'],
Expand Down
2 changes: 2 additions & 0 deletions src/main/php/lang/ast/syntax/PHP.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ public function __construct() {
$this->assignment('>>=');
$this->assignment('<<=');
$this->assignment('??=');
$this->assignment('&&=');
$this->assignment('||=');

// This is ambiguous:
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function prefix($operator) {
);
}

#[Test, Values(['=', '+=', '-=', '*=', '/=', '.=', '**=', '&=', '|=', '^=', '>>=', '<<='])]
#[Test, Values(['=', '+=', '-=', '*=', '/=', '.=', '**=', '&=', '|=', '^=', '>>=', '<<=', '??=', '&&=', '||='])]
public function assignment($operator) {
$this->assertParsed(
[new Assignment(new Variable('a', self::LINE), $operator, new Variable('b', self::LINE), self::LINE)],
Expand Down

0 comments on commit 6924a08

Please sign in to comment.