{"id":16499191,"url":"https://github.com/hardbyte/common-expression-language","last_synced_at":"2026-03-11T21:39:04.966Z","repository":{"id":174887718,"uuid":"652432613","full_name":"hardbyte/common-expression-language","owner":"hardbyte","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-26T06:01:05.000Z","size":136,"stargazers_count":7,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-12T05:07:23.186Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hardbyte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-12T04:17:59.000Z","updated_at":"2025-08-27T07:59:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"66af6714-2a8c-462e-8dba-1f75cfddf706","html_url":"https://github.com/hardbyte/common-expression-language","commit_stats":null,"previous_names":["hardbyte/common-expression-language"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hardbyte/common-expression-language","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardbyte%2Fcommon-expression-language","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardbyte%2Fcommon-expression-language/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardbyte%2Fcommon-expression-language/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardbyte%2Fcommon-expression-language/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hardbyte","download_url":"https://codeload.github.com/hardbyte/common-expression-language/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardbyte%2Fcommon-expression-language/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30401959,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T21:02:20.017Z","status":"ssl_error","status_checked_at":"2026-03-11T20:59:32.667Z","response_time":84,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T14:51:28.718Z","updated_at":"2026-03-11T21:39:04.951Z","avatar_url":"https://github.com/hardbyte.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"\nLearning Rust by playing with the [Common Expression Language](https://github.com/google/cel-spec).\n\n## Plan\n\n- Write a very basic CEL Lexer/Parser in Rust (using [Chumsky](https://crates.io/crates/chumsky))\n- Evaluate the parsed CEL AST by implementing a basic Treewalk interpreter\n- Write a basic CLI for evaluating CEL expressions with data loaded from stdin or a JSON/YAML file.\n- Create rust packages for the Lexer/Parser and Interpreter\n- See how conformant we can get to the CEL spec, parse the test data and evaluate the expressions.\n- Wrap for Python\n\n### Extensions\n\n- Use a Pratt parser ~once~ now that Chumsky supports it (https://github.com/zesterer/chumsky/pull/464)\n- Possibly write a bytecode compiler for a simple stack based VM...\n- Research and try the existing Rust implementations of CEL.\n- Benchmark the Cloud Custodian Python-CEL implementation against the Rust ones.\n- Use an existing Lexer like [Logos](https://docs.rs/logos/latest/logos/)\n\n\n## Execution\n\n```\ncargo run -- --expression=\"-(3.0 + 5.0) * 2.0e0 - -1.0\"\n```\nWhich outputs something like:\n```\nAST:\nArithmetic(Arithmetic(Unary(Neg, Arithmetic(Atom(Float(3.0)), Add, Atom(Float(5.0)))), Multiply, Atom(Float(2.0))), Subtract, Unary(Neg, Atom(Float(1.0))))\n\nEvaluating program\nNumericCelType(Float(-15.0))\n```\n\nNote while the parser is close to complete I'm not intending to implement a full interpreter\nwith all built-in functions.\n\nThe interpreter has basic support for strings, numbers, bools, lists, maps, variables, and\nbinary and unary operators.\n\n\n```shell\ncargo run -- --expression=\"size('hello world') \u003e 5u\"\n```\n\nOutputs:\n```\nAST:\nRelation(Member(Ident(\"size\"), FunctionCall([Atom(String(\"hello world\"))])), GreaterThan, Atom(UInt(5)))\n\nEvaluating program\nBool(true)\n```\n### Context\n\nTo add context from a JSON file use `--input` with either a filename or `-` to read from\nstdin:\n\n```shell\necho \"{\\\"foo\\\":\\\"bar\\\"}\" | cargo run -- --expression=\"foo\" --input -\n```\n\nOutputs:\n\n```\nParsed context data: Object {\"foo\": String(\"bar\")}\nAST:\nIdent(\"foo\")\n\nEvaluating program\nString(\"bar\")\n```\n\n\n### Python Bindings\n\nA Python package `rustycel` using PyO3 in `python_bindings` offers a simple `evaluate` function from Python:\n\n```python\n\u003e\u003e\u003e import rustycel\n\u003e\u003e\u003e rustycel.evaluate(\"1u + 4u\")\n5\n```\n\n_Note only a few primitive types are mapped back to Python native types._\n\n\n# References\n\n## Existing CEL Implementations\n\n- [cel-go](https://github.com/google/cel-go) - Reference implementation of CEL by Google in Go.\n- [cel-python](https://github.com/cloud-custodian/cel-python) - Python implementation of CEL by Cloud Custodian\n  as used in [Netchecks](https://github.com/hardbyte/netchecks).\n- [clarkmcc/cel-rust](https://github.com/clarkmcc/cel-rust) (Maintained fork of [orf/cel-rust](https://github.com/orf/cel-rust).)\n  Implements separate crates for parser (using lalrpop) and interpreter (straightforward treewalk interpreter).\n- [thesayyn/cel-rust](https://github.com/thesayyn/cel-rust) (Incomplete). WASM target with online [demo](https://thesayyn.github.io/cel-rust/).\n  Parser uses lalrpop.\n\nTest Data\n\nhttps://github.com/google/cel-spec/blob/master/tests/simple/testdata/basic.textproto\n\n## Real parsers using Chumsky\n\n- [jaq](https://github.com/01mf02/jaq/blob/main/jaq-parse/src/token.rs)\n- https://github.com/panda-re/panda/blob/dev/panda/plugins/cosi_strace/src/c_type_parser.rs\n- [prql](https://github.com/PRQL/prql/blob/main/prql-compiler/src/parser) (uses a separate Chumsky Lexer to create Vec\u003cToken\u003e, then parses Token stream into Expr, Stmt, Literal etc)\n- [flux](https://github.com/fluxed-lang/flux/blob/main/crates/compiler/fluxc_parser/src/lib.rs) - lexed with [Logos](https://github.com/fluxed-lang/flux/blob/main/crates/compiler/fluxc_lexer/src/lib.rs) then parsed with Chumsky.\n- [Cotton](https://github.com/nanikamado/cotton/blob/main/compiler/parser/src/parse.rs) Separate Chumsky Lexer and Parser.\n- [Cornucopia](https://github.com/cornucopia-rs/cornucopia/blob/main/crates/cornucopia/src/parser.rs) parses SQL.\n- [percival](https://github.com/ekzhang/percival/blob/main/crates/percival/src/parser.rs) nice split between Lexer and Parser with WASM target.\n- [monty](https://github.com/mental32/monty/blob/master/montyc_parser/src/comb.rs) uses a lot of Rust macros\n- [blackstone](https://github.com/BlackstoneDF/blackstone/blob/main/src/parser/parse.rs)\n- [savage](https://github.com/p-e-w/savage/blob/master/savage_core/src/parse.rs)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardbyte%2Fcommon-expression-language","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhardbyte%2Fcommon-expression-language","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardbyte%2Fcommon-expression-language/lists"}