Add comments to lexer

Signed-off-by: CHatingPython <chatingpython@gmail.com>
This commit is contained in:
CHatingPython
2026-05-25 11:45:14 +02:00
committed by CHatingPython
parent 438288f8f1
commit 535b088f81
3 changed files with 38 additions and 1 deletions
+26
View File
@@ -13,6 +13,32 @@ lexer::lexer(std::string_view filename, std::string_view content)
token_handle<> lexer::next_token() {
skip_spaces();
while (m_cursor + 2 <= m_content.size() && m_content[m_cursor] == '/') {
if (m_content[m_cursor + 1] == '/') {
m_cursor += 2;
while (m_content[m_cursor] != '\n') {
next();
}
} else if (m_content[m_cursor + 1] == '*') {
m_cursor += 2;
while (m_cursor + 2 < m_content.size()) {
if (m_content[m_cursor + 1] == '*') {
next();
} else if (m_content[m_cursor + 0] != '*' || m_content[m_cursor + 1] != '/') {
next();
next();
} else {
break;
}
}
if (m_cursor + 2 >= m_content.size()) {
next();
return { current_location(), "unexpected end of file before enclosing `*/`" };
}
m_cursor += 2;
}
skip_spaces();
}
location location = current_location();