pub mod json_schema;
pub mod lark;
pub mod mask;
pub mod parser;
pub mod regex_gbnf;
pub(crate) mod repetition;
pub mod request;
pub mod sampler;
pub mod serialize;
pub mod structural_tag;
#[allow(unused_imports)]
pub use parser::{
parse, parse_with_token_resolver, parse_with_tokenizer, Grammar, GretElement, GretType,
ParseError,
};
#[allow(unused_imports)]
pub use sampler::{
GrammarRuntime, LazyGrammarConfig, PartialUtf8, Pos, Stack, Stacks,
MAX_LAZY_TRIGGER_BUFFER_BYTES,
};
#[allow(unused_imports)]
pub use serialize::{rename_rules, serialize};
#[cfg(test)]
pub(crate) mod test_fixtures {
pub(crate) const PEER_GRAMMARS: &[(&str, &str)] = &[
(
"arithmetic.gbnf",
include_str!("../../../../scripts/fixtures/grammars/peer/arithmetic.gbnf"),
),
(
"c.gbnf",
include_str!("../../../../scripts/fixtures/grammars/peer/c.gbnf"),
),
(
"chess.gbnf",
include_str!("../../../../scripts/fixtures/grammars/peer/chess.gbnf"),
),
(
"english.gbnf",
include_str!("../../../../scripts/fixtures/grammars/peer/english.gbnf"),
),
(
"japanese.gbnf",
include_str!("../../../../scripts/fixtures/grammars/peer/japanese.gbnf"),
),
(
"json.gbnf",
include_str!("../../../../scripts/fixtures/grammars/peer/json.gbnf"),
),
(
"json_arr.gbnf",
include_str!("../../../../scripts/fixtures/grammars/peer/json_arr.gbnf"),
),
(
"list.gbnf",
include_str!("../../../../scripts/fixtures/grammars/peer/list.gbnf"),
),
];
pub(crate) fn peer_grammar(name: &str) -> &'static str {
PEER_GRAMMARS
.iter()
.find_map(|(fixture_name, source)| (*fixture_name == name).then_some(*source))
.unwrap_or_else(|| panic!("unknown peer grammar fixture: {name}"))
}
}