math_compute 0.1.0 copy "math_compute: ^0.1.0" to clipboard
math_compute: ^0.1.0 copied to clipboard

A library to lex, parse and compute mathematical expressions.

Math lexer/parser/evaluator #

A highly customizable and easy to use math expression lexer/parser/evaluator

Features #

  • Comprehensible error system with originating token
  • Customizable math context
    • Custom token types
    • Custom constants
    • Custom functions
    • Custom operators
  • Token constructors and validators aware of surrounding tokens in lexer
  • Parser to Reverse Polish Notation
  • Parser to compute tree
  • Simple to use recursively-based evaluator

Getting started #

Add this package to your Dart/Flutter project via

dart pub add math_parser

or

flutter pub add math_parser

Usage #

You can find samples in the example page.

To compute an expression, simply put it in the "compute" function:

final result = compute('2 + 2');
print(result); // 4

Additional information #

If I was able to write this package myself it is thanks to Thorsten Ball's "Writing an interpreter in Go". I recommend this book for any projects like this.

1
likes
150
points
2
downloads

Publisher

unverified uploader

Weekly Downloads

A library to lex, parse and compute mathematical expressions.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

logging, rational

More

Packages that depend on math_compute