| 273 | |
| 274 | |
| 275 | LPexp * |
| 276 | Parser::parseNegor() |
| 277 | { |
| 278 | ASSERT (head() == '^'); |
| 279 | SymbolSet symlist; |
| 280 | symlist.insert(Labels::STOP); // never allowed |
| 281 | int pos = -1; |
| 282 | next(); |
| 283 | while (hasInput() && head() != ']') { |
| 284 | bool iscustom; |
| 285 | ustring sym = parseRawSymbol(iscustom); |
| 286 | if (error()) return NULL; |
| 287 | symlist.insert(sym); |
| 288 | if (iscustom) { |
| 289 | if (symlist.size() > 2 && pos != -1) |
| 290 | std::cerr << "[pathexp] you are mixing labels of different type in [...]" << std::endl; |
| 291 | pos = -1; |
| 292 | } else { |
| 293 | SymbolToInt::const_iterator found = m_label_position.find(sym); |
| 294 | if (found == m_label_position.end()) { |
| 295 | m_error = "Unrecognized basic label"; |
| 296 | return NULL; |
| 297 | } |
| 298 | if (symlist.size() > 2 && found->second != pos) |
| 299 | std::cerr << "[pathexp] you are mixing labels of different type in [...]" << std::endl; |
| 300 | pos = found->second; |
| 301 | } |
| 302 | } |
| 303 | if (!hasInput()) { |
| 304 | m_error = "Reached end of line looking for ] to end an negative or list'"; |
| 305 | return NULL; |
| 306 | } |
| 307 | if (symlist.size() < 2) { |
| 308 | m_error = "Empty or list [^] not allowed"; |
| 309 | return NULL; |
| 310 | } |
| 311 | next(); |
| 312 | lpexp::Wildexp *wildcard = new lpexp::Wildexp(symlist); |
| 313 | if (m_ingroup) |
| 314 | return wildcard; |
| 315 | else { |
| 316 | std::list<LPexp *> custom; |
| 317 | if (pos < 0) { // is a custom label |
| 318 | custom.push_back(wildcard); |
| 319 | return buildStop(new lpexp::Wildexp(m_minus_stop), new lpexp::Wildexp(m_minus_stop), custom); |
| 320 | } else { |
| 321 | LPexp *basics[2] = {NULL, NULL}; |
| 322 | basics[pos] = wildcard; |
| 323 | for (int i = 0; i < 2; ++i) |
| 324 | if (!basics[i]) |
| 325 | basics[i] = new lpexp::Wildexp(m_minus_stop); |
| 326 | return buildStop(basics[0], basics[1], custom); |
| 327 | } |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | |
| 332 | |