diff options
author | Bruce Wells <brucekwells@gmail.com> | 2020-04-21 18:12:55 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-21 18:12:55 +0300 |
commit | 4d50343330183a498c34a20d20e5981c26602c0c (patch) | |
tree | 35f93e3f47d06ce9a03edea2b05b29f1b9147679 /src/NXP/Classes/Lexer.php | |
parent | 7198653aef6eab55e1644eea9f16bf0dd0dc2edd (diff) |
Negative expression start (#60)V1.1.4
* Update documentation for PHPFUI/InstaDoc
* Support for negative numbers starting paren enclosed expressions
Diffstat (limited to 'src/NXP/Classes/Lexer.php')
-rw-r--r-- | src/NXP/Classes/Lexer.php | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/NXP/Classes/Lexer.php b/src/NXP/Classes/Lexer.php index a7fe697..9964de9 100644 --- a/src/NXP/Classes/Lexer.php +++ b/src/NXP/Classes/Lexer.php @@ -76,10 +76,10 @@ class Lexer $output[] = $token; } elseif ($token instanceof TokenNumber) { // if the number starts with a minus sign, it could be a negative number, or it could be an operator grabbed by the greedy regex - // if previous token is an operator, then it negative, otherwise remove the minus sign and put a negative operator on the stack + // if previous token is an operator or open bracket, then it negative, otherwise remove the minus sign and put a negative operator on the stack if ($lastToken !== null) { $value = $token->getValue(); - if (($value < 0 || $this->isNegativeZero($value)) && ! ($lastToken instanceof AbstractOperator)) { + if (($value < 0 || $this->isNegativeZero($value)) && ! ($lastToken instanceof AbstractOperator || $lastToken instanceof TokenLeftBracket)) { $token = new TokenNumber(abs($value)); $output[] = $token; $output[] = new TokenMinus('-'); |