From 39983e5f8261af0be89d0667e38acfe7ab40a5bc Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 4 Nov 2014 22:53:12 -0500 Subject: [PATCH] CLI - Implemented ::isName. --- src/CLI.cpp | 19 +++++++++++++++++++ src/CLI.h | 1 + 2 files changed, 20 insertions(+) diff --git a/src/CLI.cpp b/src/CLI.cpp index b0740ff68..82957218d 100644 --- a/src/CLI.cpp +++ b/src/CLI.cpp @@ -2248,3 +2248,22 @@ bool CLI::isOperator (const std::string& raw) const } //////////////////////////////////////////////////////////////////////////////// +bool CLI::isName (const std::string& raw) const +{ + if (raw != "") + { + for (int i = 0; i < raw.length (); ++i) + { + if (i == 0 && ! Lexer::is_ident_start (raw[i])) + return false; + else if (! Lexer::is_ident (raw[i])) + return false; + } + + return true; + } + + return false; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/CLI.h b/src/CLI.h index 82dd43e0e..c015a3b3e 100644 --- a/src/CLI.h +++ b/src/CLI.h @@ -119,6 +119,7 @@ private: bool isSubstitution (const std::string&) const; bool isAttribute (const std::string&) const; bool isOperator (const std::string&) const; + bool isName (const std::string&) const; public: std::multimap _entities;