diff --git a/src/Lexer.cpp b/src/Lexer.cpp index 6d8e36350..855ee095d 100644 --- a/src/Lexer.cpp +++ b/src/Lexer.cpp @@ -999,3 +999,15 @@ bool Lexer::isAllDigits (const std::string& text) } //////////////////////////////////////////////////////////////////////////////// +bool Lexer::isOneWord (const std::string& text) +{ + std::string::size_type i = 0; + int character; + while ((character = utf8_next_char (text, i))) + if (Lexer::isWhitespace (character)) + return false; + + return true; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/Lexer.h b/src/Lexer.h index 3bb07ce6b..b5cde1d42 100644 --- a/src/Lexer.h +++ b/src/Lexer.h @@ -59,6 +59,7 @@ public: static std::vector split (const std::string&); static std::string typeToString (Lexer::Type); static bool isAllDigits (const std::string&); + static bool isOneWord (const std::string&); // Static helpers. static const std::string typeName (const Lexer::Type&);