Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 961 Bytes

README.md

File metadata and controls

26 lines (20 loc) · 961 Bytes

Metaphrase*

A Java project (perhaps a library once it gets competent enough) for parsing and interpreting math equations.

Usage

Currently running the main class brings up a REPL, which can be used for entering equations or running a little benchmark:

repl_showcase

In code:

String equation = "((3 - 8 / (1 - 10 * (5)) * 4) / 3) * 8 / 5 / 1";
int wantedDecimalPlaces = 30;
Tokenizer tokenizer = new Tokenizer(equation, wantedDecimalPlaces);
Token topOfAST = Parser.parseTokens(tokenizer.getTokens(), tokenizer.getMathContext());
topOfAST.

eval(); // returns BigDecimal: "1.94829931946666666666666666667"

To Dos

  • BigDecimal instead of Doubles for accuracy (Done)
  • more error prone to unorthodox equations (e.g. "2---1" could be evaluated as "2-(-(-1))")
  • more operators
  • trigonometric functions support

*an anagram for "parse math"