This is a rust implementation of the CEL language.
This project is built for BountyHub platform, but is open-source and can be used by anyone.
If you find any issues, please report them.
git clone https://github.com/nikola-jokic/cellang.git
cd cellang
cargo buildThe workspace is fully covered by automated checks. Locally you can mirror CI with:
cargo test --locked --all-features --all-targets
cargo test --locked --all-features --docExamples under crates/cellang/examples can be exercised via:
cd crates/cellang
for example in examples/*.rs; do \
name=$(basename "${example%.rs}"); \
cargo test --locked --all-features --example "$name"; \
doneor run directly with cargo run --example <name> for interactive experimentation.
| Example | Highlights |
|---|---|
simple |
Basic expression evaluation, child runtimes, and scalar values. |
create_function |
Registering function declarations plus native Rust implementations. |
concurrency |
Sharing a runtime builder across threads for parallel evaluation. |
user_role_derive |
Using the derive feature to expose Rust structs and methods to CEL. |
comprehensions |
Practical use of CEL macros like exists, filter, map, and all. |
env_snapshot |
Building, serializing, and rehydrating a reusable environment snapshot. |
The cellang-cli crate exposes a developer-friendly command line interface for inspecting CEL programs.
cargo run -p cellang-cli -- lex expr --format json "a + size(b)"
cargo run -p cellang-cli -- parse file --path script.cel --format debug
cargo run -p cellang-cli -- eval expr --expr "users[0].has_role(role)" --env-path ./env.jsonSubcommands:
lex– emit tokens for a file or inline expression (formatted as pretty JSON or debug output).parse– dump the AST generated by the Pratt parser.eval– evaluate an expression within a runtime populated from a JSON environment file.
This repository is a rust workspace, with the following crates:
cellang: The main library crate located at libcellang-cli: A CLI tool to evaluate CEL expressions located at cli
This project is licensed under the MIT license.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the MIT license, shall be licensed as above, without any additional terms or conditions.
Special thanks to Jon Gjengset for his amazing video which helped me get started with this project.