From 37e31e8e0bb26460f85468e6e539b3a5ff448082 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 25 Jul 2015 17:34:51 -0400 Subject: [PATCH] Lexer: Implemented ::isOneOf, to help with parsing --- src/Lexer.cpp | 10 ++++++++++ src/Lexer.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/Lexer.cpp b/src/Lexer.cpp index e9efbee0d..69466465e 100644 --- a/src/Lexer.cpp +++ b/src/Lexer.cpp @@ -1092,6 +1092,16 @@ bool Lexer::isLiteral (const std::string& literal) return false; } +//////////////////////////////////////////////////////////////////////////////// +bool Lexer::isOneOf (const std::vector & options) +{ + for (auto& item : options) + if (isLiteral (item)) + return true; + + return false; +} + //////////////////////////////////////////////////////////////////////////////// // Static std::string Lexer::typeToString (Lexer::Type type) diff --git a/src/Lexer.h b/src/Lexer.h index 18857ea61..5042255c7 100644 --- a/src/Lexer.h +++ b/src/Lexer.h @@ -105,6 +105,7 @@ public: bool isIdentifier (std::string&, Lexer::Type&); bool isWord (std::string&, Lexer::Type&); bool isLiteral (const std::string&); + bool isOneOf (const std::vector &); private: std::string _text;