cctr-expr 0.5.0

Expression language parser and evaluator for cctr constraints
Documentation

Expression language parser and evaluator for cctr constraints.

Supports:

  • Numbers: 42, -3.14, 0.5
  • Strings: "hello", "with \"escapes\""
  • Booleans: true, false
  • Arrays: [1, 2, 3], ["a", "b"]
  • Arithmetic: +, -, *, /, ^
  • Comparison: ==, !=, <, <=, >, >=
  • Logical: and, or, not
  • String ops: contains, startswith, endswith, matches
  • Membership: in
  • Functions: len(s)

Example

use cctr_expr::{eval_bool, Value};
use std::collections::HashMap;

let mut vars = HashMap::new();
vars.insert("n".to_string(), Value::Number(42.0));

assert!(eval_bool("n > 0 and n < 100", &vars).unwrap());