| 397 | } |
| 398 | |
| 399 | void print_grammar(FILE * file, const parse_state & state) { |
| 400 | try { |
| 401 | std::map<uint32_t, std::string> symbol_id_names; |
| 402 | for (const auto & kv : state.symbol_ids) { |
| 403 | symbol_id_names[kv.second] = kv.first; |
| 404 | } |
| 405 | for (size_t i = 0, end = state.rules.size(); i < end; i++) { |
| 406 | // fprintf(file, "%zu: ", i); |
| 407 | // print_rule_binary(file, state.rules[i]); |
| 408 | print_rule(file, uint32_t(i), state.rules[i], symbol_id_names); |
| 409 | // fprintf(file, "\n"); |
| 410 | } |
| 411 | } catch (const std::exception & err) { |
| 412 | fprintf(stderr, "\n%s: error printing grammar: %s\n", __func__, err.what()); |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | std::vector<const llama_grammar_element *> parse_state::c_rules() { |
| 417 | std::vector<const llama_grammar_element *> ret; |
nothing calls this directly
no test coverage detected