A CompilerLibrary represents a package of CEL configuration that can be added to a Compiler. It may contain either or both of a Parser configuration and a TypeChecker configuration.
| 41 | // It may contain either or both of a Parser configuration and a |
| 42 | // TypeChecker configuration. |
| 43 | struct CompilerLibrary { |
| 44 | // Optional identifier to avoid collisions re-adding the same library. |
| 45 | // If id is empty, it is not considered. |
| 46 | std::string id; |
| 47 | // Optional callback for configuring the parser. |
| 48 | ParserBuilderConfigurer configure_parser; |
| 49 | // Optional callback for configuring the type checker. |
| 50 | TypeCheckerBuilderConfigurer configure_checker; |
| 51 | |
| 52 | CompilerLibrary(std::string id, ParserBuilderConfigurer configure_parser, |
| 53 | TypeCheckerBuilderConfigurer configure_checker = nullptr) |
| 54 | : id(std::move(id)), |
| 55 | configure_parser(std::move(configure_parser)), |
| 56 | configure_checker(std::move(configure_checker)) {} |
| 57 | |
| 58 | CompilerLibrary(std::string id, |
| 59 | TypeCheckerBuilderConfigurer configure_checker) |
| 60 | : id(std::move(id)), |
| 61 | configure_parser(std::move(nullptr)), |
| 62 | configure_checker(std::move(configure_checker)) {} |
| 63 | |
| 64 | // Convenience conversion from the CheckerLibrary type. |
| 65 | // |
| 66 | // Note: if a related CompilerLibrary exists, prefer to use that to |
| 67 | // include expected parser configuration. |
| 68 | static CompilerLibrary FromCheckerLibrary(CheckerLibrary checker_library) { |
| 69 | return CompilerLibrary(std::move(checker_library.id), |
| 70 | /*configure_parser=*/nullptr, |
| 71 | std::move(checker_library.configure)); |
| 72 | } |
| 73 | |
| 74 | // For backwards compatibility. To be removed. |
| 75 | // NOLINTNEXTLINE(google-explicit-constructor) |
| 76 | CompilerLibrary(CheckerLibrary checker_library) |
| 77 | : id(std::move(checker_library.id)), |
| 78 | configure_parser(nullptr), |
| 79 | configure_checker(std::move(checker_library.configure)) {} |
| 80 | }; |
| 81 | |
| 82 | struct CompilerLibrarySubset { |
| 83 | // The id of the library to subset. Only one subset can be applied per |
no outgoing calls