| 340 | } |
| 341 | |
| 342 | trace_format* parse_item_from_format_string(agent* thisAgent) |
| 343 | { |
| 344 | trace_format* tf, *pattern; |
| 345 | char* ch; |
| 346 | list* attribute_path; |
| 347 | int n; |
| 348 | |
| 349 | if (*format == 0) |
| 350 | { |
| 351 | return NIL; |
| 352 | } |
| 353 | if (*format == ']') |
| 354 | { |
| 355 | return NIL; |
| 356 | } |
| 357 | if (*format == '[') |
| 358 | { |
| 359 | format_string_error_message = "unexpected '[' character"; |
| 360 | return NIL; |
| 361 | } |
| 362 | |
| 363 | if (*format != '%') |
| 364 | { |
| 365 | char buf[MAX_LEXEME_LENGTH + 20]; |
| 366 | |
| 367 | ch = buf; |
| 368 | while ((*format != 0) && (*format != '%') && |
| 369 | (*format != '[') && (*format != ']')) |
| 370 | { |
| 371 | *ch++ = *format++; |
| 372 | } |
| 373 | *ch = 0; |
| 374 | tf = static_cast<trace_format_struct*>(allocate_memory(thisAgent, sizeof(trace_format), |
| 375 | MISCELLANEOUS_MEM_USAGE)); |
| 376 | tf->type = STRING_TFT; |
| 377 | tf->data.string = make_memory_block_for_string(thisAgent, buf); |
| 378 | return tf; |
| 379 | } |
| 380 | |
| 381 | /* --- otherwise *format is '%', so parse the escape sequence --- */ |
| 382 | |
| 383 | if (!strncmp(format, "%v", 2)) |
| 384 | { |
| 385 | format += 2; |
| 386 | attribute_path = parse_attribute_path_in_brackets(thisAgent); |
| 387 | if (format_string_error_message) |
| 388 | { |
| 389 | return NIL; |
| 390 | } |
| 391 | tf = static_cast<trace_format_struct*>(allocate_memory(thisAgent, sizeof(trace_format), |
| 392 | MISCELLANEOUS_MEM_USAGE)); |
| 393 | tf->type = VALUES_TFT; |
| 394 | tf->data.attribute_path = attribute_path; |
| 395 | return tf; |
| 396 | } |
| 397 | |
| 398 | if (!strncmp(format, "%o", 2)) |
| 399 | { |
no test coverage detected