Lexer: Implemented ::decomposePattern

This commit is contained in:
Paul Beckingham 2015-07-11 17:09:29 -04:00
parent 1f8a66b7f3
commit d0e4f4ca10
2 changed files with 27 additions and 0 deletions

View file

@ -1437,3 +1437,29 @@ bool Lexer::decomposeSubstitution (
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// / <pattern> / [<flags>]
bool Lexer::decomposePattern (
const std::string& text,
std::string& pattern,
std::string& flags)
{
std::string parsed_pattern;
std::string::size_type cursor = 0;
if (readWord (text, "/", cursor, parsed_pattern) &&
parsed_pattern.length ())
{
std::string parsed_flags = text.substr (cursor);
if (parsed_flags.find ("/") == std::string::npos)
{
dequote (parsed_pattern, "/");
pattern = parsed_pattern;
flags = parsed_flags;
return true;
}
}
return false;
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -80,6 +80,7 @@ public:
static bool readWord (const std::string&, std::string::size_type&, std::string&); static bool readWord (const std::string&, std::string::size_type&, std::string&);
static bool decomposePair (const std::string&, std::string&, std::string&, std::string&, std::string&); static bool decomposePair (const std::string&, std::string&, std::string&, std::string&, std::string&);
static bool decomposeSubstitution (const std::string&, std::string&, std::string&, std::string&); static bool decomposeSubstitution (const std::string&, std::string&, std::string&, std::string&);
static bool decomposePattern (const std::string&, std::string&, std::string&);
static int hexToInt (int); static int hexToInt (int);
static int hexToInt (int, int); static int hexToInt (int, int);
static int hexToInt (int, int, int, int); static int hexToInt (int, int, int, int);