Skip to content

A dart library to compute mathematical expressions with high customizability

License

Notifications You must be signed in to change notification settings

theskyblockman/math_compute

Repository files navigation

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.

About

A dart library to compute mathematical expressions with high customizability

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages