Add new lex() function to streamline lexing, change main to reflect this

This commit is contained in:
2025-09-30 17:52:53 +03:00
committed by Emin Arslan
parent 08136c6492
commit 6f58051284
3 changed files with 23 additions and 4 deletions

View File

@@ -135,5 +135,19 @@ Token Lexer::next() {
}
}
vector<Token> Lexer::collect() {
vector<Token> v;
while (true) {
Token t = next();
if (t.type == TokenType::End)
break;
v.push_back(t);
}
return v;
}
std::vector<Token> lex(std::string s) {
Lexer l(s);
return l.collect();
}