CLI2: Added ::handleTerminator
- CLI2::handleTerminator removes all terminator arguments it finds and downgrades all subsequent arguments to Lexer::Type::word. This simplifies all further processing.
This commit is contained in:
32
src/CLI2.cpp
32
src/CLI2.cpp
@@ -393,6 +393,37 @@ void CLI2::lexArguments ()
|
|||||||
context.debug (dump ("CLI2::analyze lexArguments"));
|
context.debug (dump ("CLI2::analyze lexArguments"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CLI2::handleTerminator ()
|
||||||
|
{
|
||||||
|
bool changes = false;
|
||||||
|
bool terminated = false;
|
||||||
|
std::vector <A2> reconstructed;
|
||||||
|
for (auto& a : _args)
|
||||||
|
{
|
||||||
|
if (a._lextype == Lexer::Type::separator)
|
||||||
|
{
|
||||||
|
terminated = true;
|
||||||
|
changes = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (terminated)
|
||||||
|
a._lextype = Lexer::Type::word;
|
||||||
|
|
||||||
|
reconstructed.push_back (a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changes)
|
||||||
|
{
|
||||||
|
_args = reconstructed;
|
||||||
|
|
||||||
|
if (context.config.getInteger ("debug.parser") >= 3)
|
||||||
|
context.debug (dump ("CLI2::analyze handleTerminator"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Intended to be called after ::add() to perform the final analysis.
|
// Intended to be called after ::add() to perform the final analysis.
|
||||||
void CLI2::analyze ()
|
void CLI2::analyze ()
|
||||||
@@ -407,6 +438,7 @@ void CLI2::analyze ()
|
|||||||
_args.clear ();
|
_args.clear ();
|
||||||
handleArg0 ();
|
handleArg0 ();
|
||||||
lexArguments ();
|
lexArguments ();
|
||||||
|
handleTerminator ();
|
||||||
|
|
||||||
// Process _args.
|
// Process _args.
|
||||||
aliasExpansion ();
|
aliasExpansion ();
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ private:
|
|||||||
*/
|
*/
|
||||||
void handleArg0 ();
|
void handleArg0 ();
|
||||||
void lexArguments ();
|
void lexArguments ();
|
||||||
|
void handleTerminator ();
|
||||||
void aliasExpansion ();
|
void aliasExpansion ();
|
||||||
void findOverrides ();
|
void findOverrides ();
|
||||||
void findCommand ();
|
void findCommand ();
|
||||||
|
|||||||
Reference in New Issue
Block a user