| 360 | |
| 361 | |
| 362 | std::pair<int, int> |
| 363 | Parser::parseRange() |
| 364 | { |
| 365 | ASSERT(head() == '{'); |
| 366 | next(); |
| 367 | std::string firstnum = ""; |
| 368 | while (hasInput() && '0' <= head() && head() <= '9') { |
| 369 | firstnum += head(); |
| 370 | next(); |
| 371 | } |
| 372 | std::string secondnum = ""; |
| 373 | if (hasInput() && head() == ',') { |
| 374 | next(); |
| 375 | while (hasInput() && '0' <= head() && head() <= '9') { |
| 376 | secondnum += head(); |
| 377 | next(); |
| 378 | } |
| 379 | if (!secondnum.size()) |
| 380 | secondnum = "-1"; |
| 381 | } |
| 382 | if (!hasInput() || head() != '}' || !firstnum.size()) { |
| 383 | m_error = "Bad {} range definition"; |
| 384 | return std::pair<int, int>(-1, -1); |
| 385 | } |
| 386 | next(); |
| 387 | if (secondnum.size()) |
| 388 | return std::pair<int, int>(atoi(firstnum.c_str()), atoi(secondnum.c_str())); |
| 389 | else |
| 390 | return std::pair<int, int>(atoi(firstnum.c_str()), atoi(firstnum.c_str())); |
| 391 | } |
| 392 | |
| 393 | |
| 394 | |