7#if !defined(ERROR_HANDLER_HPP)
8#define ERROR_HANDLER_HPP
19 template <
typename Iterator>
28 template <
typename Message,
typename What>
32 Iterator err_pos)
const
35 Iterator line_start =
get_pos(err_pos, line);
38 std::cout << message << what <<
" line " << line <<
':' <<
std::endl;
40 for (; line_start != err_pos; ++line_start)
46 std::cout <<
"Unexpected end of file. ";
47 std::cout << message << what <<
" line " << line <<
std::endl;
51 Iterator
get_pos(Iterator err_pos,
int& line)
const
55 Iterator line_start =
first;
59 if (i != err_pos && *i ==
'\r')
64 if (i != err_pos && *i ==
'\n')
81 while (i !=
last && (*i !=
'\r' && *i !=
'\n'))
83 return std::string(err_pos, i);
Inform & endl(Inform &inf)
error_handler(Iterator first, Iterator last)
Iterator get_pos(Iterator err_pos, int &line) const
void operator()(Message const &message, What const &what, Iterator err_pos) const
std::string get_line(Iterator err_pos) const
std::vector< Iterator > iters