- Implemented an overload of ::token_split that preserveѕ types.
This commit is contained in:
Paul Beckingham 2014-06-14 13:46:10 -04:00
parent a892abf366
commit 7d4e166277
2 changed files with 14 additions and 0 deletions

View file

@ -662,6 +662,19 @@ void Lexer::token_split (std::vector <std::string>& words, const std::string& in
words.push_back (word);
}
////////////////////////////////////////////////////////////////////////////////
// Split 'input' into 'tokens', preserving type.
void Lexer::token_split (std::vector <std::pair <std::string, Lexer::Type> >& lexemes, const std::string& input)
{
lexemes.clear ();
std::string word;
Lexer::Type type;
Lexer lex (input);
while (lex.token (word, type))
lexemes.push_back (std::pair <std::string, Lexer::Type>(word, type));
}
////////////////////////////////////////////////////////////////////////////////
bool Lexer::is_punct (int c) const
{

View file

@ -67,6 +67,7 @@ public:
static bool is_ws (int);
static void word_split (std::vector <std::string>&, const std::string&);
static void token_split (std::vector <std::string>&, const std::string&);
static void token_split (std::vector <std::pair <std::string, Lexer::Type> >&, const std::string&);
private:
bool is_punct (int) const;