| 554 | } |
| 555 | |
| 556 | static std::string normalizeEOL(Reader::Location begin, Reader::Location end) { |
| 557 | std::string normalized; |
| 558 | normalized.reserve(end - begin); |
| 559 | Reader::Location current = begin; |
| 560 | while (current != end) { |
| 561 | char c = *current++; |
| 562 | if (c == '\r') { |
| 563 | if (current != end && *current == '\n') |
| 564 | // convert dos EOL |
| 565 | ++current; |
| 566 | // convert Mac EOL |
| 567 | normalized += '\n'; |
| 568 | } else { |
| 569 | normalized += c; |
| 570 | } |
| 571 | } |
| 572 | return normalized; |
| 573 | } |
| 574 | |
| 575 | void |
| 576 | Reader::addComment(Location begin, Location end, CommentPlacement placement) { |