Skip to content

nikola-jokic/cellang

CEL language interpreter for Rust

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.

Getting started

git clone https://github.com/nikola-jokic/cellang.git
cd cellang
cargo build

Running the test suite

The 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 --doc

Examples 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"; \
done

or run directly with cargo run --example <name> for interactive experimentation.

Example overview

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.

CLI

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.json

Subcommands:

  • 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.

Repository structure

This repository is a rust workspace, with the following crates:

  • cellang: The main library crate located at lib
  • cellang-cli: A CLI tool to evaluate CEL expressions located at cli

License

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

Special thanks to Jon Gjengset for his amazing video which helped me get started with this project.

About

CEL interpreter, parser, lexer, and other utilities

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages