- Implemented ::disqualifyFirstLastBinary to detect arguments that start or end
  with a binary operator, and are therefore not expressions.
This commit is contained in:
Paul Beckingham 2014-11-09 15:20:42 -05:00
parent 33bc4f13d0
commit d8d517706b
2 changed files with 19 additions and 1 deletions

View file

@ -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;
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -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;