aboutsummaryrefslogtreecommitdiff
path: root/src/NXP/Classes/Token
diff options
context:
space:
mode:
authorAlexander Kiryukhin <a.kiryukhin@mail.ru>2020-05-15 21:51:23 +0300
committerAlexander Kiryukhin <a.kiryukhin@mail.ru>2020-05-15 21:51:23 +0300
commitcab8e2d38ae1c8c7fb75022f7d9b0539a0a86d4e (patch)
treed3107b0f586885d56b13dc65411b455a7aee37cb /src/NXP/Classes/Token
parent01415abc9d7f7401d9f4c09fbbec24930c65a097 (diff)
Massive refactoring
More clean structure Parsing without regular expressions
Diffstat (limited to 'src/NXP/Classes/Token')
-rw-r--r--src/NXP/Classes/Token/AbstractContainerToken.php46
-rw-r--r--src/NXP/Classes/Token/AbstractOperator.php51
-rw-r--r--src/NXP/Classes/Token/InterfaceFunction.php23
-rw-r--r--src/NXP/Classes/Token/InterfaceOperator.php33
-rw-r--r--src/NXP/Classes/Token/InterfaceToken.php22
-rw-r--r--src/NXP/Classes/Token/TokenAnd.php53
-rw-r--r--src/NXP/Classes/Token/TokenComma.php53
-rw-r--r--src/NXP/Classes/Token/TokenDegree.php64
-rw-r--r--src/NXP/Classes/Token/TokenDivision.php70
-rw-r--r--src/NXP/Classes/Token/TokenEqual.php53
-rw-r--r--src/NXP/Classes/Token/TokenFunction.php42
-rw-r--r--src/NXP/Classes/Token/TokenGreaterThan.php53
-rw-r--r--src/NXP/Classes/Token/TokenGreaterThanOrEqual.php53
-rw-r--r--src/NXP/Classes/Token/TokenLeftBracket.php25
-rw-r--r--src/NXP/Classes/Token/TokenLessThan.php53
-rw-r--r--src/NXP/Classes/Token/TokenLessThanOrEqual.php53
-rw-r--r--src/NXP/Classes/Token/TokenMinus.php68
-rw-r--r--src/NXP/Classes/Token/TokenMultiply.php64
-rw-r--r--src/NXP/Classes/Token/TokenNotEqual.php53
-rw-r--r--src/NXP/Classes/Token/TokenNumber.php25
-rw-r--r--src/NXP/Classes/Token/TokenOr.php53
-rw-r--r--src/NXP/Classes/Token/TokenPlus.php64
-rw-r--r--src/NXP/Classes/Token/TokenRightBracket.php25
-rw-r--r--src/NXP/Classes/Token/TokenStringDoubleQuoted.php25
-rw-r--r--src/NXP/Classes/Token/TokenStringSingleQuoted.php26
-rw-r--r--src/NXP/Classes/Token/TokenVariable.php25
26 files changed, 0 insertions, 1175 deletions
diff --git a/src/NXP/Classes/Token/AbstractContainerToken.php b/src/NXP/Classes/Token/AbstractContainerToken.php
deleted file mode 100644
index be2da5f..0000000
--- a/src/NXP/Classes/Token/AbstractContainerToken.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-/**
- * This file is part of the MathExecutor package
- *
- * (c) Alexander Kiryukhin
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code
- */
-
-namespace NXP\Classes\Token;
-
-/**
- * @author Alexander Kiryukhin <a.kiryukhin@mail.ru>
- */
-abstract class AbstractContainerToken implements InterfaceToken
-{
- /**
- * @var string
- */
- protected $value;
-
- /**
- * @param string $value
- */
- public function __construct($value)
- {
- $this->value = $value;
- }
-
- /**
- * @param string $value
- */
- public function setValue($value)
- {
- $this->value = $value;
- }
-
- /**
- * @return string
- */
- public function getValue()
- {
- return $this->value;
- }
-}
diff --git a/src/NXP/Classes/Token/AbstractOperator.php b/src/NXP/Classes/Token/AbstractOperator.php
deleted file mode 100644
index 67e8031..0000000
--- a/src/NXP/Classes/Token/AbstractOperator.php
+++ /dev/null
@@ -1,51 +0,0 @@
-<?php
-/**
- * This file is part of the MathExecutor package
- *
- * (c) Alexander Kiryukhin
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code
- */
-
-namespace NXP\Classes\Token;
-
-/**
- * @author Alexander Kiryukhin <a.kiryukhin@mail.ru>
- */
-abstract class AbstractOperator implements InterfaceToken, InterfaceOperator
-{
- const RIGHT_ASSOC = 'RIGHT';
- const LEFT_ASSOC = 'LEFT';
-
- /**
- * Divide by zero reporting
- *
- * @var bool
- */
- private $divideByZeroReporting = false;
-
- /**
- * Set division by zero exception reporting
- *
- * @param bool $exception default true
- *
- * @return $this
- */
- public function setDivisionByZeroException($exception = true)
- {
- $this->divideByZeroReporting = $exception;
-
- return $this;
- }
-
- /**
- * Get division by zero exception status
- *
- * @return bool
- */
- public function getDivisionByZeroException()
- {
- return $this->divideByZeroReporting;
- }
-}
diff --git a/src/NXP/Classes/Token/InterfaceFunction.php b/src/NXP/Classes/Token/InterfaceFunction.php
deleted file mode 100644
index a457d0e..0000000
--- a/src/NXP/Classes/Token/InterfaceFunction.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-/**
- * This file is part of the MathExecutor package
- *
- * (c) Alexander Kiryukhin
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code
- */
-
-namespace NXP\Classes\Token;
-
-/**
- * @author Alexander Kiryukhin <a.kiryukhin@mail.ru>
- */
-interface InterfaceFunction
-{
- /**
- * @param array $stack
- * @return $this
- */
- public function execute(&$stack);
-}
diff --git a/src/NXP/Classes/Token/InterfaceOperator.php b/src/NXP/Classes/Token/InterfaceOperator.php
deleted file mode 100644
index 9e3bae1..0000000
--- a/src/NXP/Classes/Token/InterfaceOperator.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/**
- * This file is part of the MathExecutor package
- *
- * (c) Alexander Kiryukhin
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code
- */
-
-namespace NXP\Classes\Token;
-
-/**
- * @author Alexander Kiryukhin <a.kiryukhin@mail.ru>
- */
-interface InterfaceOperator
-{
- /**
- * @return int
- */
- public function getPriority();
-
- /**
- * @return string
- */
- public function getAssociation();
-
- /**
- * @param array $stack
- * @return TokenNumber
- */
- public function execute(&$stack);
-}
diff --git a/src/NXP/Classes/Token/InterfaceToken.php b/src/NXP/Classes/Token/InterfaceToken.php
deleted file mode 100644
index db07aeb..0000000
--- a/src/NXP/Classes/Token/InterfaceToken.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-/**
- * This file is part of the MathExecutor package
- *
- * (c) Alexander Kiryukhin
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code
- */
-
-namespace NXP\Classes\Token;
-
-/**
- * @author Alexander Kiryukhin <a.kiryukhin@mail.ru>
- */
-interface InterfaceToken
-{
- /**
- * @return string
- */
- public static function getRegex();
-}
diff --git a/src/NXP/Classes/Token/TokenAnd.php b/src/NXP/Classes/Token/TokenAnd.php
deleted file mode 100644
index dab4497..0000000
--- a/src/NXP/Classes/Token/TokenAnd.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-
-namespace NXP\Classes\Token;
-
-use NXP\Exception\IncorrectExpressionException;
-
-class TokenAnd extends AbstractOperator
-{
- /**
- * @return string
- */
- public static function getRegex()
- {
- return '&&';
- }
-
- /**
- * @return int
- */
- public function getPriority()
- {
- return 100;
- }
-
- /**
- * @return string
- */
- public function getAssociation()
- {
- return self::LEFT_ASSOC;
- }
-
- /**
- * @param InterfaceToken[] $stack
- *
- * @return $this
- *
- * @throws \NXP\Exception\IncorrectExpressionException
- */
- public function execute(&$stack)
- {
- $op2 = array_pop($stack);
- $op1 = array_pop($stack);
-
- if ($op1 === null || $op2 === null) {
- throw new IncorrectExpressionException("&& requires two operators");
- }
-
- $result = $op1->getValue() && $op2->getValue();
-
- return new TokenNumber($result);
- }
-}
diff --git a/src/NXP/Classes/Token/TokenComma.php b/src/NXP/Classes/Token/TokenComma.php
deleted file mode 100644
index f6fc068..0000000
--- a/src/NXP/Classes/Token/TokenComma.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-/**
- * This file is part of the MathExecutor package
- *
- * (c) Alexander Kiryukhin
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code
- */
-
-namespace NXP\Classes\Token;
-
-/**
- * @author Alexander Kiryukhin <a.kiryukhin@mail.ru>
- */
-class TokenComma extends AbstractOperator
-{
- /**
- * @return string
- */
- public static function getRegex()
- {
- return '\,';
- }
-
- /**
- * Comma operator is lowest priority
- *
- * @return int
- */
- public function getPriority()
- {
- return 0;
- }
-
- /**
- * @return string
- */
- public function getAssociation()
- {
- return self::LEFT_ASSOC;
- }
-
- /**
- * @param array $stack
- * @return TokenNumber
- */
- public function execute(&$stack)
- {
- // Comma operators don't do anything, stack has already executed
- }
-
-}
diff --git a/src/NXP/Classes/Token/TokenDegree.php b/src/NXP/Classes/Token/TokenDegree.php
deleted file mode 100644
index 0d22f91..0000000
--- a/src/NXP/Classes/Token/TokenDegree.php
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-/**
-* This file is part of the MathExecutor package
-*
-* (c) Alexander Kiryukhin
-*
-* For the full copyright and license information, please view the LICENSE
-* file that was distributed with this source code
-*/
-
-namespace NXP\Classes\Token;
-
-use NXP\Exception\IncorrectExpressionException;
-
-/**
-* @author Alexander Kiryukhin <a.kiryukhin@mail.ru>
-*/
-class TokenDegree extends AbstractOperator
-{
- /**
- * @return string
- */
- public static function getRegex()
- {
- return '\^';
- }
-
- /**
- * @return int
- */
- public function getPriority()
- {
- return 220;
- }
-
- /**
- * @return string
- */
- public function getAssociation()
- {
- return self::RIGHT_ASSOC;
- }
-
- /**
- * @param InterfaceToken[] $stack
- *
- * @return TokenNumber
- *
- * @throws \NXP\Exception\IncorrectExpressionException
- */
- public function execute(&$stack)
- {
- $op2 = array_pop($stack);
- $op1 = array_pop($stack);
-
- if ($op1 === null || $op2 === null) {
- throw new IncorrectExpressionException("Power operator requires two operators");
- }
-
- $result = $op1->getValue() ** $op2->getValue();
-
- return new TokenNumber($result);
- }
-}
diff --git a/src/NXP/Classes/Token/TokenDivision.php b/src/NXP/Classes/Token/TokenDivision.php
deleted file mode 100644
index 328833b..0000000
--- a/src/NXP/Classes/Token/TokenDivision.php
+++ /dev/null
@@ -1,70 +0,0 @@
-<?php
-/**
-* This file is part of the MathExecutor package
-*
-* (c) Alexander Kiryukhin
-*
-* For the full copyright and license information, please view the LICENSE
-* file that was distributed with this source code
-*/
-
-namespace NXP\Classes\Token;
-
-use NXP\Exception\IncorrectExpressionException;
-use NXP\Exception\DivisionByZeroException;
-
-/**
-* @author Alexander Kiryukhin <a.kiryukhin@mail.ru>
-*/
-class TokenDivision extends AbstractOperator
-{
- /**
- * @return string
- */
- public static function getRegex()
- {
- return '\/';
- }
-
- /**
- * @return int
- */
- public function getPriority()
- {
- return 180;
- }
-
- /**
- * @return string
- */
- public function getAssociation()
- {
- return self::LEFT_ASSOC;
- }
-
- /**
- * @param InterfaceToken[] $stack
- *
- * @return $this
- *
- * @throws \NXP\Exception\IncorrectExpressionException
- * @throws \NXP\Exception\DivisionByZeroException
- */
- public function execute(&$stack)
- {
- $op2 = array_pop($stack);
- $op1 = array_pop($stack);
-
- if ($op1 === null || $op2 === null) {
- throw new IncorrectExpressionException("Division requires two operators");
- }
-
- if ($this->getDivisionByZeroException() && $op2->getValue() == 0) {
- throw new DivisionByZeroException();
- }
-
- $result = $op2->getValue() != 0 ? $op1->getValue() / $op2->getValue() : 0;
-
- return new TokenNumber($result);
- }
-}
diff --git a/src/NXP/Classes/Token/TokenEqual.php b/src/NXP/Classes/Token/TokenEqual.php
deleted file mode 100644
index b0ac31e..0000000
--- a/src/NXP/Classes/Token/TokenEqual.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-
-namespace NXP\Classes\Token;
-
-use NXP\Exception\IncorrectExpressionException;
-
-class TokenEqual extends AbstractOperator
-{
- /**
- * @return string
- */
- public static function getRegex()
- {
- return '\=\=';
- }
-
- /**
- * @return int
- */
- public function getPriority()
- {
- return 140;
- }
-
- /**
- * @return string
- */
- public function getAssociation()
- {
- return self::LEFT_ASSOC;
- }
-
- /**
- * @param InterfaceToken[] $stack
- *
- * @return $this
- *
- * @throws \NXP\Exception\IncorrectExpressionException
- */
- public function execute(&$stack)
- {
- $op2 = array_pop($stack);
- $op1 = array_pop($stack);
-
- if ($op1 === null || $op2 === null) {
- throw new IncorrectExpressionException("== requires two operators");
- }
-
- $result = $op1->getValue() == $op2->getValue();
-
- return new TokenNumber($result);
- }
-}
diff --git a/src/NXP/Classes/Token/TokenFunction.php b/src/NXP/Classes/Token/TokenFunction.php
deleted file mode 100644
index 432f107..0000000
--- a/src/NXP/Classes/Token/TokenFunction.php
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-/**
- * This file is part of the MathExecutor package
- *
- * (c) Alexander Kiryukhin
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code
- */
-
-namespace NXP\Classes\Token;
-
-/**
- * @author Alexander Kiryukhin <a.kiryukhin@mail.ru>
- */
-class TokenFunction extends AbstractContainerToken implements InterfaceFunction
-{
- /**
- * @return string
- */
- public static function getRegex()
- {
- return '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*';
- }
-
- /**
- * @param array $stack
- * @return $this
- */
- public function execute(&$stack)
- {
- $args = [];
- list($places, $function) = $this->value;
- for ($i = 0; $i < $places; $i++) {
- array_unshift($args, array_pop($stack)->getValue());
- }
-
- $result = call_user_func_array($function, $args);
-
- return new TokenNumber($result);
- }
-}
diff --git a/src/NXP/Classes/Token/TokenGreaterThan.php b/src/NXP/Classes/Token/TokenGreaterThan.php
deleted file mode 100644
index 51a5aca..0000000
--- a/src/NXP/Classes/Token/TokenGreaterThan.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-
-namespace NXP\Classes\Token;
-
-use NXP\Exception\IncorrectExpressionException;
-
-class TokenGreaterThan extends AbstractOperator
-{
- /**
- * @return string
- */
- public static function getRegex()
- {
- return '>';
- }
-
- /**
- * @return int
- */
- public function getPriority()
- {
- return 150;
- }
-
- /**
- * @return string
- */
- public function getAssociation()
- {
- return self::LEFT_ASSOC;
- }
-
- /**
- * @param InterfaceToken[] $stack
- *
- * @return $this
- *
- * @throws \NXP\Exception\IncorrectExpressionException
- */
- public function execute(&$stack)
- {
- $op2 = array_pop($stack);
- $op1 = array_pop($stack);
-
- if ($op1 === null || $op2 === null) {
- throw new IncorrectExpressionException("> requires two operators");
- }
-
- $result = $op1->getValue() > $op2->getValue();
-
- return new TokenNumber($result);
- }
-}
diff --git a/src/NXP/Classes/Token/TokenGreaterThanOrEqual.php b/src/NXP/Classes/Token/TokenGreaterThanOrEqual.php
deleted file mode 100644
index aa4425f..0000000
--- a/src/NXP/Classes/Token/TokenGreaterThanOrEqual.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-
-namespace NXP\Classes\Token;
-
-use NXP\Exception\IncorrectExpressionException;
-
-class TokenGreaterThanOrEqual extends AbstractOperator
-{
- /**
- * @return string
- */
- public static function getRegex()
- {
- return '>\=';
- }
-
- /**
- * @return int
- */
- public function getPriority()
- {
- return 150;
- }
-
- /**
- * @return string
- */
- public function getAssociation()
- {
- return self::LEFT_ASSOC;
- }
-
- /**
- * @param InterfaceToken[] $stack
- *
- * @return $this
- *
- * @throws \NXP\Exception\IncorrectExpressionException
- */
- public function execute(&$stack)
- {
- $op2 = array_pop($stack);
- $op1 = array_pop($stack);
-
- if ($op1 === null || $op2 === null) {
- throw new IncorrectExpressionException(">= requires two operators");
- }
-
- $result = $op1->getValue() >= $op2->getValue();
-
- return new TokenNumber($result);
- }
-}
diff --git a/src/NXP/Classes/Token/TokenLeftBracket.php b/src/NXP/Classes/Token/TokenLeftBracket.php
deleted file mode 100644
index 08165d8..0000000
--- a/src/NXP/Classes/Token/TokenLeftBracket.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-/**
- * This file is part of the MathExecutor package
- *
- * (c) Alexander Kiryukhin
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code
- */
-
-namespace NXP\Classes\Token;
-
-/**
- * @author Alexander Kiryukhin <a.kiryukhin@mail.ru>
- */
-class TokenLeftBracket implements InterfaceToken
-{
- /**
- * @return string
- */
- public static function getRegex()
- {
- return '\(';
- }
-}
diff --git a/src/NXP/Classes/Token/TokenLessThan.php b/src/NXP/Classes/Token/TokenLessThan.php
deleted file mode 100644
index d289028..0000000
--- a/src/NXP/Classes/Token/TokenLessThan.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-
-namespace NXP\Classes\Token;
-
-use NXP\Exception\IncorrectExpressionException;
-
-class TokenLessThan extends AbstractOperator
-{
- /**
- * @return string
- */
- public static function getRegex()
- {
- return '<';
- }
-
- /**
- * @return int
- */
- public function getPriority()
- {
- return 150;
- }
-
- /**
- * @return string
- */
- public function getAssociation()
- {
- return self::LEFT_ASSOC;
- }
-
- /**
- * @param InterfaceToken[] $stack
- *
- * @return $this
- *
- * @throws \NXP\Exception\IncorrectExpressionException
- */
- public function execute(&$stack)
- {
- $op2 = array_pop($stack);
- $op1 = array_pop($stack);
-
- if ($op1 === null || $op2 === null) {
- throw new IncorrectExpressionException("< requires two operators");
- }
-
- $result = $op1->getValue() < $op2->getValue();
-
- return new TokenNumber($result);
- }
-}
diff --git a/src/NXP/Classes/Token/TokenLessThanOrEqual.php b/src/NXP/Classes/Token/TokenLessThanOrEqual.php
deleted file mode 100644
index 5a2fba3..0000000
--- a/src/NXP/Classes/Token/TokenLessThanOrEqual.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-
-namespace NXP\Classes\Token;
-
-use NXP\Exception\IncorrectExpressionException;
-
-class TokenLessThanOrEqual extends AbstractOperator
-{
- /**
- * @return string
- */
- public static function getRegex()
- {
- return '<\=';
- }
-
- /**
- * @return int
- */
- public function getPriority()
- {
- return 150;
- }
-
- /**
- * @return string
- */
- public function getAssociation()
- {
- return self::LEFT_ASSOC;
- }
-
- /**
- * @param InterfaceToken[] $stack
- *
- * @return $this
- *
- * @throws \NXP\Exception\IncorrectExpressionException
- */
- public function execute(&$stack)
- {
- $op2 = array_pop($stack);
- $op1 = array_pop($stack);
-
- if ($op1 === null || $op2 === null) {
- throw new IncorrectExpressionException("<= requires two operators");
- }
-
- $result = $op1->getValue() <= $op2->getValue();
-
- return new TokenNumber($result);
- }
-}
diff --git a/src/NXP/Classes/Token/TokenMinus.php b/src/NXP/Classes/Token/TokenMinus.php
deleted file mode 100644
index b4b04e3..0000000
--- a/src/NXP/Classes/Token/TokenMinus.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-/**
-* This file is part of the MathExecutor package
-*
-* (c) Alexander Kiryukhin
-*
-* For the full copyright and license information, please view the LICENSE
-* file that was distributed with this source code
-*/
-
-namespace NXP\Classes\Token;
-
-use NXP\Exception\IncorrectExpressionException;
-
-/**
-* @author Alexander Kiryukhin <a.kiryukhin@mail.ru>
-*/
-class TokenMinus extends AbstractOperator
-{
- /**
- * @return string
- */
- public static function getRegex()
- {
- return '\-';
- }
-
- /**
- * @return int
- */
- public function getPriority()
- {
- return 170;
- }
-
- /**
- * @return string
- */
- public function getAssociation()
- {
- return self::LEFT_ASSOC;
- }
-
- /**
- * @param InterfaceToken[] $stack
- *
- * @return $this
- *
- * @throws \NXP\Exception\IncorrectExpressionException
- */
- public function execute(&$stack)
- {
- $op2 = array_pop($stack);
- $op1 = array_pop($stack);
-
- if ($op2 === null) {
- throw new IncorrectExpressionException("Subtraction requires right operator");
- }
-
- if (!$op1) {
- $op1 = new TokenNumber(0);
- }
-
- $result = $op1->getValue() - $op2->getValue();
-
- return new TokenNumber($result);
- }
-}
diff --git a/src/NXP/Classes/Token/TokenMultiply.php b/src/NXP/Classes/Token/TokenMultiply.php
deleted file mode 100644
index 762fb48..0000000
--- a/src/NXP/Classes/Token/TokenMultiply.php
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-/**
-* This file is part of the MathExecutor package
-*
-* (c) Alexander Kiryukhin
-*
-* For the full copyright and license information, please view the LICENSE
-* file that was distributed with this source code
-*/
-
-namespace NXP\Classes\Token;
-
-use NXP\Exception\IncorrectExpressionException;
-
-/**
-* @author Alexander Kiryukhin <a.kiryukhin@mail.ru>
-*/
-class TokenMultiply extends AbstractOperator
-{
- /**
- * @return string
- */
- public static function getRegex()
- {
- return '\*';
- }
-
- /**
- * @return int
- */
- public function getPriority()
- {
- return 180;
- }
-
- /**
- * @return string
- */
- public function getAssociation()
- {
- return self::LEFT_ASSOC;
- }
-
- /**
- * @param InterfaceToken[] $stack
- *
- * @return $this
- *
- * @throws \NXP\Exception\IncorrectExpressionException
- */
- public function execute(&$stack)
- {
- $op2 = array_pop($stack);
- $op1 = array_pop($stack);
-
- if ($op1 === null || $op2 === null) {
- throw new IncorrectExpressionException("Multiplication requires two operators");
- }
-
- $result = $op1->getValue() * $op2->getValue();
-
- return new TokenNumber($result);
- }
-}
diff --git a/src/NXP/Classes/Token/TokenNotEqual.php b/src/NXP/Classes/Token/TokenNotEqual.php
deleted file mode 100644
index 21c9454..0000000
--- a/src/NXP/Classes/Token/TokenNotEqual.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-
-namespace NXP\Classes\Token;
-
-use NXP\Exception\IncorrectExpressionException;
-
-class TokenNotEqual extends AbstractOperator
-{
- /**
- * @return string
- */
- public static function getRegex()
- {
- return '\!\=';
- }
-
- /**
- * @return int
- */
- public function getPriority()
- {
- return 140;
- }
-
- /**
- * @return string
- */
- public function getAssociation()
- {
- return self::LEFT_ASSOC;
- }
-
- /**
- * @param InterfaceToken[] $stack
- *
- * @return $this
- *
- * @throws \NXP\Exception\IncorrectExpressionException
- */
- public function execute(&$stack)
- {
- $op2 = array_pop($stack);
- $op1 = array_pop($stack);
-
- if ($op1 === null || $op2 === null) {
- throw new IncorrectExpressionException("!= requires two operators");
- }
-
- $result = $op1->getValue() != $op2->getValue();
-
- return new TokenNumber($result);
- }
-}
diff --git a/src/NXP/Classes/Token/TokenNumber.php b/src/NXP/Classes/Token/TokenNumber.php
deleted file mode 100644
index 982e316..0000000
--- a/src/NXP/Classes/Token/TokenNumber.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-/**
- * This file is part of the MathExecutor package
- *
- * (c) Alexander Kiryukhin
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code
- */
-
-namespace NXP\Classes\Token;
-
-/**
- * @author Alexander Kiryukhin <a.kiryukhin@mail.ru>
- */
-class TokenNumber extends AbstractContainerToken
-{
- /**
- * @return string
- */
- public static function getRegex()
- {
- return '\-?\d+\.?\d*(E-?\d+)?';
- }
-}
diff --git a/src/NXP/Classes/Token/TokenOr.php b/src/NXP/Classes/Token/TokenOr.php
deleted file mode 100644
index 86a4e53..0000000
--- a/src/NXP/Classes/Token/TokenOr.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-
-namespace NXP\Classes\Token;
-
-use NXP\Exception\IncorrectExpressionException;
-
-class TokenOr extends AbstractOperator
-{
- /**
- * @return string
- */
- public static function getRegex()
- {
- return '\|\|';
- }
-
- /**
- * @return int
- */
- public function getPriority()
- {
- return 90;
- }
-
- /**
- * @return string
- */
- public function getAssociation()
- {
- return self::LEFT_ASSOC;
- }
-
- /**
- * @param InterfaceToken[] $stack
- *
- * @return $this
- *
- * @throws \NXP\Exception\IncorrectExpressionException
- */
- public function execute(&$stack)
- {
- $op2 = array_pop($stack);
- $op1 = array_pop($stack);
-
- if ($op1 === null || $op2 === null) {
- throw new IncorrectExpressionException("|| requires two operators");
- }
-
- $result = $op1->getValue() || $op2->getValue();
-
- return new TokenNumber($result);
- }
-}
diff --git a/src/NXP/Classes/Token/TokenPlus.php b/src/NXP/Classes/Token/TokenPlus.php
deleted file mode 100644
index 494f786..0000000
--- a/src/NXP/Classes/Token/TokenPlus.php
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-/**
-* This file is part of the MathExecutor package
-*
-* (c) Alexander Kiryukhin
-*
-* For the full copyright and license information, please view the LICENSE
-* file that was distributed with this source code
-*/
-
-namespace NXP\Classes\Token;
-
-use NXP\Exception\IncorrectExpressionException;
-
-/**
-* @author Alexander Kiryukhin <a.kiryukhin@mail.ru>
-*/
-class TokenPlus extends AbstractOperator
-{
- /**
- * @return string
- */
- public static function getRegex()
- {
- return '\+';
- }
-
- /**
- * @return int
- */
- public function getPriority()
- {
- return 170;
- }
-
- /**
- * @return string
- */
- public function getAssociation()
- {
- return self::LEFT_ASSOC;
- }
-
- /**
- * @param InterfaceToken[] $stack
- *
- * @return $this
- *
- * @throws \NXP\Exception\IncorrectExpressionException
- */
- public function execute(&$stack)
- {
- $op2 = array_pop($stack);
- $op1 = array_pop($stack);
-
- if ($op1 === null || $op2 === null) {
- throw new IncorrectExpressionException("Addition requires two operators");
- }
-
- $result = $op1->getValue() + $op2->getValue();
-
- return new TokenNumber($result);
- }
-}
diff --git a/src/NXP/Classes/Token/TokenRightBracket.php b/src/NXP/Classes/Token/TokenRightBracket.php
deleted file mode 100644
index 306ae0b..0000000
--- a/src/NXP/Classes/Token/TokenRightBracket.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-/**
- * This file is part of the MathExecutor package
- *
- * (c) Alexander Kiryukhin
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code
- */
-
-namespace NXP\Classes\Token;
-
-/**
- * @author Alexander Kiryukhin <a.kiryukhin@mail.ru>
- */
-class TokenRightBracket implements InterfaceToken
-{
- /**
- * @return string
- */
- public static function getRegex()
- {
- return '\)';
- }
-}
diff --git a/src/NXP/Classes/Token/TokenStringDoubleQuoted.php b/src/NXP/Classes/Token/TokenStringDoubleQuoted.php
deleted file mode 100644
index 6cff262..0000000
--- a/src/NXP/Classes/Token/TokenStringDoubleQuoted.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-/**
- * This file is part of the MathExecutor package
- *
- * (c) Alexander Kiryukhin
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code
- */
-
-namespace NXP\Classes\Token;
-
-/**
- * @author Bruce Wells <brucekwells@gmail.com>
- */
-class TokenStringDoubleQuoted extends AbstractContainerToken
-{
- /**
- * @return string
- */
- public static function getRegex()
- {
- return '"([^"]|"")*"';
- }
-}
diff --git a/src/NXP/Classes/Token/TokenStringSingleQuoted.php b/src/NXP/Classes/Token/TokenStringSingleQuoted.php
deleted file mode 100644
index 7a7ab92..0000000
--- a/src/NXP/Classes/Token/TokenStringSingleQuoted.php
+++ /dev/null
@@ -1,26 +0,0 @@
-<?php
-/**
- * This file is part of the MathExecutor package
- *
- * (c) Alexander Kiryukhin
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code
- */
-
-namespace NXP\Classes\Token;
-
-/**
- * @author Bruce Wells <brucekwells@gmail.com>
- * @author Alexander Kiryukhin <a.kiryukhin@mail.ru>
- */
-class TokenStringSingleQuoted extends AbstractContainerToken
-{
- /**
- * @return string
- */
- public static function getRegex()
- {
- return "'([^']|'')*'";
- }
-}
diff --git a/src/NXP/Classes/Token/TokenVariable.php b/src/NXP/Classes/Token/TokenVariable.php
deleted file mode 100644
index a4a820a..0000000
--- a/src/NXP/Classes/Token/TokenVariable.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-/**
- * This file is part of the MathExecutor package
- *
- * (c) Alexander Kiryukhin
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code
- */
-
-namespace NXP\Classes\Token;
-
-/**
- * @author Alexander Kiryukhin <a.kiryukhin@mail.ru>
- */
-class TokenVariable extends AbstractContainerToken
-{
- /**
- * @return string
- */
- public static function getRegex()
- {
- return '\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*';
- }
-}