diff options
author | Alexander Kiryukhin <alexander@kiryukhin.su> | 2019-01-16 10:27:56 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-16 10:27:56 +0300 |
commit | 36b252b7c91fada20489be9ee60f173b49b823cb (patch) | |
tree | a2d1f4dd6504745596efe10620997bcc1ce06b5a /src/NXP/Classes/Lexer.php | |
parent | 5a26d651dd241f2457cda49206e3439513ea4788 (diff) | |
parent | e1b770d6c884d79b8c3c6226d2e6cc8cc5a633ca (diff) |
Merge pull request #44 from phpfui/masterv0.7.2
* Fixed comma operator
Added unit tests for expressions in function arguments.
Changed array_push to $var[] = native code.
* Fixed merge error
* Fixed typo in constant
Diffstat (limited to 'src/NXP/Classes/Lexer.php')
-rw-r--r-- | src/NXP/Classes/Lexer.php | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/NXP/Classes/Lexer.php b/src/NXP/Classes/Lexer.php index a511c9b..898d8c1 100644 --- a/src/NXP/Classes/Lexer.php +++ b/src/NXP/Classes/Lexer.php @@ -77,7 +77,7 @@ class Lexer } elseif ($token instanceof TokenVariable) { $output[] = $token; } elseif ($token instanceof TokenFunction) { - array_push($stack, $token); + $stack[] = $token; } elseif ($token instanceof AbstractOperator) { // While we have something on the stack while (($count = count($stack)) > 0 @@ -104,9 +104,12 @@ class Lexer $output[] = array_pop($stack); } - array_push($stack, $token); + // Comma operators do nothing really, don't put them on the stack + if (! ($token instanceof TokenComma)) { + $stack[] = $token; + } } elseif ($token instanceof TokenLeftBracket) { - array_push($stack, $token); + $stack[] = $token; } elseif ($token instanceof TokenRightBracket) { while (($current = array_pop($stack)) && (!($current instanceof TokenLeftBracket))) { $output[] = $current; |