diff options
author | Alexander Kiryukhin <alexander@kiryukhin.su> | 2018-09-12 20:05:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-12 20:05:09 +0300 |
commit | 4a672cfd94c07e1821227f27fd1edd2217685136 (patch) | |
tree | c50b777d06d9e9eeff6aeb59005c389ddf9a552b /src/NXP/Classes/Calculator.php | |
parent | 76d1b4b8f02d555e4b4f4fd4d641597f0f6b5f4e (diff) | |
parent | 2722a5201d326317e391ae6c0e2fa7e0c2b537b4 (diff) |
Merge pull request #28 from phpfui/support_for_double_quoted_strings
Support for double quoted strings
Diffstat (limited to 'src/NXP/Classes/Calculator.php')
-rw-r--r-- | src/NXP/Classes/Calculator.php | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/NXP/Classes/Calculator.php b/src/NXP/Classes/Calculator.php index b584d69..bfa7015 100644 --- a/src/NXP/Classes/Calculator.php +++ b/src/NXP/Classes/Calculator.php @@ -13,6 +13,7 @@ namespace NXP\Classes; use NXP\Classes\Token\InterfaceOperator; use NXP\Classes\Token\TokenFunction; use NXP\Classes\Token\TokenNumber; +use NXP\Classes\Token\TokenString; use NXP\Classes\Token\TokenVariable; use NXP\Exception\IncorrectExpressionException; use NXP\Exception\UnknownVariableException; @@ -32,11 +33,14 @@ class Calculator */ public function calculate($tokens, $variables) { - $stack = array(); + $stack = []; foreach ($tokens as $token) { if ($token instanceof TokenNumber) { array_push($stack, $token); } + if ($token instanceof TokenString) { + array_push($stack, $token); + } if ($token instanceof TokenVariable) { $variable = $token->getValue(); if (!array_key_exists($variable, $variables)) { |