void scanner::next() { lean_assert(m_curr != EOF); m_spos++; while (m_spos >= static_cast<int>(m_curr_line.size())) { if (m_last_line) { m_curr = EOF; return; } else { return fetch_line(); } } m_curr = m_curr_line[m_spos]; if (m_uskip > 0) { if (!is_utf8_next(m_curr)) throw_exception("invalid utf-8 sequence character"); m_uskip--; } else { m_upos++; m_uskip = get_utf8_size(m_curr); m_uskip--; } }
void scanner::next() { lean_assert(m_curr != EOF); m_spos++; while (m_spos >= static_cast<int>(m_curr_line.size())) { if (m_last_line) { m_curr = EOF; return; } else { m_curr_line.clear(); if (std::getline(m_stream, m_curr_line)) { m_curr_line.push_back('\n'); m_sline++; m_spos = 0; m_upos = 0; m_curr = m_curr_line[m_spos]; m_uskip = get_utf8_size(m_curr); m_uskip--; return; } else { m_last_line = true; m_curr = EOF; return; } } } m_curr = m_curr_line[m_spos]; if (m_uskip > 0) { if (!is_utf8_next(m_curr)) throw_exception("invalid utf-8 sequence character"); m_uskip--; } else { m_upos++; m_uskip = get_utf8_size(m_curr); m_uskip--; } }