* This is intended to allow the user to remove part or all of information stored on a LTI. * (All attributes, selected attributes, or just values from particular attributes.) */
| 4238 | * (All attributes, selected attributes, or just values from particular attributes.) |
| 4239 | */ |
| 4240 | bool smem_parse_remove(agent* thisAgent, const char* chunks_str, std::string** err_msg, std::string** result_message, bool force) |
| 4241 | { |
| 4242 | //TODO: need to fix so that err_msg and result_message are actually used or not passed. |
| 4243 | bool good_command = true; |
| 4244 | |
| 4245 | //parsing chunks requires an open semantic database |
| 4246 | smem_attach(thisAgent); |
| 4247 | |
| 4248 | //copied primarily from cli_sp |
| 4249 | thisAgent->alternate_input_string = chunks_str; |
| 4250 | thisAgent->alternate_input_suffix = const_cast<char*>(") "); |
| 4251 | thisAgent->current_char = ' '; |
| 4252 | thisAgent->alternate_input_exit = true; |
| 4253 | set_lexer_allow_ids(thisAgent, true);//This is the end of the incantation. |
| 4254 | |
| 4255 | get_lexeme(thisAgent); |
| 4256 | |
| 4257 | if (thisAgent->lexeme.type == L_PAREN_LEXEME) |
| 4258 | { |
| 4259 | get_lexeme(thisAgent);//Consumes the left paren |
| 4260 | } |
| 4261 | |
| 4262 | if (thisAgent->lexeme.type == AT_LEXEME && good_command) |
| 4263 | { |
| 4264 | get_lexeme(thisAgent); |
| 4265 | } |
| 4266 | |
| 4267 | good_command = thisAgent->lexeme.type == IDENTIFIER_LEXEME; |
| 4268 | |
| 4269 | smem_lti_id lti_id = 0; |
| 4270 | |
| 4271 | if (good_command) |
| 4272 | { |
| 4273 | lti_id = smem_lti_get_id(thisAgent, thisAgent->lexeme.id_letter, thisAgent->lexeme.id_number); |
| 4274 | } |
| 4275 | else |
| 4276 | { |
| 4277 | (*err_msg)->append("Error: No LTI found for that letter and number.\n"); |
| 4278 | } |
| 4279 | |
| 4280 | soar_module::symbol_triple_list retrieval_wmes; |
| 4281 | soar_module::symbol_triple_list meta_wmes; |
| 4282 | |
| 4283 | if (good_command && lti_id != NIL) |
| 4284 | { |
| 4285 | Symbol* lti = smem_lti_soar_make(thisAgent, lti_id, thisAgent->lexeme.id_letter, thisAgent->lexeme.id_number, SMEM_LTI_UNKNOWN_LEVEL); |
| 4286 | |
| 4287 | get_lexeme(thisAgent);//Consume the identifier. |
| 4288 | |
| 4289 | smem_slot_map children; |
| 4290 | |
| 4291 | if (thisAgent->lexeme.type == UP_ARROW_LEXEME) |
| 4292 | { |
| 4293 | //Now that we know we have a good lti, we can do a NCBR so that we know what attributes and values we can delete. |
| 4294 | //"--force" will ignore attempts to delete that which isn't there, while the default will be to stop and report back. |
| 4295 | smem_install_memory(thisAgent, NIL, lti_id, lti, false, meta_wmes, retrieval_wmes, fake_install); |
| 4296 | |
| 4297 | //First, we'll create the slot_map according to retrieval_wmes, then we'll remove what we encounter during parsing. |
no test coverage detected