| 41 | */ |
| 42 | |
| 43 | bool read_attribute_from_string(agent* thisAgent, Symbol* id, char* the_lexeme, Symbol** attr) |
| 44 | { |
| 45 | Symbol* attr_tmp; |
| 46 | slot* s; |
| 47 | |
| 48 | /* skip optional '^' if present. KJC added to Ken's code */ |
| 49 | if (*the_lexeme == '^') |
| 50 | { |
| 51 | the_lexeme++; |
| 52 | } |
| 53 | |
| 54 | get_lexeme_from_string(thisAgent, the_lexeme); |
| 55 | |
| 56 | switch (thisAgent->lexeme.type) |
| 57 | { |
| 58 | case SYM_CONSTANT_LEXEME: |
| 59 | attr_tmp = find_str_constant(thisAgent, thisAgent->lexeme.string); |
| 60 | break; |
| 61 | case INT_CONSTANT_LEXEME: |
| 62 | attr_tmp = find_int_constant(thisAgent, thisAgent->lexeme.int_val); |
| 63 | break; |
| 64 | case FLOAT_CONSTANT_LEXEME: |
| 65 | attr_tmp = find_float_constant(thisAgent, thisAgent->lexeme.float_val); |
| 66 | break; |
| 67 | case IDENTIFIER_LEXEME: |
| 68 | attr_tmp = find_identifier(thisAgent, thisAgent->lexeme.id_letter, |
| 69 | thisAgent->lexeme.id_number); |
| 70 | break; |
| 71 | case VARIABLE_LEXEME: |
| 72 | attr_tmp = read_identifier_or_context_variable(thisAgent); |
| 73 | if (!attr_tmp) |
| 74 | { |
| 75 | return false; |
| 76 | } |
| 77 | break; |
| 78 | default: |
| 79 | return false; |
| 80 | } |
| 81 | s = find_slot(id, attr_tmp); |
| 82 | if (s) |
| 83 | { |
| 84 | *attr = attr_tmp; |
| 85 | return true; |
| 86 | } |
| 87 | else |
| 88 | { |
| 89 | *attr = attr_tmp; |
| 90 | } |
| 91 | return false; |
| 92 | } |
| 93 | |
| 94 | /* |
| 95 | * |
no test coverage detected