Expand description
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"] - Objects:
{"key": value, ...} - Arithmetic:
+,-,*,/,^ - Comparison:
==,!=,<,<=,>,>= - Logical:
and,or,not - String ops:
contains,startswith,endswith,matches - Membership:
in - Array/object access:
a[0],obj["key"],obj.key - Functions:
len(s),type(v),keys(obj) - Quantifiers:
expr forall x in arr
§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());