Skip to main content

llama_cpp_gbnf/
gbnf_validation_error.rs

1use std::ffi::NulError;
2
3#[derive(Debug, thiserror::Error, PartialEq, Eq)]
4pub enum GbnfValidationError {
5    #[error("grammar string contains an interior NUL byte")]
6    GrammarContainsNul(#[source] NulError),
7    #[error("grammar root name contains an interior NUL byte")]
8    RootContainsNul(#[source] NulError),
9    #[error("grammar has a syntax error and could not be parsed")]
10    SyntaxError,
11    #[error("grammar defines no rules")]
12    EmptyRuleSet,
13    #[error("grammar does not define the root symbol {root:?}")]
14    RootSymbolMissing { root: String },
15    #[error("grammar is left-recursive and cannot be compiled by llama.cpp")]
16    LeftRecursion,
17    #[error("the llama.cpp grammar engine threw an exception")]
18    GrammarEngineThrew,
19}