/** * @param string $input Source string of equation * @return array Tokens stream * @throws \Z\Exception\IncorrectExpressionException */ public function stringToTokensStream($input) { $matches = array(); preg_match_all($this->tokenFactory->getTokenParserRegex(), $input, $matches); $tokenFactory = $this->tokenFactory; $matches = array_diff($matches[0], [""]); $tokensStream = array_map(function ($token) use($tokenFactory) { return $tokenFactory->createToken($token); }, $matches); return $tokensStream; }
/** * Add function to executor * * @param string $name Name of function * @param callable $function Function * @param int $places Count of arguments * @return MathExecutor */ public function addFunction($name, callable $function = null, $places = 1) { $this->tokenFactory->addFunction($name, $function, $places); return $this; }