Soar Kernel  9.3.2 08-06-12
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Macros | Functions
print.cpp File Reference
#include <portability.h>
#include <stdlib.h>
#include "print.h"
#include "kernel.h"
#include "agent.h"
#include "symtab.h"
#include "init_soar.h"
#include "wmem.h"
#include "gdatastructs.h"
#include "rete.h"
#include "rhsfun.h"
#include "production.h"
#include "instantiations.h"
#include "xml.h"
#include "soar_TraceNames.h"
#include <stdarg.h>

Go to the source code of this file.

Macros

#define PRINT_ACTION_LIST_TEMP_SIZE   10000
#define PRINT_BUFSIZE   5000 /* This better be large enough!! */
#define PRINT_CONDITION_LIST_TEMP_SIZE   10000

Functions

void filtered_print_wme_add (agent *thisAgent, wme *w)
void filtered_print_wme_remove (agent *thisAgent, wme *w)
int get_printer_output_column (agent *thisAgent)
Bool passes_wme_filtering (agent *thisAgent, wme *w, Bool isAdd)
Bool pick_actions_with_matching_id (dl_cons *dc, agent *thisAgent)
Bool pick_conds_with_matching_id_test (dl_cons *dc, agent *thisAgent)
char preference_type_indicator (agent *thisAgent, byte type)
void print (agent *thisAgent, const char *format,...)
void print_action (agent *thisAgent, action *a)
void print_action_list (agent *thisAgent, action *actions, int indent, Bool internal)
void print_condition (agent *thisAgent, condition *cond)
void print_condition_list (agent *thisAgent, condition *conds, int indent, Bool internal)
void print_instantiation_with_wmes (agent *thisAgent, instantiation *inst, wme_trace_type wtt, int action)
void print_list_of_conditions (agent *thisAgent, condition *cond)
void print_phase (agent *thisAgent, const char *s, bool end_of_phase)
void print_preference (agent *thisAgent, preference *pref)
void print_production (agent *thisAgent, production *p, Bool internal)
void print_spaces (agent *thisAgent, int n)
void print_string (agent *thisAgent, const char *s)
void print_with_symbols (agent *thisAgent, const char *format,...)
void print_wme (agent *thisAgent, wme *w)
void print_wme_for_tcl (agent *thisAgent, wme *w)
void print_wme_without_timetag (agent *thisAgent, wme *w)
char * rhs_value_to_string (agent *thisAgent, rhs_value rv, char *dest, size_t dest_size)
void snprintf_with_symbols (agent *thisAgent, char *dest, size_t count, const char *format,...)
char * string_to_escaped_string (agent *thisAgent, char *s, char first_and_last_char, char *dest)
char * symbol_to_string (agent *thisAgent, Symbol *sym, Bool rereadable, char *dest, size_t dest_size)
char const * symbol_to_typeString (agent *, Symbol *sym)
void tell_printer_that_output_column_has_been_reset (agent *thisAgent)
char * test_to_string (agent *thisAgent, test t, char *dest, size_t dest_size)
void vsnprintf_with_symbols (agent *thisAgent, char *dest, size_t count, const char *format, va_list args)
Bool wme_filter_component_match (Symbol *filterComponent, Symbol *wmeComponent)

Macro Definition Documentation

#define PRINT_ACTION_LIST_TEMP_SIZE   10000

Definition at line 679 of file print.cpp.

Referenced by print_action_list().

#define PRINT_BUFSIZE   5000 /* This better be large enough!! */

Definition at line 100 of file print.cpp.

Referenced by print(), print_spaces(), and print_with_symbols().

#define PRINT_CONDITION_LIST_TEMP_SIZE   10000

Definition at line 504 of file print.cpp.

Referenced by print_condition_list().

Function Documentation

void filtered_print_wme_add ( agent thisAgent,
wme w 
)

Definition at line 980 of file print.cpp.

References passes_wme_filtering(), print(), print_wme(), TRUE, xml_begin_tag(), and xml_end_tag().

Referenced by do_buffered_wm_changes().

{
if (passes_wme_filtering(thisAgent, w,TRUE))
{
print (thisAgent, "=>WM: ");
xml_begin_tag(thisAgent, kTagWMEAdd);
print_wme(thisAgent, w);
xml_end_tag(thisAgent, kTagWMEAdd);
}
}
void filtered_print_wme_remove ( agent thisAgent,
wme w 
)

Definition at line 990 of file print.cpp.

References FALSE, passes_wme_filtering(), print(), print_wme(), xml_begin_tag(), and xml_end_tag().

Referenced by do_buffered_wm_changes().

{
if (passes_wme_filtering(thisAgent, w,FALSE))
{
print (thisAgent, "<=WM: ");
xml_begin_tag(thisAgent, kTagWMERemove);
print_wme(thisAgent, w); /* print_wme takes care of tagged output itself */
xml_end_tag(thisAgent, kTagWMERemove);
}
}
int get_printer_output_column ( agent thisAgent)
Bool passes_wme_filtering ( agent thisAgent,
wme w,
Bool  isAdd 
)

Definition at line 1215 of file print.cpp.

References wme_filter_struct::adds, wme_filter_struct::attr, wme_struct::attr, FALSE, cons_struct::first, wme_filter_struct::id, wme_struct::id, NIL, wme_filter_struct::removes, cons_struct::rest, TRUE, wme_filter_struct::value, wme_struct::value, wme_filter_component_match(), and agent_struct::wme_filter_list.

Referenced by filtered_print_wme_add(), and filtered_print_wme_remove().

{
cons *c;
/* print ("testing wme for filtering: "); print_wme(w); */
for (c=thisAgent->wme_filter_list; c!=NIL; c=c->rest) {
wf = (wme_filter *) c->first;
/* print_with_symbols(thisAgent, " trying filter: %y ^%y %y\n",wf->id,wf->attr,wf->value); */
if ( ((isAdd && wf->adds) || ((!isAdd) && wf->removes)) &&
return FALSE;
}
return TRUE; /* no defined filters match -> w passes */
}
Bool pick_actions_with_matching_id ( dl_cons dc,
agent thisAgent 
)

Definition at line 672 of file print.cpp.

References agent_struct::action_id_to_match, FALSE, action_struct::id, dl_cons_struct::item, MAKE_ACTION, rhs_value_to_symbol(), and action_struct::type.

Referenced by print_action_list().

{
action *a;
a = static_cast<action_struct *>(dc->item);
if (a->type!=MAKE_ACTION) return FALSE;
return (rhs_value_to_symbol(a->id) == thisAgent->action_id_to_match);
}
Bool pick_conds_with_matching_id_test ( dl_cons dc,
agent thisAgent 
)
char preference_type_indicator ( agent thisAgent,
byte  type 
)

Definition at line 915 of file print.cpp.

References abort_with_fatal_error(), ACCEPTABLE_PREFERENCE_TYPE, BEST_PREFERENCE_TYPE, BETTER_PREFERENCE_TYPE, BINARY_INDIFFERENT_PREFERENCE_TYPE, BINARY_PARALLEL_PREFERENCE_TYPE, BUFFER_MSG_SIZE, NUMERIC_INDIFFERENT_PREFERENCE_TYPE, PROHIBIT_PREFERENCE_TYPE, RECONSIDER_PREFERENCE_TYPE, REJECT_PREFERENCE_TYPE, REQUIRE_PREFERENCE_TYPE, UNARY_INDIFFERENT_PREFERENCE_TYPE, UNARY_PARALLEL_PREFERENCE_TYPE, WORSE_PREFERENCE_TYPE, and WORST_PREFERENCE_TYPE.

Referenced by print_action_list(), and print_preference().

{
switch (type) {
case ACCEPTABLE_PREFERENCE_TYPE: return '+';
case REQUIRE_PREFERENCE_TYPE: return '!';
case REJECT_PREFERENCE_TYPE: return '-';
case PROHIBIT_PREFERENCE_TYPE: return '~';
case RECONSIDER_PREFERENCE_TYPE: return '@';
case BEST_PREFERENCE_TYPE: return '>';
case BETTER_PREFERENCE_TYPE: return '>';
case WORST_PREFERENCE_TYPE: return '<';
case WORSE_PREFERENCE_TYPE: return '<';
default:
{ char msg[BUFFER_MSG_SIZE];
strncpy(msg,
"print.c: Error: bad type passed to preference_type_indicator\n", BUFFER_MSG_SIZE);
msg[BUFFER_MSG_SIZE - 1] = 0; /* ensure null termination */
abort_with_fatal_error(thisAgent, msg);
}
}
return 0; /* unreachable, but without it, gcc -Wall warns here */
}
void print ( agent thisAgent,
const char *  format,
  ... 
)

Definition at line 102 of file print.cpp.

References PRINT_BUFSIZE, and print_string().

Referenced by abort_with_fatal_error(), abs_rhs_function_code(), add_input_wme(), add_output_function(), add_preference_to_tm(), add_rhs_function(), atan2_rhs_function_code(), backtrace_through_instantiation(), capitalize_symbol_rhs_function_code(), check_unbound_negative_relational_test_referents(), chunk_instantiation(), collect_root_variables(), compute_heading_rhs_function_code(), compute_range_rhs_function_code(), cos_rhs_function_code(), create_instantiation(), create_new_context(), create_soar_agent(), deallocate_preference(), decide_non_context_slot(), determine_highest_active_production_level_in_stack_apply(), determine_highest_active_production_level_in_stack_propose(), determine_type_of_constituent_string(), div_rhs_function_code(), do_buffered_wm_changes(), do_one_top_level_phase(), do_preference_phase(), do_working_memory_phase(), dont_learn_rhs_function_code(), elaborate_gds(), epmem_init_db(), epmem_new_episode(), epmem_process_query(), excise_production(), explain_cond_list(), explain_list_chunks(), explain_trace(), explain_trace_chunk(), exploration_boltzmann_select(), exploration_epsilon_greedy_select(), filtered_print_wme_add(), filtered_print_wme_remove(), find_chunk(), find_goal_for_match_set_change_retraction(), find_ground(), float_rhs_function_code(), force_learn_rhs_function_code(), fp_divide_rhs_function_code(), generate_chunk_name_sym_constant(), get_io_symbol_from_tio_constituent_string(), get_next_char(), goal_stack_consistent_through_goal(), highest_active_goal_apply(), highest_active_goal_propose(), ifeq_rhs_function_code(), int_rhs_function_code(), lex_quote(), lex_unknown(), lex_vbar(), load_rete_net(), make_preference(), make_production(), minus_rhs_function_code(), mod_rhs_function_code(), p_node_left_addition(), p_node_left_removal(), parse_attr_value_make(), parse_attr_value_tests(), parse_cond(), parse_disjunction_test(), parse_format_string(), parse_function_call_after_lparen(), parse_head_of_conds_for_one_id(), parse_preferences_soar8_non_operator(), parse_production(), parse_relational_test(), parse_rhs_action(), parse_rhs_value(), post_link_addition(), post_link_removal(), ppmi_aux(), print_action_list(), print_assertion(), print_candidates(), print_condition_list(), print_consed_list_of_condition_wmes(), print_consed_list_of_conditions(), print_identifier_ref_info(), print_instantiation_with_wmes(), print_list_of_conditions(), print_location_of_most_recent_lexeme(), print_match_set(), print_memory_statistics(), print_partial_match_information(), print_phase(), print_preference(), print_production(), print_retraction(), print_saved_test_list(), print_trace_format_list(), print_tracing_rule(), print_tracing_rule_tcl(), print_whole_token(), print_wme(), print_wme_for_tcl(), print_wme_without_timetag(), process_o_rejects_and_deallocate_them(), read_identifier_or_context_variable(), remove_input_wme(), remove_operator_if_necessary(), remove_preference_from_tm(), reorder_action_list(), reorder_lhs(), reorder_simplified_conditions(), reset_id_counters(), reset_wme_timetags(), restore_and_deallocate_saved_tests(), retract_instantiation(), rl_perform_update(), rl_store_data(), round_off_air_rhs_function_code(), round_off_heading_air_rhs_function_code(), save_rete_net(), set_sysparam(), smem_path_param::set_value(), epmem_path_param::set_value(), should_variablize(), shouldCreateInstantiation(), sin_rhs_function_code(), smem_init_db(), smem_store_chunk(), soar_list_all_callbacks(), soar_list_all_callbacks_for_event(), sqrt_rhs_function_code(), stats_init_db(), stop_lex_from_file(), trim_rhs_function_code(), wma_activate_wme(), wma_go(), wma_remove_decay_element(), wma_update_decay_histories(), and xml_partial_match_information().

{
va_list args;
char buf[PRINT_BUFSIZE];
va_start (args, format);
vsprintf (buf, format, args);
va_end (args);
print_string (thisAgent, buf);
}
void print_action ( agent thisAgent,
action a 
)

Definition at line 906 of file print.cpp.

References action_struct::next, NIL, print_action_list(), and TRUE.

{
action *old_next;
old_next = a->next;
a->next = NIL;
print_action_list (thisAgent, a, 0, TRUE);
a->next = old_next;
}
void print_action_list ( agent thisAgent,
action actions,
int  indent,
Bool  internal 
)

Definition at line 680 of file print.cpp.

References agent_struct::action_id_to_match, add_to_growable_string(), action_struct::attr, COLUMNS_PER_LINE, agent_struct::dl_cons_pool, extract_dl_list_elements(), FALSE, free_growable_string(), FUNCALL_ACTION, action_struct::id, dl_cons_struct::item, make_blank_growable_string(), action_struct::next, dl_cons_struct::next, NIL, pick_actions_with_matching_id(), preference_is_binary(), action_struct::preference_type, preference_type_indicator(), dl_cons_struct::prev, print(), PRINT_ACTION_LIST_TEMP_SIZE, print_spaces(), print_string(), print_with_symbols(), agent_struct::printer_output_column, action_struct::referent, remove_from_dll, rhs_value_to_string(), rhs_value_to_symbol(), text_of_growable_string(), TRUE, action_struct::type, action_struct::value, xml_att_val(), xml_begin_tag(), and xml_end_tag().

Referenced by chunk_instantiation(), explain_cond_list(), print_action(), and print_production().

{
Bool did_one_line_already;
dl_list *actions_not_yet_printed, *tail_of_actions_not_yet_printed;
dl_list *actions_for_this_id;
dl_cons *dc;
action *a;
if (!actions) return;
did_one_line_already = FALSE;
/* --- build dl_list of all the actions --- */
actions_not_yet_printed = NIL;
tail_of_actions_not_yet_printed = NIL;
for (a=actions; a!=NIL; a=a->next) {
allocate_with_pool (thisAgent, &thisAgent->dl_cons_pool, &dc);
dc->item = a;
if (actions_not_yet_printed) tail_of_actions_not_yet_printed->next = dc;
else actions_not_yet_printed = dc;
dc->prev = tail_of_actions_not_yet_printed;
tail_of_actions_not_yet_printed = dc;
}
tail_of_actions_not_yet_printed->next = NIL;
/* --- main loop: find all actions for first id, print them together --- */
while (actions_not_yet_printed) {
if (did_one_line_already) {
print (thisAgent, "\n");
print_spaces (thisAgent, indent);
} else {
did_one_line_already = TRUE;
}
dc = actions_not_yet_printed;
remove_from_dll (actions_not_yet_printed, dc, next, prev);
a = static_cast<action_struct *>(dc->item);
if (a->type==FUNCALL_ACTION) {
free_with_pool (&thisAgent->dl_cons_pool, dc);
xml_begin_tag(thisAgent, kTagAction);
print_string (thisAgent, rhs_value_to_string (thisAgent, a->value, NULL, 0));
xml_att_val(thisAgent, kAction, rhs_value_to_string (thisAgent, a->value, NULL, 0));
xml_end_tag(thisAgent, kTagAction);
continue;
}
/* --- normal make actions --- */
/* --- collect all actions whose id matches the first action's id --- */
actions_for_this_id = dc;
dc->prev = NIL;
if (internal) {
dc->next = NIL;
} else {
dc->next = extract_dl_list_elements (thisAgent, &actions_not_yet_printed,
}
/* --- print the collected actions all together --- */
print_with_symbols (thisAgent, "(%y", thisAgent->action_id_to_match);
xml_begin_tag(thisAgent, kTagAction);
xml_att_val(thisAgent, kActionId, thisAgent->action_id_to_match);
while (actions_for_this_id) {
dc = actions_for_this_id;
actions_for_this_id = actions_for_this_id->next;
a = static_cast<action_struct *>(dc->item);
free_with_pool (&thisAgent->dl_cons_pool, dc);
{ /* --- build and print attr/value test for action a --- */
char temp[PRINT_ACTION_LIST_TEMP_SIZE], *ch;
ch = temp;
strncpy (ch, " ^", PRINT_ACTION_LIST_TEMP_SIZE - (ch - temp)); while (*ch) ch++;
rhs_value_to_string (thisAgent, a->attr, ch, PRINT_ACTION_LIST_TEMP_SIZE - (ch - temp));
while (*ch) ch++;
*(ch++) = ' ';
rhs_value_to_string (thisAgent, a->value, ch, PRINT_ACTION_LIST_TEMP_SIZE - (ch - temp));
while (*ch) ch++;
*(ch++) = ' ';
*(ch++) = preference_type_indicator (thisAgent, a->preference_type);
*(ch++) = ' ';
rhs_value_to_string (thisAgent, a->referent, ch, PRINT_ACTION_LIST_TEMP_SIZE - (ch - temp));
while (*ch) ch++;
}
*ch = 0;
if (thisAgent->printer_output_column + (ch - temp) >=
print_string (thisAgent, "\n");
print_spaces (thisAgent, indent+6);
}
print_string (thisAgent, temp);
add_to_growable_string(thisAgent, &gs, temp);
}
}
xml_att_val(thisAgent, kAction, text_of_growable_string(gs));
free_growable_string(thisAgent, gs);
print_string (thisAgent, ")");
xml_end_tag(thisAgent, kTagAction);
} /* end of while (actions_not_yet_printed) */
}
void print_condition ( agent thisAgent,
condition cond 
)

Definition at line 894 of file print.cpp.

References condition_struct::next, NIL, condition_struct::prev, print_condition_list(), and TRUE.

Referenced by build_chunk_conds_for_grounds_and_add_negateds(), explain_cond_list(), explain_trace(), explain_trace_chunk(), ppmi_aux(), print_consed_list_of_conditions(), and print_list_of_conditions().

{
condition *old_next, *old_prev;
old_next = cond->next;
old_prev = cond->prev;
cond->next = NIL;
cond->prev = NIL;
print_condition_list (thisAgent, cond, 0, TRUE);
cond->next = old_next;
cond->prev = old_prev;
}
void print_condition_list ( agent thisAgent,
condition conds,
int  indent,
Bool  internal 
)

Definition at line 505 of file print.cpp.

References add_to_growable_string(), three_field_tests_struct::attr_test, COLUMNS_PER_LINE, CONJUNCTIVE_NEGATION_CONDITION, copy_of_equality_test_found_in_test(), copy_test_removing_goal_impasse_tests(), condition_struct::data, deallocate_test(), agent_struct::dl_cons_pool, extract_dl_list_elements(), FALSE, free_growable_string(), three_field_tests_struct::id_test, agent_struct::id_test_to_match, dl_cons_struct::item, make_blank_growable_string(), condition_struct::condition_main_data_union::ncc, NEGATIVE_CONDITION, dl_cons_struct::next, condition_struct::next, NIL, pick_conds_with_matching_id_test(), dl_cons_struct::prev, print(), print_condition_list(), PRINT_CONDITION_LIST_TEMP_SIZE, print_spaces(), print_string(), agent_struct::printer_output_column, remove_from_dll, condition_struct::test_for_acceptable_preference, test_is_blank_test(), test_to_string(), condition_struct::condition_main_data_union::tests, text_of_growable_string(), ncc_info_struct::top, TRUE, condition_struct::type, three_field_tests_struct::value_test, xml_att_val(), xml_begin_tag(), and xml_end_tag().

Referenced by chunk_instantiation(), explain_cond_list(), print_condition(), print_condition_list(), and print_production().

{
dl_list *conds_not_yet_printed, *tail_of_conds_not_yet_printed;
dl_list *conds_for_this_id;
dl_cons *dc;
Bool removed_goal_test, removed_impasse_test;
test id_test;
if (!conds) return;
/* --- build dl_list of all the actions --- */
conds_not_yet_printed = NIL;
tail_of_conds_not_yet_printed = NIL;
for (c=conds; c!=NIL; c=c->next)
{
allocate_with_pool (thisAgent, &thisAgent->dl_cons_pool, &dc);
dc->item = c;
if (conds_not_yet_printed)
{
tail_of_conds_not_yet_printed->next = dc;
}
else
{
conds_not_yet_printed = dc;
}
dc->prev = tail_of_conds_not_yet_printed;
tail_of_conds_not_yet_printed = dc;
}
tail_of_conds_not_yet_printed->next = NIL;
/* --- main loop: find all conds for first id, print them together --- */
Bool did_one_line_already = FALSE;
while (conds_not_yet_printed)
{
if (did_one_line_already)
{
print (thisAgent, "\n");
print_spaces (thisAgent, indent);
}
else
{
did_one_line_already = TRUE;
}
dc = conds_not_yet_printed;
remove_from_dll (conds_not_yet_printed, dc, next, prev);
c = static_cast<condition_struct *>(dc->item);
{
free_with_pool (&thisAgent->dl_cons_pool, dc);
print_string (thisAgent, "-{");
xml_begin_tag(thisAgent, kTagConjunctive_Negation_Condition);
print_condition_list (thisAgent, c->data.ncc.top, indent+2, internal);
xml_end_tag(thisAgent, kTagConjunctive_Negation_Condition);
print_string (thisAgent, "}");
continue;
}
/* --- normal pos/neg conditions --- */
removed_goal_test = removed_impasse_test = FALSE;
&removed_goal_test,
&removed_impasse_test);
thisAgent->id_test_to_match = copy_of_equality_test_found_in_test (thisAgent, id_test);
/* --- collect all cond's whose id test matches this one --- */
conds_for_this_id = dc;
dc->prev = NIL;
if (internal)
{
dc->next = NIL;
}
else
{
dc->next = extract_dl_list_elements (thisAgent, &conds_not_yet_printed,
}
/* --- print the collected cond's all together --- */
print_string (thisAgent, " (");
xml_begin_tag(thisAgent, kTagCondition);
if (removed_goal_test)
{
print_string (thisAgent, "state ");
xml_att_val(thisAgent, kConditionTest, kConditionTestState);
}
if (removed_impasse_test)
{
print_string (thisAgent, "impasse ");
xml_att_val(thisAgent, kConditionTest, kConditionTestImpasse);
}
print_string (thisAgent, test_to_string (thisAgent, id_test, NULL, 0));
xml_att_val(thisAgent, kConditionId, test_to_string (thisAgent, id_test, NULL, 0));
deallocate_test (thisAgent, thisAgent->id_test_to_match);
deallocate_test (thisAgent, id_test);
while (conds_for_this_id)
{
dc = conds_for_this_id;
conds_for_this_id = conds_for_this_id->next;
c = static_cast<condition_struct *>(dc->item);
free_with_pool (&thisAgent->dl_cons_pool, dc);
{ /* --- build and print attr/value test for condition c --- */
ch = temp;
strncpy (ch, " ", PRINT_CONDITION_LIST_TEMP_SIZE - (ch - temp));
{
strncat (ch, "-", PRINT_CONDITION_LIST_TEMP_SIZE - (ch - temp));
}
while (*ch) ch++;
strncpy (ch, "^", PRINT_CONDITION_LIST_TEMP_SIZE - (ch - temp));
while (*ch) ch++;
test_to_string (thisAgent, c->data.tests.attr_test, ch, PRINT_CONDITION_LIST_TEMP_SIZE - (ch - temp));
while (*ch) ch++;
{
*(ch++) = ' ';
test_to_string (thisAgent, c->data.tests.value_test, ch, PRINT_CONDITION_LIST_TEMP_SIZE - (ch - temp));
while (*ch) ch++;
{
strncpy (ch, " +", PRINT_CONDITION_LIST_TEMP_SIZE - (ch - temp));
while (*ch) ch++;
}
}
*ch = 0;
if (thisAgent->printer_output_column + (ch - temp) >= COLUMNS_PER_LINE)
{
print_string (thisAgent, "\n");
print_spaces (thisAgent, indent+6);
}
print_string (thisAgent, temp);
add_to_growable_string(thisAgent, &gs, temp);
}
}
xml_att_val(thisAgent, kCondition, text_of_growable_string(gs));
free_growable_string(thisAgent, gs);
print_string (thisAgent, ")");
xml_end_tag(thisAgent, kTagCondition);
} /* end of while (conds_not_yet_printed) */
}
void print_instantiation_with_wmes ( agent thisAgent,
instantiation inst,
wme_trace_type  wtt,
int  action 
)

Definition at line 1040 of file print.cpp.

References condition_struct::bt, FULL_WME_TRACE, bt_info_struct::level, production_struct::name, condition_struct::next, NIL, NONE_WME_TRACE, POSITIVE_CONDITION, print(), print_with_symbols(), print_wme(), instantiation_struct::prod, symbol_to_string(), wme_struct::timetag, TIMETAG_WME_TRACE, TOP_GOAL_LEVEL, instantiation_struct::top_of_instantiated_conditions, condition_struct::type, bt_info_struct::wme_, xml_att_val(), xml_begin_tag(), and xml_end_tag().

Referenced by create_instantiation(), elaborate_gds(), print_match_set(), and retract_instantiation().

{
int PRINTING = -1;
int FIRING = 0;
int RETRACTING = 1;
condition *cond;
if (action == PRINTING) {
xml_begin_tag(thisAgent, kTagProduction);
} else if (action == FIRING) {
xml_begin_tag(thisAgent, kTagProduction_Firing);
xml_begin_tag(thisAgent, kTagProduction);
} else if (action == RETRACTING) {
xml_begin_tag(thisAgent, kTagProduction_Retracting);
xml_begin_tag(thisAgent, kTagProduction);
}
if (inst->prod) {
print_with_symbols (thisAgent, "%y", inst->prod->name);
xml_att_val(thisAgent, kProduction_Name, symbol_to_string (thisAgent, inst->prod->name, true, 0, 0));
} else {
print (thisAgent, "[dummy production]");
xml_att_val(thisAgent, kProduction_Name, "[dummy_production]");
}
print (thisAgent, "\n");
if (wtt==NONE_WME_TRACE) {
if (action == PRINTING) {
xml_end_tag(thisAgent, kTagProduction);
} else if (action == FIRING) {
xml_end_tag(thisAgent, kTagProduction);
xml_end_tag(thisAgent, kTagProduction_Firing);
} else if (action == RETRACTING) {
xml_end_tag(thisAgent, kTagProduction);
xml_end_tag(thisAgent, kTagProduction_Retracting);
}
return;
}
for (cond=inst->top_of_instantiated_conditions; cond!=NIL; cond=cond->next)
if (cond->type==POSITIVE_CONDITION) {
switch (wtt) {
print (thisAgent, " %lu", cond->bt.wme_->timetag);
xml_begin_tag(thisAgent, kTagWME);
xml_att_val(thisAgent, kWME_TimeTag, cond->bt.wme_->timetag);
xml_end_tag(thisAgent, kTagWME);
break;
// Not all conds and wme_'s available when retracting, depending on DO_TOP_LEVEL_REF_CTS
#ifdef DO_TOP_LEVEL_REF_CTS
print (thisAgent, " ");
print_wme (thisAgent, cond->bt.wme_);
#else
if (action != RETRACTING && cond->bt.level > TOP_GOAL_LEVEL) {
print (thisAgent, " ");
print_wme (thisAgent, cond->bt.wme_);
} else {
// Wmes that matched the LHS of a retraction may already be free'd; just print tt.
print (thisAgent, " %lu", cond->bt.wme_->timetag);
xml_begin_tag(thisAgent, kTagWME);
xml_att_val(thisAgent, kWME_TimeTag, cond->bt.wme_->timetag);
xml_end_tag(thisAgent, kTagWME);
}
#endif
break;
}
}
if (action == PRINTING) {
xml_end_tag(thisAgent, kTagProduction);
} else if (action == FIRING) {
xml_end_tag(thisAgent, kTagProduction);
xml_end_tag(thisAgent, kTagProduction_Firing);
} else if (action == RETRACTING) {
xml_end_tag(thisAgent, kTagProduction);
xml_end_tag(thisAgent, kTagProduction_Retracting);
}
}
void print_list_of_conditions ( agent thisAgent,
condition cond 
)

Definition at line 1131 of file print.cpp.

References COLUMNS_PER_LINE, get_printer_output_column(), condition_struct::next, print(), and print_condition().

Referenced by explain_trace_chunk().

{
while (cond != NULL) {
print (thisAgent, "\n ");
print_condition (thisAgent, cond);
print (thisAgent, "\n");
cond = cond->next;
}
}
void print_phase ( agent thisAgent,
const char *  s,
bool  end_of_phase 
)

Definition at line 1143 of file print.cpp.

References APPLY_PHASE, agent_struct::current_phase, DECISION_PHASE, agent_struct::FIRING_TYPE, IE_PRODS, INPUT_PHASE, OUTPUT_PHASE, PE_PRODS, PREFERENCE_PHASE, print(), PROPOSE_PHASE, WM_PHASE, xml_att_val(), xml_begin_tag(), and xml_end_tag().

Referenced by do_one_top_level_phase().

{
// should be more consistent with creating string, but for now, for
// consistency with previous versions, we'll let calling code set string.
print (thisAgent, s);
// the rest is all for tagged output events
xml_begin_tag(thisAgent, kTagPhase);
if (end_of_phase) {
xml_att_val(thisAgent, kPhase_Status, kPhaseStatus_End);
}
switch (thisAgent->current_phase) {
xml_att_val(thisAgent, kPhase_Name, kPhaseName_Input);
break;
xml_att_val(thisAgent, kPhase_Name, kPhaseName_Pref);
break;
case WM_PHASE:
xml_att_val(thisAgent, kPhase_Name, kPhaseName_WM);
switch (thisAgent->FIRING_TYPE) {
case PE_PRODS: /* no longer needed; Soar8 has PROPOSE/APPLY */
xml_att_val(thisAgent, kPhase_FiringType, kPhaseFiringType_PE);
break;
case IE_PRODS:
xml_att_val(thisAgent, kPhase_FiringType, kPhaseFiringType_IE);
break;
}
break;
xml_att_val(thisAgent, kPhase_Name, kPhaseName_Decision);
break;
xml_att_val(thisAgent, kPhase_Name, kPhaseName_Output);
break;
xml_att_val(thisAgent, kPhase_Name, kPhaseName_Propose);
break;
xml_att_val(thisAgent, kPhase_Name, kPhaseName_Apply);
break;
default:
xml_att_val(thisAgent, kPhase_Name, kPhaseName_Unknown);
break;
} // end switch
xml_end_tag(thisAgent, kTagPhase);
return;
}
void print_preference ( agent thisAgent,
preference pref 
)

Definition at line 942 of file print.cpp.

References preference_struct::attr, preference_struct::id, preference_struct::o_supported, preference_is_binary(), preference_type_indicator(), print(), print_string(), print_with_symbols(), preference_struct::referent, preference_struct::type, preference_struct::value, xml_att_val(), xml_begin_tag(), and xml_end_tag().

Referenced by add_preference_to_tm(), chunk_instantiation(), create_instantiation(), deallocate_preference(), decide_non_context_slot(), decision_consistent_with_current_preferences(), elaborate_gds(), make_preference(), process_o_rejects_and_deallocate_them(), remove_preference_from_tm(), retract_instantiation(), trace_locals(), and trace_ungrounded_potentials().

{
char pref_type = preference_type_indicator (thisAgent, pref->type);
print_with_symbols (thisAgent, "(%y ^%y %y ", pref->id, pref->attr, pref->value);
print (thisAgent, "%c", pref_type);
if (preference_is_binary(pref->type)) {
print_with_symbols (thisAgent, " %y", pref->referent);
}
if (pref->o_supported) print_string (thisAgent, " :O ");
print_string (thisAgent, ")");
print (thisAgent, "\n");
// <preference id="s1" attr="foo" value="123" pref_type=">"></preference>
xml_begin_tag(thisAgent, kTagPreference);
xml_att_val(thisAgent, kWME_Id, pref->id);
xml_att_val(thisAgent, kWME_Attribute, pref->attr);
xml_att_val(thisAgent, kWME_Value, pref->value);
char buf[2];
buf[0] = pref_type;
buf[1] = 0;
xml_att_val(thisAgent, kPreference_Type, buf);
if (preference_is_binary(pref->type)) {
xml_att_val(thisAgent, kReferent, pref->referent);
}
if (pref->o_supported) {
xml_att_val(thisAgent, kOSupported, ":O");
}
xml_end_tag(thisAgent, kTagPreference);
}
void print_production ( agent thisAgent,
production p,
Bool  internal 
)

Definition at line 789 of file print.cpp.

References CHUNK_PRODUCTION_TYPE, deallocate_action_list(), deallocate_condition_list(), DECLARED_I_SUPPORT, DECLARED_O_SUPPORT, production_struct::declared_support, DEFAULT_PRODUCTION_TYPE, production_struct::documentation, production_struct::interrupt, JUSTIFICATION_PRODUCTION_TYPE, MAX_LEXEME_LENGTH, production_struct::name, NIL, production_struct::p_node, p_node_to_conditions_and_nots(), print(), print_action_list(), print_condition_list(), print_string(), print_with_symbols(), string_to_escaped_string(), TEMPLATE_PRODUCTION_TYPE, production_struct::type, USER_PRODUCTION_TYPE, xml_att_val(), xml_begin_tag(), and xml_end_tag().

Referenced by chunk_instantiation().

{
condition *top, *bottom;
action *rhs;
/*
--- print "sp" and production name ---
*/
print_with_symbols (thisAgent, "sp {%y\n", p->name);
xml_begin_tag(thisAgent, kTagProduction);
xml_att_val(thisAgent, kProduction_Name, p->name);
/*
--- print optional documention string ---
*/
if (p->documentation)
{
char temp[MAX_LEXEME_LENGTH*2+10];
string_to_escaped_string (thisAgent, p->documentation, '"', temp);
print (thisAgent, " %s\n", temp);
xml_att_val(thisAgent, kProductionDocumentation, temp);
}
/*
--- print any flags ---
*/
switch (p->type)
{
print_string (thisAgent, " :default\n");
xml_att_val(thisAgent, kProductionType, kProductionTypeDefault);
break;
break;
print_string (thisAgent, " :chunk\n");
xml_att_val(thisAgent, kProductionType, kProductionTypeChunk);
break;
print_string (thisAgent, " :justification ;# not reloadable\n");
xml_att_val(thisAgent, kProductionType, kProductionTypeJustification);
break;
print_string (thisAgent, " :template\n");
xml_att_val(thisAgent, kProductionType, kProductionTypeTemplate);
break;
}
{
print_string (thisAgent, " :o-support\n");
xml_att_val(thisAgent, kProductionDeclaredSupport, kProductionDeclaredOSupport);
}
{
print_string (thisAgent, " :i-support\n");
xml_att_val(thisAgent, kProductionDeclaredSupport, kProductionDeclaredISupport);
}
if (p->interrupt)
print_string(thisAgent, " :interrupt\n");
/*
--- print the LHS and RHS ---
*/
&top, &bottom, NIL,&rhs);
print_string (thisAgent, " ");
xml_begin_tag(thisAgent, kTagConditions);
print_condition_list (thisAgent, top, 3, internal);
xml_end_tag(thisAgent, kTagConditions);
deallocate_condition_list (thisAgent, top);
print_string (thisAgent, "\n -->\n ");
print_string (thisAgent, " ");
xml_begin_tag(thisAgent, kTagActions);
print_action_list (thisAgent, rhs, 4, internal);
xml_end_tag(thisAgent, kTagActions);
print_string (thisAgent, "\n}\n");
xml_end_tag(thisAgent, kTagProduction);
deallocate_action_list (thisAgent, rhs);
}
void print_spaces ( agent thisAgent,
int  n 
)

Definition at line 153 of file print.cpp.

References PRINT_BUFSIZE, and print_string().

Referenced by backtrace_through_instantiation(), ppmi_aux(), print_action_list(), print_condition_list(), print_consed_list_of_condition_wmes(), and print_consed_list_of_conditions().

{
char *ch;
char buf[PRINT_BUFSIZE];
ch = buf;
while (n) { *(ch++)=' '; n--; }
*ch=0;
print_string (thisAgent, buf);
}
void print_string ( agent thisAgent,
const char *  s 
)
void print_with_symbols ( agent thisAgent,
const char *  format,
  ... 
)

Definition at line 136 of file print.cpp.

References PRINT_BUFSIZE, print_string(), and vsnprintf_with_symbols().

Referenced by abs_rhs_function_code(), add_production_to_rete(), add_rete_tests_for_test(), add_rhs_function(), assert_new_preferences(), atan2_rhs_function_code(), backtrace_through_instantiation(), calculate_support_for_instantiation_preferences(), capitalize_symbol_rhs_function_code(), check_context_slot_decisions(), chunk_instantiation(), collect_root_variables(), compute_heading_rhs_function_code(), compute_range_rhs_function_code(), cos_rhs_function_code(), create_gds_for_goal(), create_instantiation(), deallocate_instantiation(), deallocate_symbol(), deallocate_wme(), decide_context_slot(), decide_non_context_slot(), decision_consistent_with_current_preferences(), dice_prob_rhs_function_code(), div_rhs_function_code(), do_preference_phase(), dont_learn_rhs_function_code(), elaborate_gds(), execute_action(), exploration_boltzmann_select(), exploration_epsilon_greedy_select(), fill_in_new_instantiation_stuff(), find_goal_for_match_set_change_assertion(), find_goal_for_match_set_change_retraction(), float_rhs_function_code(), force_learn_rhs_function_code(), fp_divide_rhs_function_code(), garbage_collect_id(), gds_invalid_so_remove_goal(), goal_stack_consistent_through_goal(), int_rhs_function_code(), make_production(), minus_rhs_function_code(), mod_rhs_function_code(), p_node_left_addition(), p_node_left_removal(), parse_head_of_conds_for_one_id(), parse_production(), plus_rhs_function_code(), post_link_addition(), post_link_removal(), print_action_list(), print_assertion(), print_candidates(), print_instantiation_with_wmes(), print_match_set(), print_preference(), print_production(), print_retraction(), print_saved_test(), print_tracing_rule(), print_tracing_rule_tcl(), print_wme(), print_wme_for_tcl(), print_wme_without_timetag(), rand_float_rhs_function_code(), rand_int_rhs_function_code(), read_identifier_or_context_variable(), remove_current_decision(), remove_garbage_slots(), remove_operator_if_necessary(), remove_rhs_function(), reteload_rhs_value(), shouldCreateInstantiation(), sin_rhs_function_code(), sqrt_rhs_function_code(), times_rhs_function_code(), trim_rhs_function_code(), and uniquely_add_to_head_of_dll().

{
va_list args;
char buf[PRINT_BUFSIZE];
va_start (args, format);
vsnprintf_with_symbols(thisAgent, buf, PRINT_BUFSIZE, format, args);
va_end (args);
print_string (thisAgent, buf);
}
void print_wme ( agent thisAgent,
wme w 
)
void print_wme_for_tcl ( agent thisAgent,
wme w 
)

Definition at line 1032 of file print.cpp.

References wme_struct::acceptable, wme_struct::attr, wme_struct::id, print(), print_string(), print_with_symbols(), wme_struct::timetag, and wme_struct::value.

{
print (thisAgent, "%lu: ", w->timetag);
print_with_symbols (thisAgent, "%y ^%y %y", w->id, w->attr, w->value);
if (w->acceptable) print_string (thisAgent, " +");
}
void print_wme_without_timetag ( agent thisAgent,
wme w 
)

Definition at line 1021 of file print.cpp.

References wme_struct::acceptable, wme_struct::attr, wme_struct::id, print(), print_string(), print_with_symbols(), wme_struct::value, xml_object(), and XML_WME_NO_TIMETAG.

{
print_with_symbols (thisAgent, "(%y ^%y %y", w->id, w->attr, w->value);
if (w->acceptable) print_string (thisAgent, " +");
print_string (thisAgent, ")");
print (thisAgent, "\n");
// <wme id="s1" attr="foo" attrtype="string" val="123" valtype="string"></wme>
xml_object( thisAgent, w, XML_WME_NO_TIMETAG );
}
char* rhs_value_to_string ( agent thisAgent,
rhs_value  rv,
char *  dest,
size_t  dest_size 
)

Definition at line 425 of file print.cpp.

References abort_with_fatal_error(), BUFFER_MSG_SIZE, cons_struct::first, MAX_LEXEME_LENGTH, sym_constant_struct::name, rhs_function_struct::name, NIL, agent_struct::printed_output_string, cons_struct::rest, rhs_value_is_reteloc(), rhs_value_is_symbol(), rhs_value_to_funcall_list(), rhs_value_to_string(), rhs_value_to_symbol(), symbol_union::sc, symbol_to_string(), and TRUE.

Referenced by calculate_support_for_instantiation_preferences(), p_node_left_addition(), parse_attr_value_make(), parse_preferences_soar8_non_operator(), print_action_list(), and rhs_value_to_string().

{
cons *c;
list *fl;
char *ch;
char msg[BUFFER_MSG_SIZE];
strncpy (msg, "Internal error: rhs_value_to_string called on reteloc.\n", BUFFER_MSG_SIZE);
msg[BUFFER_MSG_SIZE - 1] = 0; /* ensure null termination */
abort_with_fatal_error(thisAgent, msg);
}
return symbol_to_string (thisAgent, rhs_value_to_symbol(rv), TRUE, dest, dest_size);
}
rf = static_cast<rhs_function_struct *>(fl->first);
if (!dest) {
dest=thisAgent->printed_output_string;
dest_size = MAX_LEXEME_LENGTH*2+10; /* from agent.h */
}
ch = dest;
strncpy (ch, "(", dest_size);
ch[dest_size - 1] = 0;
while (*ch) ch++;
if (!strcmp(rf->name->sc.name,"+")) {
strncpy (ch, "+", dest_size - (ch - dest));
ch[dest_size - (ch - dest) - 1] = 0;
} else if (!strcmp(rf->name->sc.name,"-")) {
strncpy (ch, "-", dest_size - (ch - dest));
ch[dest_size - (ch - dest) - 1] = 0;
} else {
symbol_to_string (thisAgent, rf->name, TRUE, ch, dest_size - (ch - dest));
}
while (*ch) ch++;
for (c=fl->rest; c!=NIL; c=c->rest) {
strncpy (ch, " ", dest_size - (ch - dest));
ch[dest_size - (ch - dest) - 1] = 0;
while (*ch)
ch++;
rhs_value_to_string (thisAgent, static_cast<char *>(c->first), ch, dest_size - (ch - dest));
while (*ch)
ch++;
}
strncpy (ch, ")", dest_size - (ch - dest));
ch[dest_size - (ch - dest) - 1] = 0;
return dest;
}
void snprintf_with_symbols ( agent thisAgent,
char *  dest,
size_t  count,
const char *  format,
  ... 
)

Definition at line 146 of file print.cpp.

References vsnprintf_with_symbols().

Referenced by add_wme_to_gds(), gds_invalid_so_remove_goal(), and smem_store_chunk().

{
va_list args;
va_start (args, format);
vsnprintf_with_symbols(thisAgent, dest, count, format, args);
va_end (args);
}
char* string_to_escaped_string ( agent thisAgent,
char *  s,
char  first_and_last_char,
char *  dest 
)

Definition at line 191 of file print.cpp.

References agent_struct::printed_output_string.

Referenced by print_production(), print_trace_format_list(), and symbol_to_string().

{
char *ch;
if (!dest) dest = thisAgent->printed_output_string;
ch = dest;
*ch++ = first_and_last_char;
while (*s) {
if ((*s==first_and_last_char)||(*s=='\\')) *ch++ = '\\';
*ch++ = *s++;
}
*ch++ = first_and_last_char;
*ch = 0;
return dest;
}
char* symbol_to_string ( agent thisAgent,
Symbol sym,
Bool  rereadable,
char *  dest,
size_t  dest_size 
)

Definition at line 226 of file print.cpp.

References abort_with_fatal_error(), BUFFER_MSG_SIZE, determine_possible_symbol_types_for_string(), symbol_union::fc, FLOAT_CONSTANT_SYMBOL_TYPE, symbol_union::ic, symbol_union::id, IDENTIFIER_SYMBOL_TYPE, INT_CONSTANT_SYMBOL_TYPE, MAX_LEXEME_LENGTH, sym_constant_struct::name, variable_struct::name, identifier_struct::name_letter, identifier_struct::name_number, NIL, agent_struct::printed_output_string, symbol_union::sc, identifier_struct::smem_lti, string_to_escaped_string(), SYM_CONSTANT_SYMBOL_TYPE, int_constant_struct::value, float_constant_struct::value, symbol_union::var, and VARIABLE_SYMBOL_TYPE.

Referenced by add_production_to_rete(), add_rete_tests_for_test(), add_trace_for_attribute_path(), add_trace_for_wme(), add_values_of_attribute_path(), assert_new_preferences(), calculate_support_for_instantiation_preferences(), capitalize_symbol_rhs_function_code(), collect_root_variables(), count_rhs_function_code(), create_instantiation(), find_goal_for_match_set_change_assertion(), float_rhs_function_code(), int_rhs_function_code(), make_constant_symbol_rhs_function_code(), make_equality_test(), make_float_constant(), make_int_constant(), make_new_identifier(), make_sym_constant(), make_variable(), object_to_trace_string(), p_node_left_addition(), p_node_left_removal(), parse_head_of_conds_for_one_id(), parse_preferences_soar8_non_operator(), print_instantiation_with_wmes(), print_sym(), reteload_rhs_value(), retesave_symbol_and_assign_index(), rhs_value_to_string(), should_variablize(), strlen_rhs_function_code(), symbol_add_ref(), symbol_remove_ref(), test_to_string(), trace_format_list_to_string(), trim_rhs_function_code(), update_for_top_state_wme_addition(), vsnprintf_with_symbols(), write_rhs_function_code(), and xml_att_val().

{
Bool possible_id, possible_var, possible_sc, possible_ic, possible_fc;
Bool is_rereadable;
Bool has_angle_bracket;
switch(sym->common.symbol_type) {
if (!dest) return sym->var.name;
strncpy (dest, sym->var.name, dest_size);
dest[dest_size - 1] = 0; /* ensure null termination */
return dest;
if (!dest) {
dest=thisAgent->printed_output_string;
dest_size = MAX_LEXEME_LENGTH*2+10; /* from agent.h */
}
if (sym->id.smem_lti == NIL) {
// NOT an lti (long term identifier), print like we always have
SNPRINTF (dest, dest_size, "%c%llu", sym->id.name_letter, static_cast<long long unsigned>(sym->id.name_number));
}
else {
// IS an lti (long term identifier), prepend an @ symbol
SNPRINTF (dest, dest_size, "@%c%llu", sym->id.name_letter, static_cast<long long unsigned>(sym->id.name_number));
}
dest[dest_size - 1] = 0; /* ensure null termination */
return dest;
if (!dest) {
dest=thisAgent->printed_output_string;
dest_size = MAX_LEXEME_LENGTH*2+10; /* from agent.h */
}
SNPRINTF (dest, dest_size, "%ld", static_cast<long int>(sym->ic.value));
dest[dest_size - 1] = 0; /* ensure null termination */
return dest;
if (!dest) {
dest=thisAgent->printed_output_string;
dest_size = MAX_LEXEME_LENGTH*2+10; /* from agent.h */
}
SNPRINTF (dest, dest_size, "%#.16g", sym->fc.value);
dest[dest_size - 1] = 0; /* ensure null termination */
{ /* --- strip off trailing zeros --- */
char *start_of_exponent;
char *end_of_mantissa;
start_of_exponent = dest;
while ((*start_of_exponent != 0) && (*start_of_exponent != 'e'))
start_of_exponent++;
end_of_mantissa = start_of_exponent - 1;
while (*end_of_mantissa == '0') end_of_mantissa--;
end_of_mantissa++;
while (*start_of_exponent) *end_of_mantissa++ = *start_of_exponent++;
*end_of_mantissa = 0;
}
return dest;
if (!rereadable) {
if (!dest) return sym->sc.name;
strncpy (dest, sym->sc.name, dest_size);
return dest;
}
strlen (sym->sc.name),
&possible_id,
&possible_var,
&possible_sc,
&possible_ic,
&possible_fc,
&is_rereadable);
has_angle_bracket = sym->sc.name[0] == '<' ||
sym->sc.name[strlen(sym->sc.name)-1] == '>';
if ((!possible_sc) || possible_var || possible_ic || possible_fc ||
(!is_rereadable) ||
has_angle_bracket) {
/* BUGBUG if in context where id's could occur, should check
possible_id flag here also */
return string_to_escaped_string (thisAgent, sym->sc.name, '|', dest);
}
if (!dest) return sym->sc.name;
strncpy (dest, sym->sc.name, dest_size);
return dest;
default:
{
char msg[BUFFER_MSG_SIZE];
strncpy(msg, "Internal Soar Error: symbol_to_string called on bad symbol\n", BUFFER_MSG_SIZE);
msg[BUFFER_MSG_SIZE - 1] = 0; /* ensure null termination */
abort_with_fatal_error(thisAgent, msg);
}
}
return NIL; /* unreachable, but without it, gcc -Wall warns here */
}
char const* symbol_to_typeString ( agent ,
Symbol sym 
)

Definition at line 208 of file print.cpp.

References FLOAT_CONSTANT_SYMBOL_TYPE, IDENTIFIER_SYMBOL_TYPE, INT_CONSTANT_SYMBOL_TYPE, SYM_CONSTANT_SYMBOL_TYPE, and VARIABLE_SYMBOL_TYPE.

Referenced by xml_object().

{
switch(sym->common.symbol_type) {
return kTypeVariable ;
return kTypeID ;
return kTypeInt ;
return kTypeDouble ;
return kTypeString ;
default:
return 0 ;
}
}
void tell_printer_that_output_column_has_been_reset ( agent thisAgent)

Definition at line 63 of file print.cpp.

References agent_struct::printer_output_column.

Referenced by get_next_char().

{
thisAgent->printer_output_column = 1;
}
char* test_to_string ( agent thisAgent,
test  t,
char *  dest,
size_t  dest_size 
)

Definition at line 328 of file print.cpp.

References complex_test_from_test(), complex_test_struct::test_info_union::conjunct_list, CONJUNCTIVE_TEST, complex_test_struct::data, complex_test_struct::test_info_union::disjunction_list, DISJUNCTION_TEST, cons_struct::first, GOAL_ID_TEST, GREATER_OR_EQUAL_TEST, GREATER_TEST, IMPASSE_ID_TEST, LESS_OR_EQUAL_TEST, LESS_TEST, MAX_LEXEME_LENGTH, NIL, NOT_EQUAL_TEST, agent_struct::printed_output_string, complex_test_struct::test_info_union::referent, referent_of_equality_test(), cons_struct::rest, SAME_TYPE_TEST, symbol_to_string(), test_is_blank_or_equality_test(), test_is_blank_test(), test_to_string(), TRUE, and complex_test_struct::type.

Referenced by check_unbound_negative_relational_test_referents(), print_condition_list(), print_saved_test(), test_to_string(), and xml_condition_list().

{
cons *c;
char *ch;
if (!dest) dest=thisAgent->printed_output_string;
strncpy (dest, "[BLANK TEST]", dest_size); /* this should never get executed */
dest[dest_size - 1] = 0; /* ensure null termination */
return dest;
}
return symbol_to_string (thisAgent, referent_of_equality_test(t), TRUE, dest, dest_size);
}
if (!dest) {
dest=thisAgent->printed_output_string;
dest_size = MAX_LEXEME_LENGTH*2+10; /* from agent.h */
}
ch = dest;
switch (ct->type) {
strncpy (ch, "<> ", dest_size - (ch - dest));
ch[dest_size - (ch - dest) - 1] = 0; /* ensure null termination */
while (*ch)
ch++;
symbol_to_string (thisAgent, ct->data.referent, TRUE, ch, dest_size - (ch - dest));
break;
case LESS_TEST:
strncpy (ch, "< ", dest_size - (ch - dest));
ch[dest_size - (ch - dest) - 1] = 0; /* ensure null termination */
while (*ch) ch++;
symbol_to_string (thisAgent, ct->data.referent, TRUE, ch, dest_size - (ch - dest));
break;
strncpy (ch, "> ", dest_size - (ch - dest));
ch[dest_size - (ch - dest) - 1] = 0; /* ensure null termination */
while (*ch) ch++;
symbol_to_string (thisAgent, ct->data.referent, TRUE, ch, dest_size - (ch - dest));
break;
strncpy (ch, "<= ", dest_size - (ch - dest));
ch[dest_size - (ch - dest) - 1] = 0; /* ensure null termination */
while (*ch) ch++;
symbol_to_string (thisAgent, ct->data.referent, TRUE, ch, dest_size - (ch - dest));
break;
strncpy (ch, ">= ", dest_size - (ch - dest));
ch[dest_size - (ch - dest) - 1] = 0; /* ensure null termination */
while (*ch) ch++;
symbol_to_string (thisAgent, ct->data.referent, TRUE, ch, dest_size - (ch - dest));
break;
strncpy (ch, "<=> ", dest_size - (ch - dest));
ch[dest_size - (ch - dest) - 1] = 0; /* ensure null termination */
while (*ch) ch++;
symbol_to_string (thisAgent, ct->data.referent, TRUE, ch, dest_size - (ch - dest));
break;
strncpy (ch, "<< ", dest_size - (ch - dest));
ch[dest_size - (ch - dest) - 1] = 0; /* ensure null termination */
while (*ch) ch++;
for (c=ct->data.disjunction_list; c!=NIL; c=c->rest) {
symbol_to_string (thisAgent, static_cast<symbol_union *>(c->first), TRUE, ch, dest_size - (ch - dest));
while (*ch) ch++;
*(ch++) = ' ';
}
strncpy (ch, ">>", dest_size - (ch - dest));
ch[dest_size - (ch - dest) - 1] = 0; /* ensure null termination */
break;
strncpy (ch, "{ ", dest_size - (ch - dest));
ch[dest_size - (ch - dest) - 1] = 0; /* ensure null termination */
while (*ch) ch++;
for (c=ct->data.conjunct_list; c!=NIL; c=c->rest) {
test_to_string (thisAgent, static_cast<char *>(c->first), ch, dest_size - (ch - dest));
while (*ch) ch++;
*(ch++) = ' ';
}
strncpy (ch, "}", dest_size - (ch - dest));
ch[dest_size - (ch - dest) - 1] = 0; /* ensure null termination */
break;
strncpy (dest, "[GOAL ID TEST]", dest_size - (ch - dest)); /* this should never get executed */
ch[dest_size - (ch - dest) - 1] = 0; /* ensure null termination */
break;
strncpy (dest, "[IMPASSE ID TEST]", dest_size - (ch - dest)); /* this should never get executed */
ch[dest_size - (ch - dest) - 1] = 0; /* ensure null termination */
break;
}
return dest;
}
void vsnprintf_with_symbols ( agent thisAgent,
char *  dest,
size_t  count,
const char *  format,
va_list  args 
)

Definition at line 112 of file print.cpp.

References symbol_to_string(), and TRUE.

Referenced by print_with_symbols(), and snprintf_with_symbols().

{
char *ch;
ch = dest;
while (TRUE) {
/* --- copy anything up to the first "%" --- */
while ((*format != '%') && (*format != 0)) *(ch++) = *(format++);
if (*format == 0) break;
/* --- handle the %-thingy --- */
if (*(format+1)=='y') {
/* the size of the remaining buffer (after ch) is
the difference between the address of ch and
the address of the beginning of the buffer
*/
symbol_to_string (thisAgent, va_arg(args, Symbol *), TRUE, ch, count - (ch - dest));
while (*ch) ch++;
} else {
*(ch++) = '%';
}
format += 2;
}
*ch = 0;
}
Bool wme_filter_component_match ( Symbol filterComponent,
Symbol wmeComponent 
)

Definition at line 1201 of file print.cpp.

References sym_constant_struct::name, symbol_union::sc, SYM_CONSTANT_SYMBOL_TYPE, and TRUE.

Referenced by passes_wme_filtering().

{
if ((filterComponent->common.symbol_type == SYM_CONSTANT_SYMBOL_TYPE) &&
(!strcmp(filterComponent->sc.name,"*")))
return TRUE;
return(filterComponent == wmeComponent);
}