Util: Rearrange Parser functions

This commit is contained in:
Riyyi
2022-07-12 01:54:15 +02:00
parent aa5b5117ad
commit a33f35faab
2 changed files with 6 additions and 7 deletions
+5 -5
View File
@@ -86,11 +86,6 @@ bool Parser::reachedEnd()
return m_index >= m_tokens->size(); return m_index >= m_tokens->size();
} }
Token Parser::peek()
{
return m_tokens->at(m_index);
}
bool Parser::seekForward(Token::Type type) bool Parser::seekForward(Token::Type type)
{ {
for (; !reachedEnd(); ++m_index) { for (; !reachedEnd(); ++m_index) {
@@ -103,6 +98,11 @@ bool Parser::seekForward(Token::Type type)
return false; return false;
} }
Token Parser::peek()
{
return m_tokens->at(m_index);
}
Token Parser::consume() Token Parser::consume()
{ {
Token token = peek(); Token token = peek();
+1 -2
View File
@@ -26,10 +26,9 @@ public:
private: private:
bool reachedEnd(); bool reachedEnd();
Token peek();
bool seekForward(Token::Type type); bool seekForward(Token::Type type);
Token peek();
Token consume(); Token consume();
Value getLiteral(); Value getLiteral();