1 #include <portability.h>
67 if (!isalpha(first_letter)) {
70 i = tolower(first_letter) -
static_cast<int>(
'a');
71 assert (i >= 0 && i < 26);
75 SNPRINTF (buf,
sizeof(buf)-1,
"<#%c*%lu>", first_letter, static_cast<long unsigned int>(thisAgent->
placeholder_counter[i]++));
76 buf[
sizeof(buf)-1] =
'\0';
80 v->var.current_binding_value =
NIL;
121 if (*((*sym)->var.name + 1) !=
'#')
return;
123 just_created =
FALSE;
125 if (! (*sym)->var.current_binding_value) {
126 prefix[0] = *((*sym)->var.name + 2);
169 for ( ; cond!=
NIL; cond=cond->
next) {
170 switch (cond->
type) {
225 "Grammar for left hand sides of productions:",
227 " <lhs> ::= <cond>+",
228 " <cond> ::= <positive_cond> | - <positive_cond>",
229 " <positive_cond> ::= <conds_for_one_id> | { <cond>+ }",
230 " <conds_for_one_id> ::= ( [state|impasse] [<id_test>] <attr_value_tests>* )",
231 " <id_test> ::= <test>",
232 " <attr_value_tests> ::= [-] ^ <attr_test> [.<attr_test>]* <value_test>*",
233 " <attr_test> ::= <test>",
234 " <value_test> ::= <test> [+] | <conds_for_one_id> [+]",
236 " <test> ::= <conjunctive_test> | <simple_test>",
237 " <conjunctive_test> ::= { <simple_test>+ }",
238 " <simple_test> ::= <disjunction_test> | <relational_test>",
239 " <disjunction_test> ::= << <constant>* >>",
240 " <relational_test> ::= [<relation>] <single_test>",
241 " <relation> ::= <> | < | > | <= | >= | = | <=>",
242 " <single_test> ::= <variable> | <constant>",
243 " <constant> ::= sym_constant | int_constant | float_constant",
244 " <variable> ::= variable | lti",
246 "See also: rhs-grammar, sp",
267 strncpy(msg,
"parser.c: Internal error: ID found in make_symbol_for_current_lexeme\n",
BUFFER_MSG_SIZE);
274 if ( lti_id ==
NIL ) {
276 strncpy(msg,
"parser.c: Internal error: invalid long-term identifier found in make_symbol_for_current_lexeme\n",
BUFFER_MSG_SIZE);
287 SNPRINTF(msg,
BUFFER_MSG_SIZE,
"parser.c: Internal error: bad lexeme type in make_symbol_for_current_lexeme\n, thisAgent->lexeme.string=%s\n", thisAgent->
lexeme.
string);
317 Bool use_equality_test;
322 use_equality_test =
FALSE;
328 use_equality_test =
TRUE;
363 use_equality_test =
TRUE;
379 if (use_equality_test) {
383 ct->
type = test_type;
390 print (thisAgent,
"Expected variable or constant for test\n");
408 print (thisAgent,
"Expected << to begin disjunction test\n");
428 print (thisAgent,
"Expected constant or >> while reading disjunction test\n");
512 test equality_test_from_t;
515 for (positive_c=conds; positive_c!=
NIL; positive_c=positive_c->
next)
522 for (c=conds; c!=
NIL; c=c->
next) {
536 for (c=conds; c!=
NIL; c=c->
next) {
548 test equality_test_from_t;
551 for (positive_c=conds; positive_c!=
NIL; positive_c=positive_c->
next)
558 for (c=conds; c!=
NIL; c=c->
next) {
572 for (c=conds; c!=
NIL; c=c->
next) {
597 switch (conds->
type) {
611 allocate_with_pool (thisAgent, &thisAgent->
condition_pool, &temp);
616 for (last=conds; last->
next!=
NIL; last=last->
next);
631 char first_letter_if_no_id_given,
635 condition *c, *last_c, *first_c, *new_conds;
687 if (last_c) last_c->
next = new_conds;
else first_c = new_conds;
688 new_conds->
prev = last_c;
689 for (last_c=new_conds; last_c->
next!=
NIL; last_c=last_c->
next);
707 test id_test_to_use, attr_test;
709 condition *first_c, *last_c, *c, *new_conds;
717 print (thisAgent,
"Expected ^ followed by attribute\n");
728 if (!attr_test)
return NIL;
734 id_test_to_use =
NIL;
741 if (last_c) last_c->
next = c;
else first_c = c;
774 if (id_test_to_use)
fill_in_id_tests (thisAgent, new_conds, id_test_to_use);
776 if (last_c) last_c->
next = new_conds;
else first_c = new_conds;
777 new_conds->
prev = last_c;
798 test id_test, id_goal_impasse_test, check_for_symconstant;
803 print (thisAgent,
"Expected ( to begin condition element\n");
816 first_letter_if_no_id_given =
's';
817 }
else if (!strcmp(thisAgent->
lexeme.
string,
"impasse")) {
822 first_letter_if_no_id_given =
'i';
851 print(thisAgent,
" This will never match.\n");
914 if (last_c) last_c->
next = new_conds;
else first_c = new_conds;
915 new_conds->
prev = last_c;
916 for (last_c=new_conds; last_c->
next!=
NIL; last_c=last_c->
next);
944 test *dest_id_test) {
946 test id_test, equality_test_from_id_test;
950 if (! id_test)
return NIL;
961 *dest_id_test = id_test;
997 print (thisAgent,
"Expected } to end conjunctive condition\n");
1022 condition *first_c, *last_c, *new_conds;
1033 if (last_c) last_c->
next = new_conds;
else first_c = new_conds;
1034 new_conds->
prev = last_c;
1035 for (last_c=new_conds; last_c->
next!=
NIL; last_c=last_c->
next);
1100 "Grammar for right hand sides of productions:",
1102 " <rhs> ::= <rhs_action>*",
1103 " <rhs_action> ::= ( <variable> <attr_value_make>+ ) | <function_call>",
1104 " <function_call> ::= ( <function_name> <rhs_value>* )",
1105 " <function_name> ::= sym_constant | + | -",
1106 " <rhs_value> ::= <constant> | <function_call> | <variable>",
1107 " <constant> ::= sym_constant | int_constant | float_constant",
1108 " <attr_value_make> ::= ^ <rhs_value> <value_make>+",
1109 " <value_make> ::= <rhs_value> <preferences>",
1110 " <variable> ::= variable | lti",
1112 " <preferences> ::= [,] | <preference_specifier>+",
1113 " <preference-specifier> ::= <naturally-unary-preference> [,]",
1114 " | <forced-unary-preference>",
1115 " | <binary-preference> <rhs_value> [,]",
1116 " <naturally-unary-preference> ::= + | - | ! | ~ | @",
1117 " <binary-preference> ::= > | = | < | &",
1118 " <any-preference> ::= <naturally-unary-preference> | <binary-preference>",
1119 " <forced-unary-preference> ::= <binary-preference> ",
1120 " {<any-preference> | , | ) | ^}",
1121 " ;but the parser shouldn't consume the <any-preference>, \")\" or \"^\"",
1124 "See also: lhs-grammar, sp",
1142 Bool is_stand_alone_action) {
1168 print (thisAgent,
"Function %s cannot be used as a stand-alone action\n",
1174 print (thisAgent,
"Function %s can only be used as a stand-alone action\n",
1203 print (thisAgent,
"Wrong number of arguments to function %s (expected %d)\n",
1246 print (thisAgent,
"Illegal value for RHS value\n");
1262 switch (test_lexeme) {
1417 byte preference_type;
1448 allocate_with_pool (thisAgent, &thisAgent->
action_pool, &a);
1499 byte preference_type;
1503 char szPrintAttr[256];
1504 char szPrintValue[256];
1505 char szPrintId[256];
1531 print (thisAgent,
"\nERROR: in Soar8, binary preference illegal for non-operator.");
1538 print(thisAgent,
"id = %s\t attr = %s\t value = %s\n", szPrintId, szPrintAttr, szPrintValue);
1549 print (thisAgent,
"\nWARNING: in Soar8, the only allowable non-operator preference \nis REJECT - .\nIgnoring specified preferences.\n");
1550 xml_generate_warning(thisAgent,
"WARNING: in Soar8, the only allowable non-operator preference \nis REJECT - .\nIgnoring specified preferences.");
1557 print(thisAgent,
"id = %s\t attr = %s\t value = %s\n", szPrintId, szPrintAttr, szPrintValue);
1564 allocate_with_pool (thisAgent, &thisAgent->
action_pool, &a);
1587 if (prev_a ==
NIL) {
1589 allocate_with_pool (thisAgent, &thisAgent->
action_pool, &a);
1619 action *all_actions, *new_actions, *last;
1620 Symbol *old_id, *new_var;
1623 char szAttribute[256];
1626 print (thisAgent,
"Expected ^ in RHS make action\n");
1654 if(strcmp(szAttribute,
"operator") != 0)
1664 for (last=new_actions; last->
next!=
NIL; last=last->
next)
1667 last->
next = all_actions;
1668 all_actions = new_actions;
1697 if(strcmp(szAttribute,
"operator") != 0)
1710 for (last=new_actions; last->
next!=
NIL; last=last->
next);
1711 last->
next = all_actions;
1712 all_actions = new_actions;
1730 action *all_actions, *new_actions, *last;
1735 print (thisAgent,
"Expected ( to begin RHS action\n");
1747 if (!funcall_value)
return NIL;
1748 allocate_with_pool (thisAgent, &thisAgent->
action_pool, &all_actions);
1751 all_actions->
value = funcall_value;
1758 if ( lti_id ==
NIL ) {
1760 strncpy(msg,
"parser.c: Internal error: invalid long-term identifier found in make_symbol_for_current_lexeme\n",
BUFFER_MSG_SIZE);
1777 for (last=new_actions; last->
next!=
NIL; last=last->
next);
1778 last->
next = all_actions;
1779 all_actions = new_actions;
1818 action *all_actions, *new_actions, *last;
1824 for (last=new_actions; last->
next!=
NIL; last=last->
next);
1825 last->
next = all_actions;
1826 all_actions = new_actions;
1832 *dest_rhs = all_actions;
1853 action *prev, *current, *next;
1858 next = current->
next;
1859 current->
next = prev;
1880 char *documentation;
1884 byte declared_support;
1891 Bool interrupt_on_match;
1897 print (thisAgent,
"Expected symbol for production name\n");
1914 documentation =
NIL;
1920 interrupt_on_match =
FALSE;
1949 interrupt_on_match =
TRUE;
1968 print (thisAgent,
"Expected --> in production\n");
1994 print (thisAgent,
"Expected ) to end production\n");
2012 for (lhs_bottom=lhs; lhs_bottom->
next!=
NIL; lhs_bottom=lhs_bottom->
next);