metrale_grammar/schema/
mod.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3//! 2026-09-26: JSON Schema to EBNF conversion. `json_schema_to_ebnf` parses the schema
4//! into a `JsonValue`, resolves it into a `SchemaSpec` (`parser*`), and emits the EBNF
5//! rules (`converter`, `gen_*`); `json_schema_to_grammar` parses that EBNF into
6//! `GrammarData`.
7//!
8//! `JsonValue` keeps object entries in document order, and `SchemaSpec::properties` is
9//! filled in that order. An `allOf` with more than one schema is generated as `any`.
10//!
11//! Owner: grammar.
12//! Invariants: none beyond the types.
13
14mod api;
15mod cache_key;
16mod converter;
17mod error;
18mod float_regex;
19mod formats;
20mod gen_array;
21mod gen_composite;
22mod gen_object;
23mod gen_object_props;
24mod gen_object_props_constrained;
25mod gen_scalar;
26mod indent;
27mod json_value;
28mod options;
29mod parser;
30mod parser_collections;
31mod parser_composite;
32mod range_regex;
33mod script;
34mod spec;
35
36#[cfg(test)]
37mod tests;
38
39pub use api::{
40    builtin_json_grammar, builtin_json_grammar_ebnf, deepseek_xml_tool_calling_to_ebnf,
41    json_schema_to_ebnf, json_schema_to_grammar, json_value_to_ebnf,
42    minimax_xml_tool_calling_to_ebnf, qwen_xml_tool_calling_to_ebnf,
43};
44pub use error::{SchemaError, SchemaErrorKind, SchemaResult};
45pub use float_regex::generate_float_range_regex;
46pub use json_value::JsonValue;
47pub use options::{JsonFormat, SchemaConverterOptions};
48pub use range_regex::generate_range_regex;