Lexer: Implemented ::isOneOf using a std::map as input
This commit is contained in:
@@ -1127,6 +1127,16 @@ bool Lexer::isOneOf (const std::vector <std::string>& options, bool endBoundary)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool Lexer::isOneOf (const std::map <std::string, std::string>& options, bool endBoundary)
|
||||||
|
{
|
||||||
|
for (auto& item : options)
|
||||||
|
if (isLiteral (item.first, endBoundary))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Static
|
// Static
|
||||||
std::string Lexer::typeToString (Lexer::Type type)
|
std::string Lexer::typeToString (Lexer::Type type)
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#define INCLUDED_LEXER
|
#define INCLUDED_LEXER
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
@@ -107,6 +108,7 @@ public:
|
|||||||
bool isWord (std::string&, Lexer::Type&);
|
bool isWord (std::string&, Lexer::Type&);
|
||||||
bool isLiteral (const std::string&, bool);
|
bool isLiteral (const std::string&, bool);
|
||||||
bool isOneOf (const std::vector <std::string>&, bool);
|
bool isOneOf (const std::vector <std::string>&, bool);
|
||||||
|
bool isOneOf (const std::map <std::string, std::string>&, bool);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _text;
|
std::string _text;
|
||||||
|
|||||||
Reference in New Issue
Block a user