void print_file_line(std::size_t line) const;
void print_line(Iterator line_start, Iterator last) const;
void print_indicator(Iterator& line_start, Iterator last, char ind) const;
- void skip_whitespace(Iterator& err_pos, Iterator last) const;
- void skip_non_whitespace(Iterator& err_pos, Iterator last) const;
Iterator get_line_start(Iterator first, Iterator pos) const;
std::size_t position(Iterator i) const;
}
}
- template <typename Iterator>
- void error_handler<Iterator>::skip_whitespace(Iterator& err_pos, Iterator last) const
- {
- // make sure err_pos does not point to white space
- while (err_pos != last)
- {
- char c = *err_pos;
- if (std::isspace(c))
- ++err_pos;
- else
- break;
- }
- }
-
- template <typename Iterator>
- void error_handler<Iterator>::skip_non_whitespace(Iterator& err_pos, Iterator last) const
- {
- // make sure err_pos does not point to white space
- while (err_pos != last)
- {
- char c = *err_pos;
- if (std::isspace(c))
- break;
- else
- ++err_pos;
- }
- }
-
template <class Iterator>
inline Iterator error_handler<Iterator>::get_line_start(Iterator first, Iterator pos) const
{
Iterator latest = first;
- for (Iterator i = first; i != pos; ++i)
+ for (Iterator i = first; i != pos;)
if (*i == '\r' || *i == '\n')
- latest = i;
+ latest = ++i;
+ else
+ ++i;
return latest;
}
Iterator first = pos_cache.first();
Iterator last = pos_cache.last();
- // make sure err_pos does not point to white space
- skip_whitespace(err_pos, last);
-
print_file_line(position(err_pos));
err_out << error_message << std::endl;
Iterator start = get_line_start(first, err_pos);
- if (start != first)
- ++start;
print_line(start, last);
print_indicator(start, err_pos, '_');
err_out << "^_" << std::endl;
Iterator first = pos_cache.first();
Iterator last = pos_cache.last();
- // make sure err_pos does not point to white space
- skip_whitespace(err_first, last);
-
print_file_line(position(err_first));
err_out << error_message << std::endl;
Iterator start = get_line_start(first, err_first);
- if (start != first)
- ++start;
print_line(start, last);
print_indicator(start, err_first, ' ');
print_indicator(start, err_last, '~');