save current lexer impl
This commit is contained in:
@@ -80,7 +80,7 @@ public:
|
||||
}
|
||||
default:
|
||||
// fprintf(stderr, "%s:%d:%d: ERROR: unexpected token while parsing %ld\n", m_lexer->filename(), token->line_number, token->offset_start, token->token);
|
||||
ErrorLogger::Raise(Error::ParseError(m_lexer->filename(), StringView::FromFormat("unexpected token while parsing '%c'", token->token), token->line_number, token->offset_start));
|
||||
ErrorLogger::Raise(Error::ParseError(m_lexer->filename(), StringView::FromFormat("unexpected token while parsing '%d'", token->token), token->line_number, token->offset_start));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ public:
|
||||
case TokenType::Fn: program->PushFunction(ParseFnDecl()); break;
|
||||
case TokenType::Extern: program->PushExtern(ParseExtern()); break;
|
||||
default: {
|
||||
ErrorLogger::Raise(Error::ParseError(m_lexer->filename(), StringView::FromFormat("unexpected token while parsing '%c'", token.token), token.line_number, token.offset_start));
|
||||
ErrorLogger::Raise(Error::ParseError(m_lexer->filename(), StringView::FromFormat("unexpected token while parsing '%d'", token.token), token.line_number, token.offset_start));
|
||||
assert(false);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user