mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-29 07:57:20 +02:00
Lexer: Implemented ::decomposePattern
This commit is contained in:
parent
1f8a66b7f3
commit
d0e4f4ca10
2 changed files with 27 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -80,6 +80,7 @@ public:
|
|||
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 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, int);
|
||||
static int hexToInt (int, int, int, int);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue