mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
CLI
- Implemented ::disqualifyFirstLastBinary to detect arguments that start or end with a binary operator, and are therefore not expressions.
This commit is contained in:
parent
33bc4f13d0
commit
d8d517706b
2 changed files with 19 additions and 1 deletions
19
src/CLI.cpp
19
src/CLI.cpp
|
@ -666,7 +666,8 @@ void CLI::addArg (const std::string& arg)
|
|||
|
||||
if (disqualifyInsufficientTerms (lexemes) ||
|
||||
disqualifyNoOps (lexemes) ||
|
||||
disqualifyOnlyParenOps (lexemes))
|
||||
disqualifyOnlyParenOps (lexemes) ||
|
||||
disqualifyFirstLastBinary (lexemes))
|
||||
{
|
||||
_original_args.push_back (raw);
|
||||
}
|
||||
|
@ -2370,4 +2371,20 @@ bool CLI::disqualifyOnlyParenOps (
|
|||
|
||||
return opCount == opParenCount;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool CLI::disqualifyFirstLastBinary (
|
||||
const std::vector <std::pair <std::string, Lexer::Type> >& lexemes) const
|
||||
{
|
||||
std::string dummy;
|
||||
if (canonicalize (dummy, "binary_operator", lexemes[0].first))
|
||||
return true;
|
||||
|
||||
if (lexemes.size () > 1 &&
|
||||
canonicalize (dummy, "binary_operator", lexemes[lexemes.size () - 1].first))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -129,6 +129,7 @@ private:
|
|||
bool disqualifyInsufficientTerms (const std::vector <std::pair <std::string, Lexer::Type> >&) const;
|
||||
bool disqualifyNoOps (const std::vector <std::pair <std::string, Lexer::Type> >&) const;
|
||||
bool disqualifyOnlyParenOps (const std::vector <std::pair <std::string, Lexer::Type> >&) const;
|
||||
bool disqualifyFirstLastBinary (const std::vector <std::pair <std::string, Lexer::Type> >&) const;
|
||||
|
||||
public:
|
||||
std::multimap <std::string, std::string> _entities;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue