mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-29 17:07:19 +02:00
CLI
- Modify ::disqualifyOnlyParenOps to count sugared operators. - Labelled '(' and ')' as circumflex operators, thanks awwaiid.
This commit is contained in:
parent
61e943f456
commit
3279566244
2 changed files with 18 additions and 6 deletions
16
src/CLI.cpp
16
src/CLI.cpp
|
@ -666,7 +666,7 @@ void CLI::addArg (const std::string& arg)
|
||||||
|
|
||||||
if (disqualifyInsufficientTerms (lexemes) ||
|
if (disqualifyInsufficientTerms (lexemes) ||
|
||||||
disqualifyNoOps (lexemes) ||
|
disqualifyNoOps (lexemes) ||
|
||||||
// disqualifyOnlyParenOps (lexemes) ||
|
disqualifyOnlyParenOps (lexemes) ||
|
||||||
disqualifyFirstLastBinary (lexemes) ||
|
disqualifyFirstLastBinary (lexemes) ||
|
||||||
disqualifySugarFree (lexemes))
|
disqualifySugarFree (lexemes))
|
||||||
{
|
{
|
||||||
|
@ -2357,10 +2357,12 @@ bool CLI::disqualifyOnlyParenOps (
|
||||||
const std::vector <std::pair <std::string, Lexer::Type> >& lexemes) const
|
const std::vector <std::pair <std::string, Lexer::Type> >& lexemes) const
|
||||||
{
|
{
|
||||||
int opCount = 0;
|
int opCount = 0;
|
||||||
|
int opSugarCount = 0;
|
||||||
int opParenCount = 0;
|
int opParenCount = 0;
|
||||||
|
|
||||||
std::vector <std::pair <std::string, Lexer::Type> >::const_iterator l;
|
std::vector <std::pair <std::string, Lexer::Type> >::const_iterator l;
|
||||||
for (l = lexemes.begin (); l != lexemes.end (); ++l)
|
for (l = lexemes.begin (); l != lexemes.end (); ++l)
|
||||||
|
{
|
||||||
if (l->second == Lexer::typeOperator)
|
if (l->second == Lexer::typeOperator)
|
||||||
{
|
{
|
||||||
++opCount;
|
++opCount;
|
||||||
|
@ -2370,7 +2372,17 @@ bool CLI::disqualifyOnlyParenOps (
|
||||||
++opParenCount;
|
++opParenCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
return opCount == opParenCount;
|
else if (isTag (l->first) ||
|
||||||
|
isUUIDList (l->first) ||
|
||||||
|
isUUID (l->first) ||
|
||||||
|
isIDSequence (l->first) ||
|
||||||
|
isID (l->first) ||
|
||||||
|
isPattern (l->first) ||
|
||||||
|
isAttribute (l->first))
|
||||||
|
++opSugarCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
return opCount == opParenCount && ! opSugarCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -45,8 +45,8 @@ static struct
|
||||||
{
|
{
|
||||||
std::string op;
|
std::string op;
|
||||||
int precedence;
|
int precedence;
|
||||||
char type;
|
char type; // b=binary, u=unary, c=circumfix
|
||||||
char associativity;
|
char associativity; // l=left, r=right, _=?
|
||||||
} operators[] =
|
} operators[] =
|
||||||
{
|
{
|
||||||
// Operator Precedence Type Associativity
|
// Operator Precedence Type Associativity
|
||||||
|
@ -83,8 +83,8 @@ static struct
|
||||||
{ "or", 4, 'b', 'l' }, // Disjunction
|
{ "or", 4, 'b', 'l' }, // Disjunction
|
||||||
{ "xor", 3, 'b', 'l' }, // Disjunction
|
{ "xor", 3, 'b', 'l' }, // Disjunction
|
||||||
|
|
||||||
{ "(", 0, '_', 'l' }, // Precedence start
|
{ "(", 0, 'c', '_' }, // Precedence start
|
||||||
{ ")", 0, '_', 'l' }, // Precedence end
|
{ ")", 0, 'c', '_' }, // Precedence end
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NUM_OPERATORS (sizeof (operators) / sizeof (operators[0]))
|
#define NUM_OPERATORS (sizeof (operators) / sizeof (operators[0]))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue