A PHP expression parser. This tool was largely inspired by snips of code I came across on the web while looking for some form of an expression DSL. The approach inspired me enough to feel it deserved sharing. Unfortunately these snippets had no name associated with them and I am therefor unable to attribute the inspirative work to its inceptor.
<?php
$expression = new \Expressive\Parser('(2+2)*sqrt(4)');
echo $expression;
// 8
this is intended more as an example use
> bin/expr
math > (2+2)*sqrt(4)
8
math > exit
>
Supported Operations:
+
addition2+2
-
substraction4-2
/
division4/2
*
multiplication2*2
^
exponential2^2
sin
sinesin(60)
cos
cosinecos(90)
tan
tangenttan(45)
sqrt
square rootsqrt(4)
exp
exponentexp(12)