save current lexer impl

This commit is contained in:
2026-01-03 15:02:26 +01:00
parent 6176d549c1
commit 629b65e151
4 changed files with 17 additions and 25 deletions

View File

@@ -73,7 +73,7 @@ public:
auto lnl = m_last_newline;
if (!NextToken())
{
return nullptr;
return new Token(TokenType::Eof, m_line, m_pos - m_last_newline, m_pos - m_last_newline);
}
auto seeked = m_token;
m_token = s;
@@ -92,11 +92,11 @@ public:
public:
bool NextToken()
{
// if (m_pos >= m_code.len())
// {
// m_token = Token(TokenType::Eof);
// return false;
// }
if (m_pos > m_code.len())
{
m_token = Token(TokenType::Eof);
return false;
}
char c = m_code.data[m_pos++];
@@ -109,7 +109,7 @@ public:
c = m_code.data[m_pos++];
}
if (m_pos >= m_code.len())
if (m_pos-1 > m_code.len())
{
m_token = Token(TokenType::Eof);
return false;
@@ -126,7 +126,7 @@ public:
s.Push(m_code.data[m_pos++]);
}
s.Push('\0');
m_token = Token(TokenType::Id, m_line, offset_start, m_pos - m_last_newline);
m_token = Token(TokenType::Id, m_line, offset_start, offset_start);
m_token.string = s.view();
if (strcmp("extern", m_token.string.c_str()) == 0)