dev-master
9999999-devA component to parse all kind of numerical expressions and solve them
MIT
The Requires
- php ^7.0
parser math expression
Wallogit.com
2017 © Pedro Peláez
A component to parse all kind of numerical expressions and solve them
A Math expression parser built in PHP., (*1)
You can install the component by using composer., (*2)
composer require josefelipetto/math-expression-parser, (*3)
You can use in two ways:, (*4)
use Parser\Facades\ExpressionParser;
$result = ExpressionParser::parse('(2+2)^(2*2)/1+3+5');
assert($result === 264);
use Parser\Evaluator;
use Parser\Lexer; // Or your Lexer
use Parser\Syntactic; // Or your AST
$evaluator = new Evaluator(new Syntactic(new Lexer('(2+2)^(2*2)/1+3+5')));
assert($evaluator->parse() === 264);
The parser accepts the following operators: + ; - ; . ; * ; / ; ^ ; ( ; ), (*5)
A component to parse all kind of numerical expressions and solve them
MIT
parser math expression