mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-29 17:07:19 +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) ||
|
if (disqualifyInsufficientTerms (lexemes) ||
|
||||||
disqualifyNoOps (lexemes) ||
|
disqualifyNoOps (lexemes) ||
|
||||||
disqualifyOnlyParenOps (lexemes))
|
disqualifyOnlyParenOps (lexemes) ||
|
||||||
|
disqualifyFirstLastBinary (lexemes))
|
||||||
{
|
{
|
||||||
_original_args.push_back (raw);
|
_original_args.push_back (raw);
|
||||||
}
|
}
|
||||||
|
@ -2370,4 +2371,20 @@ bool CLI::disqualifyOnlyParenOps (
|
||||||
|
|
||||||
return opCount == opParenCount;
|
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 disqualifyInsufficientTerms (const std::vector <std::pair <std::string, Lexer::Type> >&) const;
|
||||||
bool disqualifyNoOps (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 disqualifyOnlyParenOps (const std::vector <std::pair <std::string, Lexer::Type> >&) const;
|
||||||
|
bool disqualifyFirstLastBinary (const std::vector <std::pair <std::string, Lexer::Type> >&) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::multimap <std::string, std::string> _entities;
|
std::multimap <std::string, std::string> _entities;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue