- Added a strict analysis mode that throws errors. In non-strict mode no errors
  are thrown because parsing is incomplete most of the time, and only the final
  pass needs to be strict.
This commit is contained in:
Paul Beckingham 2014-11-08 14:00:39 -05:00
parent 11d210a7c7
commit b9b998c769
3 changed files with 10 additions and 8 deletions

View file

@ -219,6 +219,7 @@ const std::string A::dump () const
////////////////////////////////////////////////////////////////////////////////
CLI::CLI ()
: _strict (false)
{
}
@ -283,13 +284,16 @@ void CLI::add (const std::string& arg)
// Intended to be called after ::initialize() and ::add(), to perform the final
// analysis. Analysis is also performed directly after the above, because there
// is a need to extract overrides early, before entities are proviedd.
void CLI::analyze (bool parse /* = true */)
void CLI::analyze (bool parse /* = true */, bool strict /* = false */)
{
// Clean what needs to be cleaned. Most in this case.
_args.clear ();
_id_ranges.clear ();
_uuid_list.clear ();
// For propagation.
_strict = strict;
for (int i = 0; i < _original_args.size (); ++i)
{
if (i == 0)
@ -1785,13 +1789,10 @@ void CLI::injectDefaults ()
context.header ("[" + combined + "]");
}
// TODO This fails because when ::injectDefaults is first run,
// ::applyOverrides has not yet been called.
else
// Only an error in strict mode.
else if (_strict)
{
/*
throw std::string (STRING_TRIVIAL_INPUT);
*/
}
}
else