zRosenthal / math-executor

Simple math expressions calculator - extension of http://github.com/NeonXP/MathExecutor
MIT License
2 stars 1 forks source link

Fatal error: Call to a member function getPriority() on null in C:\xampp\htdocs\math\vendor\nxp\math-executor\src\NXP\Classes\Lexer.php on line 107 #1

Open falinhares opened 7 years ago

falinhares commented 7 years ago

I've installed math-executor through Composer, ran some tests on the first code and came to this issue:

Code: require "vendor/autoload.php"; $calculator = new \NXP\MathExecutor(); print $calculator->execute("1 + 2 * (2 - (4+10))^2 + sin(10)"); print $calculator->execute("(4+10)^2"); Output: -19.544021110889 Notice: Undefined offset: -1 in C:\xampp\htdocs\math\vendor\nxp\math-executor\src\NXP\Classes\Lexer.php on line 107

Fatal error: Call to a member function getPriority() on null in C:\xampp\htdocs\math\vendor\nxp\math-executor\src\NXP\Classes\Lexer.php on line 107

How can I fix this?

zRosenthal commented 7 years ago

Hello falinhares, there are some bugs when using a lot of parentheses. I would suggest using the following package, Executor

falinhares commented 7 years ago

but the expression delivering the error is (4+10)^2