|
parser 1.0.0
UTF-8 CEL expression compilation and checked library extensions
|
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.
This tutorial builds the parser and its runtime from source as static libraries inside your application's CMake build. No installation or package prefix is needed.
Use CMake 3.24 or later, Ninja, Git, and a C++20 compiler with floating-point std::from_chars and IEEE binary64 double. Do not enable fast-math. The first configuration downloads pinned build infrastructure and cel-runtime. You need Git read access to both repositories; no separate runtime checkout is required. The commands below use a POSIX shell.
Create an application directory:
Create a directory for the CPM bootstrap:
Save this bootstrap as cmake/CPM.cmake:
CMake downloads and verifies CPM before executing it. A checksum mismatch stops configuration. Keep the version and checksum together when updating.
Save the complete first-expression program from the main page as main.cpp in your application directory. Create CMakeLists.txt beside it:
Configure, build, and run from your application directory:
Confirm that the test passes and prints 5. CPM builds both libraries from source as static libraries by default. Dependency builds omit the libraries' tests and CEL package installation rules. CPM_USE_LOCAL_PACKAGES OFF keeps CPM from preferring installed packages. No install command is part of this build.
The cel::parser target supplies the C++20 requirement and links the static cel::runtime dependency. Do not add dependency include or library directories manually. Select a reviewed release after @ when updating the dependency; the parser selects its own pinned runtime revision.
Continue with Compile and reuse expressions to cache programs after their source strings and compiler are destroyed.