I know there's many topics with some problems like mine but I can't find the right answer for my problem in particular.
I would like to split my string into tokens by multiples delimiter (' '
, '\n'
, '('
, ')'
) and save all in my vector (Even the delimiters).
Here's the first code I made, it actually just take all lines, but now I would like to split it with the other delimiters.
std::vector<std::string> Lexer::getToken(std::string flow)
{
std::string token;
std::vector<std::string> tokens;
std::stringstream f;
f << flow;
while (std::getline(f, token, '\n'))
{
tokens.push_back(token);
}
return (tokens);
}
Exmaple, if I have :
push int32(42)
I would like to have the folowing tokens :
push
int32
(
42
)