MCPcopy Create free account
hub / github.com/SoarGroup/Soar / read_pattern_component

Function read_pattern_component

Core/CLI/src/cli_print.cpp:477–508  ·  view source on GitHub ↗

--- Read and consume one pattern element. Return 0 if error, 1 if "*", otherwise return 2 and set dest_sym to find_symbol() result. --- */

Source from the content-addressed store, hash-verified

475/* --- Read and consume one pattern element. Return 0 if error, 1 if "*",
476otherwise return 2 and set dest_sym to find_symbol() result. --- */
477int read_pattern_component(agent* thisAgent, Symbol** dest_sym)
478{
479 if (strcmp(thisAgent->lexeme.string, "*") == 0)
480 {
481 return 1;
482 }
483 switch (thisAgent->lexeme.type)
484 {
485 case SYM_CONSTANT_LEXEME:
486 *dest_sym = find_str_constant(thisAgent, thisAgent->lexeme.string);
487 return 2;
488 case INT_CONSTANT_LEXEME:
489 *dest_sym = find_int_constant(thisAgent, thisAgent->lexeme.int_val);
490 return 2;
491 case FLOAT_CONSTANT_LEXEME:
492 *dest_sym = find_float_constant(thisAgent, thisAgent->lexeme.float_val);
493 return 2;
494 case IDENTIFIER_LEXEME:
495 *dest_sym = find_identifier(thisAgent, thisAgent->lexeme.id_letter, thisAgent->lexeme.id_number);
496 return 2;
497 case VARIABLE_LEXEME:
498 *dest_sym = read_identifier_or_context_variable(thisAgent);
499 if (*dest_sym)
500 {
501 return 2;
502 }
503 return 0;
504 default:
505 print(thisAgent, "Expected identifier or constant in wme pattern\n");
506 return 0;
507 }
508}
509
510list* read_pattern_and_get_matching_wmes(agent* thisAgent)
511{

Callers 1

Calls 6

find_str_constantFunction · 0.85
find_int_constantFunction · 0.85
find_float_constantFunction · 0.85
find_identifierFunction · 0.85
printFunction · 0.85

Tested by

no test coverage detected