Expand description
2026-09-26: JSON Schema to EBNF conversion. json_schema_to_ebnf parses the schema
into a JsonValue, resolves it into a SchemaSpec (parser*), and emits the EBNF
rules (converter, gen_*); json_schema_to_grammar parses that EBNF into
GrammarData.
JsonValue keeps object entries in document order, and SchemaSpec::properties is
filled in that order. An allOf with more than one schema is generated as any.
Owner: grammar. Invariants: none beyond the types.
Structs§
- Schema
Converter Options - Options controlling JSON-schema -> EBNF conversion. Field meanings
match the
JSONSchemaToEBNFparameters in the C++ header. - Schema
Error - An error raised while converting a JSON Schema document into an EBNF grammar string.
Enums§
- Json
Format - Root output format.
Jsonproduces a fully JSON-style grammar; the XML variants produce an XML-style root object with JSON-style inner values (used for tool calling). Mirrors C++JSONFormat. - Json
Value - An order-preserving JSON value.
- Schema
Error Kind - Classification of a schema-conversion failure, mirroring the C++
SchemaErrorTypeenum.
Functions§
- builtin_
json_ grammar - Build the parsed
GrammarDatafor the builtin-JSON grammar. - builtin_
json_ grammar_ ebnf - Build the EBNF grammar for the “any JSON value” schema (
{}). - deepseek_
xml_ tool_ calling_ to_ ebnf - Convert a function-call parameter schema into a DeepSeek-XML-style
EBNF grammar. Port of
DeepSeekXMLToolCallingToEBNF. - generate_
float_ range_ regex - Generate a regex matching floats in
[start, end]inclusive, each boundNonemeaning unbounded, with at mostprecisionfractional digits. Port ofGenerateFloatRangeRegex. - generate_
range_ regex - Generate a regex matching integers in
[start, end](inclusive), each boundNonemeaning unbounded. Port ofGenerateRangeRegex. - json_
schema_ to_ ebnf - Convert a JSON Schema string into an EBNF grammar string. Port
of the
std::stringoverload ofJSONSchemaToEBNF. - json_
schema_ to_ grammar - Convert a JSON Schema string into a parsed
GrammarDataAST by generating the EBNF and feeding it through the EBNF parser. - json_
value_ to_ ebnf - Convert a JSON Schema document (already parsed into a
JsonValue) into an EBNF grammar string. Port of thepicojson::valueoverload ofJSONSchemaToEBNF. - minimax_
xml_ tool_ calling_ to_ ebnf - Convert a function-call parameter schema into a MiniMax-XML-style
EBNF grammar. Port of
MiniMaxXMLToolCallingToEBNF. - qwen_
xml_ tool_ calling_ to_ ebnf - Convert a function-call parameter schema into a Qwen-XML-style
EBNF grammar. Port of
QwenXMLToolCallingToEBNF.
Type Aliases§
- Schema
Result - Convenience alias for converter results.