| 48 | } |
| 49 | |
| 50 | bool ExplainChunks(agent* thisAgent, const char* pProduction, int mode) |
| 51 | { |
| 52 | // mode == -1 full |
| 53 | // mode == 0 name |
| 54 | // mode > 0 condition |
| 55 | |
| 56 | get_lexeme_from_string(thisAgent, const_cast<char*>(pProduction)); |
| 57 | |
| 58 | if (thisAgent->lexeme.type != SYM_CONSTANT_LEXEME) |
| 59 | { |
| 60 | return false; // invalid production |
| 61 | } |
| 62 | |
| 63 | switch (mode) |
| 64 | { |
| 65 | case -1: // full |
| 66 | { |
| 67 | explain_chunk_str* chunk = find_chunk(thisAgent, thisAgent->explain_chunk_list, thisAgent->lexeme.string); |
| 68 | if (chunk) |
| 69 | { |
| 70 | explain_trace_chunk(thisAgent, chunk); |
| 71 | } |
| 72 | } |
| 73 | break; |
| 74 | case 0: |
| 75 | { |
| 76 | explain_chunk_str* chunk = find_chunk(thisAgent, thisAgent->explain_chunk_list, thisAgent->lexeme.string); |
| 77 | if (!chunk) |
| 78 | { |
| 79 | return false; |
| 80 | } |
| 81 | |
| 82 | /* First print out the production in "normal" form */ |
| 83 | print(thisAgent, "(sp %s\n ", chunk->name); |
| 84 | print_condition_list(thisAgent, chunk->conds, 2, false); |
| 85 | print(thisAgent, "\n-->\n "); |
| 86 | print_action_list(thisAgent, chunk->actions, 3, false); |
| 87 | print(thisAgent, ")\n\n"); |
| 88 | |
| 89 | /* Then list each condition and the associated "ground" WME */ |
| 90 | int i = 0; |
| 91 | condition* ground = chunk->all_grounds; |
| 92 | |
| 93 | for (condition* cond = chunk->conds; cond != NIL; cond = cond->next) |
| 94 | { |
| 95 | i++; |
| 96 | print(thisAgent, " %2d : ", i); |
| 97 | print_condition(thisAgent, cond); |
| 98 | |
| 99 | while (get_printer_output_column(thisAgent) < COLUMNS_PER_LINE - 40) |
| 100 | { |
| 101 | print(thisAgent, " "); |
| 102 | } |
| 103 | |
| 104 | print(thisAgent, " Ground :"); |
| 105 | print_condition(thisAgent, ground); |
| 106 | print(thisAgent, "\n"); |
| 107 | ground = ground->next; |
no test coverage detected