1#pragma once
2
3#include <nlohmann/json_fwd.hpp>
4
5#include <functional>
6#include <string>
7
8std::string json_schema_to_grammar(const nlohmann::ordered_json & schema,
9 bool force_gbnf = false);
10
11struct common_grammar_builder {
12 std::function<std::string(const std::string &, const std::string &)> add_rule;
13 std::function<std::string(const std::string &, const nlohmann::ordered_json &)> add_schema;
14 std::function<void(nlohmann::ordered_json &)> resolve_refs;
15};
16
17struct common_grammar_options {
18 bool dotall = false;
19};
20
21std::string build_grammar(const std::function<void(const common_grammar_builder &)> & cb, const common_grammar_options & options = {});
22