CLI2: Removed unused ::addArgs method

This commit is contained in:
Paul Beckingham 2015-06-20 11:59:37 -07:00
parent db3150d7b2
commit 20d259a129
2 changed files with 1 additions and 68 deletions

View file

@ -695,74 +695,6 @@ const std::string CLI2::dump (const std::string& title) const
return out.str (); return out.str ();
} }
/*
////////////////////////////////////////////////////////////////////////////////
// Note: This seems silly - it's essentially performing a low-quality parse. But
// that is really all that is needed - to separate the args that need to
// be lexed from those that need to be left alone.
//
// Either the arg is appended to _original_args intact, or the lexemes are.
void CLI2::addArg (const std::string& arg)
{
std::string raw = trim (arg);
// Do not lex these constructs.
if (isTerminator (raw)) // --
_terminated = true;
// This is the case where the argument should not be lexed, which is when it
// is a single entity, and recognized.
if (_terminated ||
isRCOverride (raw) || // rc:<file>
isConfigOverride (raw) || // rc.<attr>:<value>
isCommand (raw) || // <cmd>
isTag (raw) || // [+-]<tag>
isUUIDList (raw) || // <uuid>,[uuid ...]
isUUID (raw) || // <uuid>
isIDSequence (raw) || // <id>[-<id>][,<id>[-<id>] ...]
isID (raw) || // <id>
isPattern (raw) || // /<pattern</
isSubstitution (raw) || // /<from>/<to>/[g]
isAttribute (raw) || // <name>[.[~]<modifier>]:<value>
isOperator (raw)) // <operator>
{
_original_args.push_back (raw);
}
// The argument may require lexing. Lex anyway, and analyze before comitting
// to that.
else
{
// Lex each remaining argument. The apply a series of disqualifying tests
// that cause the lexemes to be ignored, and the original arugment used
// intact.
std::string lexeme;
Lexer::Type type;
Lexer lex (raw);
lex.ambiguity (false);
std::vector <std::pair <std::string, Lexer::Type>> lexemes;
while (lex.token (lexeme, type))
lexemes.push_back (std::pair <std::string, Lexer::Type> (lexeme, type));
if (disqualifyInsufficientTerms (lexemes) ||
disqualifyNoOps (lexemes) ||
disqualifyOnlyParenOps (lexemes) ||
disqualifyFirstLastBinary (lexemes))
{
_original_args.push_back (raw);
}
else
{
// How often have I said to you that when you have eliminated the
// impossible, whatever remains, however improbable, must be the truth?
for (auto& l : lexemes)
_original_args.push_back (l.first);
}
}
}
*/
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void CLI2::aliasExpansion () void CLI2::aliasExpansion ()
{ {

View file

@ -124,6 +124,7 @@ private:
bool isUUIDList (const std::string&) const; bool isUUIDList (const std::string&) const;
// These methods come up iwht reasons not to Lex a token. Probably no longer needed.
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;