From 52d2bbd11a470d898a7f7919c7a13689d771234c Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 26 Jul 2015 12:09:40 -0400 Subject: [PATCH] Lexer: Implemented ::isOneOf using a std::map as input --- src/Lexer.cpp | 10 ++++++++++ src/Lexer.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/Lexer.cpp b/src/Lexer.cpp index bea0a5099..a4a14cb74 100644 --- a/src/Lexer.cpp +++ b/src/Lexer.cpp @@ -1127,6 +1127,16 @@ bool Lexer::isOneOf (const std::vector & options, bool endBoundary) return false; } +//////////////////////////////////////////////////////////////////////////////// +bool Lexer::isOneOf (const std::map & options, bool endBoundary) +{ + for (auto& item : options) + if (isLiteral (item.first, endBoundary)) + return true; + + return false; +} + //////////////////////////////////////////////////////////////////////////////// // Static std::string Lexer::typeToString (Lexer::Type type) diff --git a/src/Lexer.h b/src/Lexer.h index 93aec21cb..476776755 100644 --- a/src/Lexer.h +++ b/src/Lexer.h @@ -28,6 +28,7 @@ #define INCLUDED_LEXER #include +#include #include #include @@ -107,6 +108,7 @@ public: bool isWord (std::string&, Lexer::Type&); bool isLiteral (const std::string&, bool); bool isOneOf (const std::vector &, bool); + bool isOneOf (const std::map &, bool); private: std::string _text;