bet 0.3.2

Helps parsing and evaluating binary expression trees
Documentation

MIT Latest Version docs Chat on Miaou

A library building and preparing expressions, for example boolean expressions such as (A | B) & !(C | D | E), which can be executed on dynamic contents.

An expression is built by calling the push_operator, open_par, close_par and push_atom functions.

It can then be evaluated with the eval function which takes as parameters

  • a function which gives a value to an atom
  • a function which, given an operator and one or two values, gives a new value
  • a function deciding whether to short-circuit

Normal evaluation order is left to right but is modified with parenthesis.

bet is designed around separation of building, transformations, and evaluation, so that an expression can be efficiently applied on many inputs.

bet is used in broot to let users type composite queries on files.

Limits:

  • no operator precedence: evaluation is left to right when there's no parenthesis

Usage and documentation: docs.rs/bet

If you wonder whether bet could be applied to your problems, don't hesitate to come and discuss. If you know a documented crate with overlapping use cases, tell me too so that I may list it here as alternative.