/** * Tests ExpLexer::process */ public function testProcess() { $actualTokenStream = ExpLexer::process($this->input); $this->assertEquals($this->tokenStream, $actualTokenStream); }
/** * Evaluates the given $expression using the $dataContext as variable source. * * Internally the ExpressionParser uses a infix to postfix conversion to easily * be able to evaluate mathematical expressions * * @param string $expression * @param array $dataContext * @return string evaluated result or an exception of failure */ public static function evaluate($expression, $dataContext) { $outputTokens = ExpLexer::process($expression); $result = ExpParser::parse($outputTokens, $dataContext); return $result->value; }