MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / print_grammar

Function print_grammar

common/grammar-parser.cpp:399–414  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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;

Callers

nothing calls this directly

Calls 4

fprintfFunction · 0.85
print_ruleFunction · 0.70
sizeMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected