MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / dump

Method dump

subprojects/llama.cpp/common/peg-parser.cpp:805–863  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

803}
804
805std::string common_peg_arena::dump(common_peg_parser_id id) const {
806 const auto & parser = parsers_.at(id);
807
808 return std::visit([this](const auto & p) -> std::string {
809 using T = std::decay_t<decltype(p)>;
810
811 if constexpr (std::is_same_v<T, common_peg_epsilon_parser>) {
812 return "Epsilon";
813 } else if constexpr (std::is_same_v<T, common_peg_start_parser>) {
814 return "Start";
815 } else if constexpr (std::is_same_v<T, common_peg_end_parser>) {
816 return "End";
817 } else if constexpr (std::is_same_v<T, common_peg_literal_parser>) {
818 return "Literal(" + p.literal + ")";
819 } else if constexpr (std::is_same_v<T, common_peg_sequence_parser>) {
820 std::vector<std::string> parts;
821 for (const auto & child : p.children) {
822 parts.push_back(dump(child));
823 }
824 return "Sequence(" + string_join(parts, ", ") + ")";
825 } else if constexpr (std::is_same_v<T, common_peg_choice_parser>) {
826 std::vector<std::string> parts;
827 for (const auto & child : p.children) {
828 parts.push_back(dump(child));
829 }
830 return "Choice(" + string_join(parts, ", ") + ")";
831 } else if constexpr (std::is_same_v<T, common_peg_repetition_parser>) {
832 if (p.max_count == -1) {
833 return "Repetition(" + dump(p.child) + ", " + std::to_string(p.min_count) + ", unbounded)";
834 }
835 return "Repetition(" + dump(p.child) + ", " + std::to_string(p.min_count) + ", " + std::to_string(p.max_count) + ")";
836 } else if constexpr (std::is_same_v<T, common_peg_and_parser>) {
837 return "And(" + dump(p.child) + ")";
838 } else if constexpr (std::is_same_v<T, common_peg_not_parser>) {
839 return "Not(" + dump(p.child) + ")";
840 } else if constexpr (std::is_same_v<T, common_peg_any_parser>) {
841 return "Any";
842 } else if constexpr (std::is_same_v<T, common_peg_space_parser>) {
843 return "Space";
844 } else if constexpr (std::is_same_v<T, common_peg_chars_parser>) {
845 if (p.max_count == -1) {
846 return "CharRepeat(" + p.pattern + ", " + std::to_string(p.min_count) + ", unbounded)";
847 }
848 return "CharRepeat(" + p.pattern + ", " + std::to_string(p.min_count) + ", " + std::to_string(p.max_count) + ")";
849 } else if constexpr (std::is_same_v<T, common_peg_json_string_parser>) {
850 return "JsonString()";
851 } else if constexpr (std::is_same_v<T, common_peg_until_parser>) {
852 return "Until(" + string_join(p.delimiters, " | ") + ")";
853 } else if constexpr (std::is_same_v<T, common_peg_schema_parser>) {
854 return "Schema(" + dump(p.child) + ", " + (p.schema ? p.schema->dump() : "null") + ")";
855 } else if constexpr (std::is_same_v<T, common_peg_rule_parser>) {
856 return "Rule(" + p.name + ", " + dump(p.child) + ")";
857 } else if constexpr (std::is_same_v<T, common_peg_ref_parser>) {
858 return "Ref(" + p.name + ")";
859 } else {
860 return "Unknown";
861 }
862 }, parser);

Callers 15

generate_completionMethod · 0.45
params_from_json_cmplMethod · 0.45
convert_anthropic_to_oaiFunction · 0.45
safe_json_to_strFunction · 0.45
normalizeFunction · 0.45
renormalize_jsonFunction · 0.45
testFunction · 0.45

Calls 5

dumpFunction · 0.85
string_joinFunction · 0.85
to_stringFunction · 0.85
atMethod · 0.65
push_backMethod · 0.45

Tested by 12

normalizeFunction · 0.36
renormalize_jsonFunction · 0.36
testFunction · 0.36
test_with_argsFunction · 0.36
test_json_healingFunction · 0.36
test_template_cppFunction · 0.36
test_template_pyFunction · 0.36
test_json_serializationFunction · 0.36