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

Function print_error_message

smallthinker/tests/test-gbnf-validator.cpp:39–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39static void print_error_message(const std::string & input_str, size_t error_pos, const std::string & error_msg) {
40 fprintf(stdout, "Input string is invalid according to the grammar.\n");
41 fprintf(stdout, "Error: %s at position %zu\n", error_msg.c_str(), error_pos);
42 fprintf(stdout, "\n");
43 fprintf(stdout, "Input string:\n");
44 fprintf(stdout, "%s", input_str.substr(0, error_pos).c_str());
45 if (error_pos < input_str.size()) {
46 fprintf(stdout, "\033[1;31m%c", input_str[error_pos]);
47 if (error_pos+1 < input_str.size()) {
48 fprintf(stdout, "\033[0;31m%s", input_str.substr(error_pos+1).c_str());
49 }
50 fprintf(stdout, "\033[0m\n");
51 }
52}
53
54int main(int argc, char** argv) {
55 if (argc != 3) {

Callers 1

mainFunction · 0.85

Calls 4

fprintfFunction · 0.85
substrMethod · 0.80
c_strMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected