From f0e4f3f4dca248e7e597e5c7437729991bf28657 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 6 Oct 2014 23:26:53 -0400 Subject: [PATCH] Parser - Modified to obey rc.debug.parser. --- src/Parser.cpp | 12 +++++++++--- src/Parser.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Parser.cpp b/src/Parser.cpp index 3740b3d3b..6a136058f 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -48,6 +48,7 @@ static int safetyValveDefault = 10; //////////////////////////////////////////////////////////////////////////////// Parser::Parser () +: _debug (0) { _tree = new Tree ("root"); } @@ -177,6 +178,8 @@ Tree* Parser::tree () //////////////////////////////////////////////////////////////////////////////// Tree* Parser::parse () { + _debug = context.config.getInteger ("debug.parser"); + findBinary (); findTerminator (); resolveAliases (); @@ -581,7 +584,8 @@ void Parser::injectDefaults () std::string defaultCommand = context.config.get ("default.command"); 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, // because captureFirst inserts args immediately after the command, and @@ -619,7 +623,8 @@ void Parser::injectDefaults () } 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); Tree* t = captureFirst ("information"); t->tag ("ASSUMED"); @@ -1776,7 +1781,8 @@ void Parser::validate () std::vector ::iterator i; for (i = nodes.begin (); i != nodes.end (); ++i) 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 There must be a root/+CMD. diff --git a/src/Parser.h b/src/Parser.h index a7075dd07..1069288fb 100644 --- a/src/Parser.h +++ b/src/Parser.h @@ -90,6 +90,7 @@ private: void validate (); private: + int _debug; Tree* _tree; std::multimap _entities; std::map _aliases;