- ::addArg now lexes args, and looks for embedded operators before deciding to
  use the lexemes.
This commit is contained in:
Paul Beckingham 2014-10-31 20:11:34 -04:00
parent 975b20a517
commit 7420ef8e28

View file

@ -504,7 +504,7 @@ void CLI::addArg (const std::string& arg)
_original_args.push_back (arg); _original_args.push_back (arg);
} }
// Do not lex, unless lexing reveals OPs. // Lex, but only use lexemes if an operator is found in there.
else else
{ {
// Lex each argument. If there are multiple lexemes, create sub branches, // Lex each argument. If there are multiple lexemes, create sub branches,
@ -518,16 +518,15 @@ void CLI::addArg (const std::string& arg)
while (lex.token (lexeme, type)) while (lex.token (lexeme, type))
lexemes.push_back (std::pair <std::string, Lexer::Type> (lexeme, type)); lexemes.push_back (std::pair <std::string, Lexer::Type> (lexeme, type));
// This one looks interesting.
if (lexemes.size () > 1)
{
bool foundOP = false; bool foundOP = false;
std::vector <std::pair <std::string, Lexer::Type> >::iterator l; std::vector <std::pair <std::string, Lexer::Type> >::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)
foundOP = true; foundOP = true;
if (foundOP) // This one looks interesting.
if (lexemes.size () > 1 &&
foundOP)
{ {
for (l = lexemes.begin (); l != lexemes.end (); ++l) for (l = lexemes.begin (); l != lexemes.end (); ++l)
_original_args.push_back (l->first); _original_args.push_back (l->first);
@ -535,9 +534,6 @@ void CLI::addArg (const std::string& arg)
else else
_original_args.push_back (arg); _original_args.push_back (arg);
} }
else
_original_args.push_back (arg);
}
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////