Questions about functions using commas and ** operator
Hello and thank you for publishing the package.
I've been trying pow() and log() with two parameters but the , returned the Unknown token exception.
The ** operator returned a Syntax error exception.
Code example
$parser = new StdMathParser();
$AST = $parser->parse( 'pow(33,10)' );
$evaluator = new Evaluator();
//$total returns the exceptions explained above
$total = $AST->accept($evaluator);
$parser = new StdMathParser();
$AST = $parser->parse( '3**10' );
$evaluator = new Evaluator();
//$total returns the exceptions explained above
$total = $AST->accept($evaluator);
Did I forget a step for those scenarios ? All the other math functions and operator work as expected in my case. Thanks again
Hello, I see that pow() and ** are not supported and that log() only accepts one argument.
Is that correct ?
The standard lexer/parser that ships with the project only uses ^ for exponentiation, and log for the logarithm to base e. If you want to change that, I would suggest that you implement your own lever. Use StdMathLexer as inspiration.
Actually, let me think a little more about this. I just realised that there is no obvious way to add functions taking several comma-separated arguments.
Hello @mossadal , thank you for your answer.
Yes I was wrong considering that php functions would also be valid/accepted formulas, but I realize it doesn't have to be the case.
I also tried to add comas as a valid token but realized I couldn't develop the logic to for coma separated arguments at the moment.
Thank you again.