- Modify ::disqualifyOnlyParenOps to count sugared operators.
- Labelled '(' and ')' as circumflex operators, thanks awwaiid.
This commit is contained in:
Paul Beckingham 2014-11-09 16:51:36 -05:00
parent 61e943f456
commit 3279566244
2 changed files with 18 additions and 6 deletions

View file

@ -666,7 +666,7 @@ void CLI::addArg (const std::string& arg)
if (disqualifyInsufficientTerms (lexemes) ||
disqualifyNoOps (lexemes) ||
// disqualifyOnlyParenOps (lexemes) ||
disqualifyOnlyParenOps (lexemes) ||
disqualifyFirstLastBinary (lexemes) ||
disqualifySugarFree (lexemes))
{
@ -2357,10 +2357,12 @@ bool CLI::disqualifyOnlyParenOps (
const std::vector <std::pair <std::string, Lexer::Type> >& lexemes) const
{
int opCount = 0;
int opSugarCount = 0;
int opParenCount = 0;
std::vector <std::pair <std::string, Lexer::Type> >::const_iterator l;
for (l = lexemes.begin (); l != lexemes.end (); ++l)
{
if (l->second == Lexer::typeOperator)
{
++opCount;
@ -2370,7 +2372,17 @@ bool CLI::disqualifyOnlyParenOps (
++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;
}
////////////////////////////////////////////////////////////////////////////////