diff options
author | Bruce Wells <bruce.wells@simparel.com> | 2018-09-12 18:55:31 +0300 |
---|---|---|
committer | Bruce Wells <bruce.wells@simparel.com> | 2018-09-12 19:33:17 +0300 |
commit | 00def17f0e9183544813427cddbdaed851986309 (patch) | |
tree | fcc3e47fdf11465e2566e9c6f71e7a80488da6a8 /src/NXP/Classes/Lexer.php | |
parent | 855ca5dfc1a6d70d9872df4b0d7bea8ba3c4c040 (diff) |
Support for double quoted strings
Changed array() to [] syntax.
Added variable in question to unknown variable exception.
Added getVar and getVars accessor functions.
Added getOperators and getFunctions accessor functions for completeness.
Extended all Exceptions off MathExecutorException.
Diffstat (limited to 'src/NXP/Classes/Lexer.php')
-rw-r--r-- | src/NXP/Classes/Lexer.php | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/NXP/Classes/Lexer.php b/src/NXP/Classes/Lexer.php index e541732..82b2c53 100644 --- a/src/NXP/Classes/Lexer.php +++ b/src/NXP/Classes/Lexer.php @@ -17,6 +17,7 @@ use NXP\Classes\Token\TokenLeftBracket; use NXP\Classes\Token\TokenNumber; use NXP\Classes\Token\TokenRightBracket; use NXP\Classes\Token\TokenVariable; +use NXP\Classes\Token\TokenString; use NXP\Exception\IncorrectBracketsException; use NXP\Exception\IncorrectExpressionException; @@ -42,7 +43,7 @@ class Lexer */ public function stringToTokensStream($input) { - $matches = array(); + $matches = []; preg_match_all($this->tokenFactory->getTokenParserRegex(), $input, $matches); $tokenFactory = $this->tokenFactory; $tokensStream = array_map( @@ -62,10 +63,13 @@ class Lexer */ public function buildReversePolishNotation($tokensStream) { - $output = array(); - $stack = array(); + $output = []; + $stack = []; foreach ($tokensStream as $token) { + if ($token instanceof TokenString) { + $output[] = $token; + } if ($token instanceof TokenNumber) { $output[] = $token; } |