#binary #expression #tree #parser


Helps parsing and evaluating binary expression trees

11 releases (3 stable)

1.0.2 Sep 27, 2022
1.0.1 Mar 5, 2022
1.0.0 May 4, 2021
0.4.0 Feb 2, 2021
0.1.0 Jun 14, 2020

#41 in Template engine

Download history 329/week @ 2023-02-13 494/week @ 2023-02-20 316/week @ 2023-02-27 347/week @ 2023-03-06 470/week @ 2023-03-13 395/week @ 2023-03-20 395/week @ 2023-03-27 207/week @ 2023-04-03 296/week @ 2023-04-10 256/week @ 2023-04-17 299/week @ 2023-04-24 400/week @ 2023-05-01 239/week @ 2023-05-08 333/week @ 2023-05-15 367/week @ 2023-05-22 302/week @ 2023-05-29

1,294 downloads per month
Used in 4 crates

MIT license

637 lines

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 designed for very fast evaluation.

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

bet is used in rhit to filter log lines.

bet is used in lfs to filter filesystems.

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.

No runtime deps