parser 1.0.0
UTF-8 CEL expression compilation and checked library extensions
Loading...
Searching...
No Matches
CEL parser

Note: This project is a temporary solution for using the CEL language from cel-rs in C++. This library will be deprecated when using the Rust implementations from C++ becomes viable.

Compile decoded UTF-8 std::string_view expressions once, then execute the owned programs on a reusable stack. This C++20 library supports a bool/f64 subset of CEL and lets you add client types and operations. JSON decoding belongs to your application.

Build from source with CPM

Use CPM to build the parser and its runtime as static libraries with your application. After adding CPM to your project, declare the dependency and link your application target:

set(CPM_USE_LOCAL_PACKAGES OFF)
include(cmake/CPM.cmake)
CPMAddPackage("gh:stlab/cel-parser@1.0.0")
add_executable(client main.cpp)
target_link_libraries(client PRIVATE cel::parser)

The build tutorial includes compiler prerequisites and configure/build commands. You do not need an installation, package prefix, or separate runtime checkout.

Compile your first expression

Include <cel/parser.hpp> to compile and execute a scalar:

#include <cel/parser.hpp>
#include <iostream>
int main() try {
auto program = compiler.parse_str("2.0 + 3.0").prepare<double>();
cel::raw_stack stack;
std::cout << program.call(stack) << '\n';
} catch (const std::exception& error) {
std::cerr << error.what() << '\n';
return 1;
}
Owns exact registrations, nominal schemas, and LIFO scope callbacks. Owns copied names,...
Definition lookup.hpp:81
Owns lookup state and compiles CEL expressions into reusable checked programs. Each successful call r...
Definition compiler.hpp:37
compiled_segment parse_str(std::string_view source)
Compiles one complete decoded UTF-8 CEL source through an owned source copy. Selects grammar alternat...
Provides UTF-8 expression compilation, checked library extensions, and source diagnostics.

The program prints 5. Numeric values require floating syntax: 2.0, not 2. Preparation binds the result type once; later calls reuse the program and stack.

Follow the tutorials

Read these guides in order:

  1. Build and link the parser with CPM.
  2. Compile and reuse expressions.
  3. Add an extension library.
  4. Check the supported language.

The generated documentation places grouped APIs under Reference and symbol lookup under Index. Build it with cmake --preset docs followed by cmake --build --preset docs, then open build/docs/html/index.html.