aboutsummaryrefslogtreecommitdiff
path: root/src/NXP/Classes/Tokenizer.php
diff options
context:
space:
mode:
authorFatih Kızmaz <barka_21@hotmail.com>2022-05-17 00:57:37 +0300
committerGitHub <noreply@github.com>2022-05-17 00:57:37 +0300
commit5d6b4a5dfdea6d4e2814391afcfcd9cf4259c046 (patch)
tree7b793b462a6d59748eb0a8faff18ad81ee4dae4e /src/NXP/Classes/Tokenizer.php
parent2874b1134189634853c3afaaf46c045f66d51ab9 (diff)
Full support for arrays => min, max and avg funcs accept array argument. Also array function is defined which return arguments as array. Square bracket arrays are also supported. (#108)
valid expression -> "max([1,2,3])" valid expression -> "max(array(1,2,3))" valid expression -> "max($ages_arr)" valid expression -> "max(ages_arr())"
Diffstat (limited to 'src/NXP/Classes/Tokenizer.php')
-rw-r--r--src/NXP/Classes/Tokenizer.php11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/NXP/Classes/Tokenizer.php b/src/NXP/Classes/Tokenizer.php
index 23e1cc9..c8b415d 100644
--- a/src/NXP/Classes/Tokenizer.php
+++ b/src/NXP/Classes/Tokenizer.php
@@ -76,6 +76,13 @@ class Tokenizer
continue 2;
+ case '[' === $ch:
+ $this->tokens[] = new Token(Token::Function, 'array');
+ $this->allowNegative = true;
+ $this->tokens[] = new Token(Token::LeftParenthesis, '');
+
+ continue 2;
+
case ' ' == $ch || "\n" == $ch || "\r" == $ch || "\t" == $ch:
$this->tokens[] = new Token(Token::Space, '');
@@ -140,7 +147,7 @@ class Tokenizer
break;
- case $this->isRP($ch):
+ case $this->isRP($ch) || ']' === $ch :
$this->emptyNumberBufferAsLiteral();
$this->emptyStrBufferAsVariable();
$this->allowNegative = false;
@@ -196,8 +203,8 @@ class Tokenizer
}
/**
- * @throws UnknownOperatorException
* @throws IncorrectBracketsException
+ * @throws UnknownOperatorException
* @return Token[] Array of tokens in revers polish notation
*/
public function buildReversePolishNotation() : array