From 47df3edbb6c437a049deee356db84f58edcba681 Mon Sep 17 00:00:00 2001 From: Bruce Wells Date: Tue, 15 Jan 2019 20:04:16 -0500 Subject: Fixed comma operator Added unit tests for expressions in function arguments. Changed array_push to $var[] = native code. --- src/NXP/Classes/Lexer.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/NXP/Classes/Lexer.php') 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; -- cgit v1.2.3