1 #include <portability.h>
55 #include "soar_TraceNames.h"
61 using namespace soar_TraceNames;
66 int num_args_expected,
67 Bool can_be_rhs_value,
68 Bool can_be_stand_alone_action,
72 if ((!can_be_rhs_value) && (!can_be_stand_alone_action))
74 print (thisAgent,
"Internal error: attempt to add_rhs_function that can't appear anywhere\n");
82 print_with_symbols (thisAgent,
"Internal error: attempt to add_rhs_function that already exists: %y\n", name);
121 prev = rf, rf = rf->
next)
123 if (rf->
name == name)
129 fprintf(stderr,
"Internal error: attempt to remove_rhs_function that does not exist.\n");
130 print_with_symbols(thisAgent,
"Internal error: attempt to remove_rhs_function that does not exist: %y\n", name);
168 for ( ; args!=
NIL; args=args->
rest) {
219 std::stringstream buf;
226 for (c=args; c!=
NIL; c=c->
rest) {
247 #define TIMESTAMP_BUFFER_SIZE 100
252 temp = localtime ((
const time_t *)&now);
255 temp = localtime ((
const time_t *)&now);
258 temp = localtime ((
const time_t *)&now);
261 temp = localtime ((
const time_t *) &now);
263 temp = localtime (&now);
269 temp->tm_mon + 1, temp->tm_mday, temp->tm_year,
270 temp->tm_hour, temp->tm_min, temp->tm_sec);
287 s = fgets (buf, 2000, stdin);
310 char * symbol_to_capitalize;
314 print (thisAgent,
"Error: 'capitalize-symbol' function called with no arguments.\n");
320 print_with_symbols (thisAgent,
"Error: non-symbol (%y) passed to capitalize-symbol function.\n", sym);
325 print (thisAgent,
"Error: 'capitalize-symbol' takes exactly 1 argument.\n");
330 symbol_to_capitalize =
savestring(symbol_to_capitalize);
331 *symbol_to_capitalize =
static_cast<char>(toupper(*symbol_to_capitalize));
407 print (thisAgent,
"Error: 'ifeq' function called with no arguments\n");
432 char *symbol_to_trim;
437 print( thisAgent,
"Error: 'trim' function called with no arguments.\n" );
445 print_with_symbols( thisAgent,
"Error: non-symbol (%y) passed to 'trim' function.\n", sym );
451 print( thisAgent,
"Error: 'trim' takes exactly 1 argument.\n" );
456 symbol_to_trim =
savestring( symbol_to_trim );
458 std::string str( symbol_to_trim );
459 size_t start_pos = str.find_first_not_of(
" \t\n" );
460 size_t end_pos = str.find_last_not_of(
" \t\n" );
462 if ( ( std::string::npos == start_pos ) || ( std::string::npos == end_pos ) )
465 str = str.substr( start_pos, end_pos - start_pos + 1 );
495 print (thisAgent,
"Error: 'dont-learn' function called with no arg.\n");
501 print_with_symbols (thisAgent,
"Error: non-identifier (%y) passed to dont-learn function.\n", state);
504 print_with_symbols(thisAgent,
"Error: identifier passed to dont-learn is not a state: %y.\n",state);
508 print (thisAgent,
"Error: 'dont-learn' takes exactly 1 argument.\n");
531 print (thisAgent,
"Error: 'force-learn' function called with no arg.\n");
537 print_with_symbols (thisAgent,
"Error: non-identifier (%y) passed to force-learn function.\n", state);
540 print_with_symbols(thisAgent,
"Error: identifier passed to force-learn is not a state: %y.\n",state);
545 print (thisAgent,
"Error: 'force-learn' takes exactly 1 argument.\n");
563 std::map<Symbol*,Symbol*>& processedSymbols);
568 std::map<Symbol*,Symbol*>& processedSymbols) {
570 bool made_new_attr_symbol =
false;
571 bool made_new_value_symbol =
false;
573 Symbol* new_id = parent_id;
578 if ( curwme->
attr->common.symbol_type == 1 ) {
580 std::map<Symbol*,Symbol*>::iterator it = processedSymbols.find(curwme->
attr);
581 if ( it != processedSymbols.end() ) {
583 new_attr = it->second;
589 made_new_attr_symbol =
true;
599 if ( curwme->
value->common.symbol_type == 1 ) {
601 std::map<Symbol*,Symbol*>::iterator it = processedSymbols.find(curwme->
value);
602 if ( it != processedSymbols.end() ) {
604 new_value = it->second;
610 made_new_value_symbol =
true;
638 std::map<Symbol*,Symbol*>& processedSymbols)
641 if ( processedSymbols.find(id_to_process) != processedSymbols.end() ) {
644 processedSymbols.insert(std::pair<Symbol*,Symbol*>(id_to_process,parent_id));
649 curslot = curslot->
next) {
652 for (
wme* curwme = curslot->wmes;
654 curwme = curwme->
next) {
668 curwme = curwme->
next) {
685 if ( baseid->common.symbol_type != 1 ) {
693 std::map<Symbol*,Symbol*> processedSymbols;
714 for ( ; args!=
NIL; args=args->
rest) {