aboutsummaryrefslogtreecommitdiff
path: root/src/NXP/Classes/Lexer.php
diff options
context:
space:
mode:
authorBruce Wells <brucekwells@gmail.com>2019-01-16 04:04:16 +0300
committerBruce Wells <brucekwells@gmail.com>2019-01-16 04:04:16 +0300
commit47df3edbb6c437a049deee356db84f58edcba681 (patch)
tree866692bf5b60b9523e3b9b271fdb71f9fd890edf /src/NXP/Classes/Lexer.php
parent265cff175eb1c0be4b59d937286059532361820f (diff)
Fixed comma operator
Added unit tests for expressions in function arguments. Changed array_push to $var[] = native code.
Diffstat (limited to 'src/NXP/Classes/Lexer.php')
-rw-r--r--src/NXP/Classes/Lexer.php9
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;