From 2155bd39691a928134e28b7c48c9d1430b7ae9f3 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 21 Feb 2015 10:58:07 -0800 Subject: [PATCH] Lexer2 - Implemented ::isAllDigits to distinguish between integers and real numbers. --- src/Lexer2.cpp | 6 ++++++ src/Lexer2.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/Lexer2.cpp b/src/Lexer2.cpp index d16eeff48..119a93d95 100644 --- a/src/Lexer2.cpp +++ b/src/Lexer2.cpp @@ -965,3 +965,9 @@ std::string Lexer2::typeToString (Lexer2::Type type) } //////////////////////////////////////////////////////////////////////////////// +bool Lexer2::isAllDigits (const std::string& text) +{ + return text.find_first_not_of ("0123456789") == std::string::npos; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/Lexer2.h b/src/Lexer2.h index 9cf3ea1e3..70cf99aa5 100644 --- a/src/Lexer2.h +++ b/src/Lexer2.h @@ -58,6 +58,7 @@ public: static std::vector > tokens (const std::string&); static std::vector split (const std::string&); static std::string typeToString (Lexer2::Type); + static bool isAllDigits (const std::string&); // Static helpers. static const std::string typeName (const Lexer2::Type&);