- Modified to obey rc.debug.parser.
This commit is contained in:
Paul Beckingham 2014-10-06 23:26:53 -04:00
parent fa011c5bfb
commit f0e4f3f4dc
2 changed files with 10 additions and 3 deletions

View file

@ -48,6 +48,7 @@ static int safetyValveDefault = 10;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Parser::Parser () Parser::Parser ()
: _debug (0)
{ {
_tree = new Tree ("root"); _tree = new Tree ("root");
} }
@ -177,6 +178,8 @@ Tree* Parser::tree ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Tree* Parser::parse () Tree* Parser::parse ()
{ {
_debug = context.config.getInteger ("debug.parser");
findBinary (); findBinary ();
findTerminator (); findTerminator ();
resolveAliases (); resolveAliases ();
@ -581,7 +584,8 @@ void Parser::injectDefaults ()
std::string defaultCommand = context.config.get ("default.command"); std::string defaultCommand = context.config.get ("default.command");
if (defaultCommand != "") if (defaultCommand != "")
{ {
context.debug ("No command or sequence found - assuming default.command."); if (_debug >= 1)
context.debug ("No command or sequence found - assuming default.command.");
// Split the defaultCommand into args, and add them in reverse order, // Split the defaultCommand into args, and add them in reverse order,
// because captureFirst inserts args immediately after the command, and // because captureFirst inserts args immediately after the command, and
@ -619,7 +623,8 @@ void Parser::injectDefaults ()
} }
else else
{ {
context.debug ("Sequence but no command found - assuming 'information' command."); if (_debug >= 1)
context.debug ("Sequence but no command found - assuming 'information' command.");
context.header (STRING_ASSUME_INFO); context.header (STRING_ASSUME_INFO);
Tree* t = captureFirst ("information"); Tree* t = captureFirst ("information");
t->tag ("ASSUMED"); t->tag ("ASSUMED");
@ -1776,7 +1781,8 @@ void Parser::validate ()
std::vector <Tree*>::iterator i; std::vector <Tree*>::iterator i;
for (i = nodes.begin (); i != nodes.end (); ++i) for (i = nodes.begin (); i != nodes.end (); ++i)
if ((*i)->hasTag ("?")) if ((*i)->hasTag ("?"))
context.debug ("Unrecognized argument '" + (*i)->attribute ("raw") + "'"); if (_debug >= 1)
context.debug ("Unrecognized argument '" + (*i)->attribute ("raw") + "'");
// TODO Any RC node must have a root/+RC @file that exists. // TODO Any RC node must have a root/+RC @file that exists.
// TODO There must be a root/+CMD. // TODO There must be a root/+CMD.

View file

@ -90,6 +90,7 @@ private:
void validate (); void validate ();
private: private:
int _debug;
Tree* _tree; Tree* _tree;
std::multimap <std::string, std::string> _entities; std::multimap <std::string, std::string> _entities;
std::map <std::string, std::string> _aliases; std::map <std::string, std::string> _aliases;