arithmexp

A powerful mathematical expression parser and evaluator for PHP featuring variable substitution, user-defined constants, functions, deterministic functions, macros, operators, and compiler optimizations.

GPL-3.0 License

Downloads
56
Stars
24
Committers
4

Bot releases are visible (Hide)

arithmexp - v0.1.12

Published by Muqsit about 2 years ago

  • BinaryOperatorRegistry no longer ends up in an invalid state when an InvalidArgumentException thrown by BinaryOperatorRegistry::register() is handled
  • Numbers with multiple decimal points (such as 3..2, 3.2.1, etc.) are no longer parsed as numeric literals
  • Function call token's "end pos" is now at closing parenthesis of its argument list
    • Parse exceptions arising from function calls are more comprehensible
      // before
      > tan(x) + tan(y) tan(z) ** tan(w)
      Unexpected Function Call token encountered at "tan" (16:19) in "tan(x) + tan(y) tan(z) ** tan(w)"
      
      // after
      > tan(x) + tan(y) tan(z) ** tan(w)
      Unexpected Function Call token encountered at "tan(z)" (16:22) in "tan(x) + tan(y) tan(z) ** tan(w)"
      
arithmexp - v0.1.11

Published by Muqsit about 2 years ago

  • Parser now throws a ParseException when encountering tokens that cannot be resolved to expression tokens
    • This fixes several cases where unexpected tokens are encountered (such as , outside fcall) where a RuntimeException would have instead been thrown with the message "Don't know how to convert * token"
arithmexp - v0.1.10

Published by Muqsit about 2 years ago

  • Add a method to observe changes to BinaryOperatorRegistry and UnaryOperatorRegistry
  • Fix operator token builders not updating operator list for runtime registrations
  • Fix a bug causing nested unary tokens to be improperly grouped
arithmexp - v0.1.9

Published by Muqsit about 2 years ago

  • Parser now throws ParseException when secluded tokens are encountered (such as 2 3 + 4 or tan(x) tan(y)) instead of silently ignoring
  • Fix ParseException being incorrectly thrown for specific nested binary operations
  • Fix operators in function arguments incorrectly throwing a ParseException
arithmexp - v0.1.8

Published by Muqsit about 2 years ago

  • Fixed a bug that caused the parser to fail due to incorrectly counting number of supplied arguments to fcalls
arithmexp - v0.1.7

Published by Muqsit about 2 years ago

arithmexp - v0.1.6

Published by Muqsit about 2 years ago

  • Fixed a bug where the parser incorrectly reported unclosed parentheses
  • Added support for variadic functions
arithmexp - v0.1.5

Published by Muqsit about 2 years ago

  • ParseException is now thrown when a missing opening/closing parenthesis is encountered
  • ParseException is now thrown when no lvalue or rvalue is supplied for a binary operator
  • ParseException is now thrown when no rvalue is supplied for a unary operator
  • ParseException is now thrown when the supplied expression is empty
  • ParseException now extends Exception
    • This change lets IDEs hint developers to catch ParseException when Parser::parse() is invoked
arithmexp - v0.1.4

Published by Muqsit about 2 years ago

arithmexp - v0.1.3

Published by Muqsit about 2 years ago

  • Added support for deterministic functions (see wiki)
  • Segments of the expression (or the expression as a whole) are now precalculated to reduce runtime computation
arithmexp - v0.1.2

Published by Muqsit about 2 years ago

  • Fix a bug causing the parser to go in an endless loop
arithmexp - v0.1.1

Published by Muqsit about 2 years ago

arithmexp - v0.1.0

Published by Muqsit about 2 years ago

arithmexp - v0.0.7

Published by Muqsit about 2 years ago

  • Operator precedence now factors in operator associativity (#6)
  • Binary operators in expressions are resolved during parsing stage instead of during the evaluation stage (performance improvement)
arithmexp - v0.0.6

Published by Muqsit about 2 years ago

  • Improve performance of Expression::evaluate()
arithmexp - v0.0.5

Published by Muqsit about 2 years ago

  • Throw a ParseException if the binary token tree is improperly formatted
    • This throws an exception during the parsing stage in expressions such as 2b, b c d, etc.
arithmexp - v0.0.4

Published by Muqsit about 2 years ago

  • Postfix expression has spaces in-between when var_dump()-ing an Expression
arithmexp - v0.0.3

Published by Muqsit about 2 years ago

  • Added support for exponential (**) binary operator
  • Added support for modulo (%) binary operator
arithmexp - v0.0.2

Published by Muqsit about 2 years ago

arithmexp - Initial Release

Published by Muqsit about 2 years ago

This is the initial release of muqsit/arithmexp.