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

Function smem_parse_cues

Core/SoarKernel/src/semantic_memory.cpp:3914–4222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3912 */
3913
3914bool smem_parse_cues(agent* thisAgent, const char* chunks_str, std::string** err_msg, std::string** result_message, uint64_t number_to_retrieve)
3915{
3916 uint64_t clause_count = 0; // This is counting up the number of parsed clauses
3917 // so that there is a pointer to a failure location.
3918
3919 //Parsing requires an open semantic database.
3920 smem_attach(thisAgent);
3921
3922 //Next 5 lines copied as in smem_parse_chunks.
3923 thisAgent->alternate_input_string = chunks_str;
3924 thisAgent->alternate_input_suffix = const_cast<char*>(")");
3925 thisAgent->current_char = ' ';
3926 thisAgent->alternate_input_exit = true;
3927 set_lexer_allow_ids(thisAgent, true);
3928
3929 bool good_cue = true; // This is a success or failure flag that will be checked periodically
3930 // and indicates whether or not we can call smem_process_query.
3931
3932 std::map<std::string, Symbol*> cue_ids; //I want to keep track of previous references when adding a new element to the cue.
3933
3934 //consume next token.
3935 get_lexeme(thisAgent);
3936
3937 good_cue = thisAgent->lexeme.type == L_PAREN_LEXEME;
3938
3939 Symbol* root_cue_id = NIL; //This is the id that gets passed to smem_process_query.
3940 //It's main purpose is to contain augmentations
3941 Symbol* negative_cues = NULL; //This is supposed to contain the negative augmentations.
3942
3943 bool trigger_first = true; //Just for managing my loop.
3944 bool minus_ever = false; //Did a negative cue ever show up?
3945 bool first_attribute = true; //Want to make sure there is a positive attribute to begin with.
3946
3947 // While there is parsing to be done:
3948 while ((thisAgent->lexeme.type == L_PAREN_LEXEME) && good_cue)
3949 {
3950 //First, consume the left paren.
3951 get_lexeme(thisAgent);
3952
3953 if (trigger_first)
3954 {
3955 good_cue = thisAgent->lexeme.type == VARIABLE_LEXEME;
3956
3957 if (good_cue)
3958 {
3959 root_cue_id = make_new_identifier(thisAgent, (char) thisAgent->lexeme.string[1], 1);
3960 cue_ids[thisAgent->lexeme.string] = root_cue_id;
3961 negative_cues = make_new_identifier(thisAgent, (char) thisAgent->lexeme.string[1], 1);
3962 }
3963 else
3964 {
3965 (*err_msg)->append("Error: The cue must be a variable.\n");//Spit out that the cue must be a variable.
3966 break;
3967 }
3968
3969 trigger_first = false;
3970 }
3971 else

Callers 1

DoSMemMethod · 0.85

Calls 15

smem_attachFunction · 0.85
set_lexer_allow_idsFunction · 0.85
get_lexemeFunction · 0.85
make_new_identifierFunction · 0.85
smem_parse_constant_attrFunction · 0.85
make_slotFunction · 0.85
make_str_constantFunction · 0.85
make_int_constantFunction · 0.85
make_float_constantFunction · 0.85
smem_lti_get_idFunction · 0.85
smem_lti_soar_makeFunction · 0.85
make_wmeFunction · 0.85

Tested by

no test coverage detected