parser 1.0.0
UTF-8 CEL expression compilation and checked library extensions
Loading...
Searching...
No Matches
diagnostic.hpp
1// SPDX-License-Identifier: BSL-1.0
2#ifndef CEL_PARSER_DIAGNOSTIC_HPP
3#define CEL_PARSER_DIAGNOSTIC_HPP
4#include <cstddef>
5#include <stdexcept>
6#include <string>
7
9namespace cel {
12
16 std::size_t begin = 0;
17 std::size_t end = 0;
18
20 bool operator==(const source_span&) const = default;
21};
22
33
36class parse_error : public std::runtime_error {
37 error_category category_;
38 source_span span_;
39
40public:
46 [[nodiscard]] error_category category() const noexcept { return category_; }
48 [[nodiscard]] source_span span() const noexcept { return span_; }
49};
50
52} // namespace cel
53#endif
parse_error(error_category category, source_span span, std::string message)
Constructs a diagnostic with an owned message, category, and byte interval. Precondition: span....
error_category category() const noexcept
Returns the category supplied at construction.
Definition diagnostic.hpp:46
source_span span() const noexcept
Returns the byte interval supplied at construction, without translating offsets.
Definition diagnostic.hpp:48
error_category
Classifies a source diagnostic independently of its human-readable message. Example: error_category::...
Definition diagnostic.hpp:25
@ resource_limit
A documented producer or compilation resource limit.
Definition diagnostic.hpp:31
@ malformed_input
Invalid UTF-8, spelling, comment, or input character.
Definition diagnostic.hpp:26
@ type_error
An unknown, unsupported, ineligible, or incompatible type.
Definition diagnostic.hpp:28
@ unsupported_literal
A literal or suffix outside bool/binary64 scope.
Definition diagnostic.hpp:27
@ lookup_error
An undefined name or unmatched operation signature.
Definition diagnostic.hpp:29
@ delimiter_error
An unmatched, mismatched, or unclosed delimiter.
Definition diagnostic.hpp:30
Provides checked CEL compilation, extension libraries, and owned results.
Definition compiler.hpp:10
Identifies a half-open UTF-8 byte interval; begin never exceeds end. Example: source_span{0,...
Definition diagnostic.hpp:15
bool operator==(const source_span &) const =default
Returns true if both byte offsets are equal.
std::size_t begin
Inclusive byte offset in the producer's source.
Definition diagnostic.hpp:16
std::size_t end
Exclusive byte offset; equal to begin for an empty interval.
Definition diagnostic.hpp:17