| 208 | } |
| 209 | |
| 210 | list* parse_attribute_path_in_brackets(agent* thisAgent) |
| 211 | { |
| 212 | list* path; |
| 213 | char name[MAX_LEXEME_LENGTH + 20], *ch; |
| 214 | Symbol* sym; |
| 215 | |
| 216 | /* --- look for opening bracket --- */ |
| 217 | if (*format != '[') |
| 218 | { |
| 219 | format_string_error_message = "Expected '[' followed by attribute (path)"; |
| 220 | return NIL; |
| 221 | } |
| 222 | format++; |
| 223 | |
| 224 | /* --- check for '*' (null path) --- */ |
| 225 | if (*format == '*') |
| 226 | { |
| 227 | path = NIL; |
| 228 | format++; |
| 229 | } |
| 230 | else |
| 231 | { |
| 232 | /* --- normal case: read the attribute path --- */ |
| 233 | path = NIL; |
| 234 | while (true) |
| 235 | { |
| 236 | ch = name; |
| 237 | while ((*format != 0) && (*format != ']') && (*format != '.')) |
| 238 | { |
| 239 | *ch++ = *format++; |
| 240 | } |
| 241 | if (*format == 0) |
| 242 | { |
| 243 | format_string_error_message = "'[' without closing ']'"; |
| 244 | deallocate_symbol_list_removing_references(thisAgent, path); |
| 245 | return NIL; |
| 246 | } |
| 247 | if (ch == name) |
| 248 | { |
| 249 | format_string_error_message = "null attribute found in attribute path"; |
| 250 | deallocate_symbol_list_removing_references(thisAgent, path); |
| 251 | return NIL; |
| 252 | } |
| 253 | *ch = 0; |
| 254 | sym = make_str_constant(thisAgent, name); |
| 255 | push(thisAgent, sym, path); |
| 256 | if (*format == ']') |
| 257 | { |
| 258 | break; |
| 259 | } |
| 260 | format++; /* skip past '.' */ |
| 261 | } |
| 262 | path = destructively_reverse_list(path); |
| 263 | } |
| 264 | |
| 265 | /* --- look for closing bracket --- */ |
| 266 | if (*format != ']') |
| 267 | { |
no test coverage detected