From 137b00a14a7b49b31ad1137ab637eaf5d23e2ef2 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 17 Jul 2011 13:52:55 -0400 Subject: [PATCH] Expressions - Commented out troublesome "distance_from_command" code. - Commented out DOM diagnostics, for now. - Commented out TDB2 diagnostics, for now. - Category "seq" arguments are now assigned type "exp". - All type "exp" arguments are now tokenized. --- src/Arguments.cpp | 42 ++++++++++++++++----------------- src/DOM.cpp | 2 +- src/Expression.cpp | 51 +++++++++++++++++----------------------- src/TDB2.cpp | 34 +++++++++++++-------------- src/commands/Command.cpp | 3 ++- 5 files changed, 63 insertions(+), 69 deletions(-) diff --git a/src/Arguments.cpp b/src/Arguments.cpp index be763b85c..4d4d3a605 100644 --- a/src/Arguments.cpp +++ b/src/Arguments.cpp @@ -288,7 +288,7 @@ void Arguments::categorize () // Track where the command is, if possible. int command_pos = -1; - int distance_from_command = 0; +// int distance_from_command = 0; // Configurable support. bool enable_expressions = context.config.getBoolean ("expressions"); @@ -367,8 +367,8 @@ void Arguments::categorize () // [-][,...] else if (is_id (arg->_first)) { - if (found_something_after_sequence || - (command_pos != -1 && distance_from_command > 0)) + if (found_something_after_sequence/* || + (command_pos != -1 && distance_from_command > 0)*/) { arg->_third = "word"; } @@ -382,8 +382,8 @@ void Arguments::categorize () // [,...] else if (is_uuid (arg->_first)) { - if (found_something_after_sequence || - (command_pos != -1 && distance_from_command > 0)) + if (found_something_after_sequence/* || + (command_pos != -1 && distance_from_command > 0)*/) { arg->_third = "word"; } @@ -401,8 +401,8 @@ void Arguments::categorize () if (found_sequence) found_something_after_sequence = true; - if (command_pos != -1) - ++distance_from_command; +// if (command_pos != -1) +// ++distance_from_command; arg->_third = "tag"; } @@ -414,8 +414,8 @@ void Arguments::categorize () if (found_sequence) found_something_after_sequence = true; - if (command_pos != -1) - ++distance_from_command; +// if (command_pos != -1) +// ++distance_from_command; arg->_third = "attmod"; } @@ -427,8 +427,8 @@ void Arguments::categorize () if (found_sequence) found_something_after_sequence = true; - if (command_pos != -1) - ++distance_from_command; +// if (command_pos != -1) +// ++distance_from_command; arg->_third = "attr"; } @@ -440,8 +440,8 @@ void Arguments::categorize () if (found_sequence) found_something_after_sequence = true; - if (command_pos != -1) - ++distance_from_command; +// if (command_pos != -1) +// ++distance_from_command; arg->_third = "subst"; } @@ -453,8 +453,8 @@ void Arguments::categorize () if (found_sequence) found_something_after_sequence = true; - if (command_pos != -1) - ++distance_from_command; +// if (command_pos != -1) +// ++distance_from_command; arg->_third = "pattern"; } @@ -466,8 +466,8 @@ void Arguments::categorize () if (found_sequence) found_something_after_sequence = true; - if (command_pos != -1) - ++distance_from_command; +// if (command_pos != -1) +// ++distance_from_command; arg->_third = "op"; } @@ -479,8 +479,8 @@ void Arguments::categorize () if (found_sequence) found_something_after_sequence = true; - if (command_pos != -1) - ++distance_from_command; +// if (command_pos != -1) +// ++distance_from_command; arg->_second = "exp"; arg->_third = "exp"; @@ -493,8 +493,8 @@ void Arguments::categorize () if (found_sequence) found_something_after_sequence = true; - if (command_pos != -1) - ++distance_from_command; +// if (command_pos != -1) +// ++distance_from_command; arg->_third = "word"; } diff --git a/src/DOM.cpp b/src/DOM.cpp index 3b8d2820d..43b219aef 100644 --- a/src/DOM.cpp +++ b/src/DOM.cpp @@ -309,7 +309,7 @@ bool DOM::is_primitive (const std::string& input) if (n.getInt (i) && n.depleted ()) return true; - std::cout << "# DOM::is_primitive '" << input << "' --> unknown\n"; +// std::cout << "# DOM::is_primitive '" << input << "' --> unknown\n"; return false; } diff --git a/src/Expression.cpp b/src/Expression.cpp index dbb74b0ab..28c2a2d49 100644 --- a/src/Expression.cpp +++ b/src/Expression.cpp @@ -60,20 +60,17 @@ bool Expression::evalFilter (const Task& task) if (!_prepared) { - if (_args.size ()) - { - _args.dump ("Expression::evalFilter"); + _args.dump ("Expression::evalFilter"); - expand_sequence (); - implicit_and (); - expand_tag (); - expand_pattern (); - expand_attr (); - expand_attmod (); - expand_word (); - expand_tokens (); - postfix (); - } + expand_sequence (); + implicit_and (); + expand_tag (); + expand_pattern (); + expand_attr (); + expand_attmod (); + expand_word (); + expand_tokens (); + postfix (); _prepared = true; } @@ -96,20 +93,17 @@ std::string Expression::evalExpression (const Task& task) if (!_prepared) { - if (_args.size ()) - { - _args.dump ("Expression::evalFilter"); + _args.dump ("Expression::evalExpression"); - expand_sequence (); - implicit_and (); - expand_tag (); - expand_pattern (); - expand_attr (); - expand_attmod (); - expand_word (); - expand_tokens (); - postfix (); - } + expand_sequence (); + implicit_and (); + expand_tag (); + expand_pattern (); + expand_attr (); + expand_attmod (); + expand_word (); + expand_tokens (); + postfix (); _prepared = true; } @@ -558,7 +552,7 @@ void Expression::expand_sequence () } // Now insert the new sequence expression. - temp.push_back (Triple (sequence.str (), "", "seq")); + temp.push_back (Triple (sequence.str (), "exp", "seq")); // Now copy everything after the last id/uuid. bool found_id = false; @@ -588,8 +582,7 @@ void Expression::expand_tokens () std::vector ::iterator arg; for (arg = _args.begin (); arg != _args.end (); ++arg) { - if (arg->_third == "seq" || - arg->_third == "exp") + if (arg->_second == "exp") { tokenize (arg->_first, arg->_third, operators, temp); delta = true; diff --git a/src/TDB2.cpp b/src/TDB2.cpp index 28bac036b..c45a8a8ca 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -54,13 +54,13 @@ void TF2::target (const std::string& f) _file = File (f); _read_only = ! _file.writable (); - std::cout << "# TF2::target " << f << "\n"; +// std::cout << "# TF2::target " << f << "\n"; } //////////////////////////////////////////////////////////////////////////////// const std::vector & TF2::get_tasks () { - std::cout << "# TF2::get_tasks\n"; +// std::cout << "# TF2::get_tasks\n"; if (! _loaded_tasks) load_tasks (); @@ -71,7 +71,7 @@ const std::vector & TF2::get_tasks () //////////////////////////////////////////////////////////////////////////////// const std::vector & TF2::get_lines () { - std::cout << "# TF2::get_lines\n"; +// std::cout << "# TF2::get_lines\n"; if (! _loaded_lines) load_lines (); @@ -82,7 +82,7 @@ const std::vector & TF2::get_lines () //////////////////////////////////////////////////////////////////////////////// const std::string& TF2::get_contents () { - std::cout << "# TF2::get_contents\n"; +// std::cout << "# TF2::get_contents\n"; if (! _loaded_contents) load_contents (); @@ -93,7 +93,7 @@ const std::string& TF2::get_contents () //////////////////////////////////////////////////////////////////////////////// void TF2::add_task (const Task& task) { - std::cout << "# TF2::add_task\n"; +// std::cout << "# TF2::add_task\n"; _tasks.push_back (task); // For subsequent queries _added_tasks.push_back (task); // For commit/synch @@ -103,7 +103,7 @@ void TF2::add_task (const Task& task) //////////////////////////////////////////////////////////////////////////////// void TF2::modify_task (const Task& task) { - std::cout << "# TF2::modify_task\n"; +// std::cout << "# TF2::modify_task\n"; // Modify in-place. std::vector ::iterator i; @@ -123,7 +123,7 @@ void TF2::modify_task (const Task& task) //////////////////////////////////////////////////////////////////////////////// void TF2::add_line (const std::string& line) { - std::cout << "# TF2::add_line\n"; +// std::cout << "# TF2::add_line\n"; _added_lines.push_back (line); _dirty = true; @@ -133,7 +133,7 @@ void TF2::add_line (const std::string& line) // This is so that synch.key can just overwrite and not grow. void TF2::clear_lines () { - std::cout << "# TF2::clear_lines\n"; +// std::cout << "# TF2::clear_lines\n"; _lines.clear (); _dirty = true; } @@ -142,7 +142,7 @@ void TF2::clear_lines () // Top-down recomposition. void TF2::commit () { - std::cout << "# TF2::commit " << _file.data << "\n"; +// std::cout << "# TF2::commit " << _file.data << "\n"; // The _dirty flag indicates that the file needs to be written. if (_dirty) @@ -239,7 +239,7 @@ void TF2::commit () //////////////////////////////////////////////////////////////////////////////// void TF2::load_tasks () { - std::cout << "# TF2::load_tasks\n"; +// std::cout << "# TF2::load_tasks\n"; if (! _loaded_lines) load_lines (); @@ -274,7 +274,7 @@ void TF2::load_tasks () //////////////////////////////////////////////////////////////////////////////// void TF2::load_lines () { - std::cout << "# TF2::load_lines\n"; +// std::cout << "# TF2::load_lines\n"; if (! _loaded_contents) load_contents (); @@ -286,7 +286,7 @@ void TF2::load_lines () //////////////////////////////////////////////////////////////////////////////// void TF2::load_contents () { - std::cout << "# TF2::load_contents\n"; +// std::cout << "# TF2::load_contents\n"; _contents = ""; @@ -330,7 +330,7 @@ TDB2::~TDB2 () // read. void TDB2::set_location (const std::string& location) { - std::cout << "# TDB2::set_location " << location << "\n"; +// std::cout << "# TDB2::set_location " << location << "\n"; _location = location; pending.target (location + "/pending.data"); @@ -344,7 +344,7 @@ void TDB2::set_location (const std::string& location) // Add the new task to the appropriate file. void TDB2::add (const Task& task) { - std::cout << "# TDB2::add\n"; +// std::cout << "# TDB2::add\n"; std::string status = task.get ("status"); if (status == "completed" || @@ -359,7 +359,7 @@ void TDB2::add (const Task& task) //////////////////////////////////////////////////////////////////////////////// void TDB2::modify (const Task& task) { - std::cout << "# TDB2::modify\n"; +// std::cout << "# TDB2::modify\n"; std::string status = task.get ("status"); if (status == "completed" || @@ -375,7 +375,7 @@ void TDB2::modify (const Task& task) void TDB2::commit () { dump (); - std::cout << "# TDB2::commit\n"; +// std::cout << "# TDB2::commit\n"; pending.commit (); completed.commit (); undo.commit (); @@ -391,7 +391,7 @@ void TDB2::commit () // Now cleans up dangling dependencies. int TDB2::gc () { - std::cout << "# TDB2::gc\n"; +// std::cout << "# TDB2::gc\n"; /* pending.load_tasks completed.load_tasks diff --git a/src/commands/Command.cpp b/src/commands/Command.cpp index ed019a499..2c1fa343a 100644 --- a/src/commands/Command.cpp +++ b/src/commands/Command.cpp @@ -263,6 +263,7 @@ bool Command::displays_id () const } //////////////////////////////////////////////////////////////////////////////// +// Filter a specific list of tasks. void Command::filter (std::vector & input, std::vector & output) { Timer timer ("Command::filter"); @@ -287,6 +288,7 @@ void Command::filter (std::vector & input, std::vector & output) } //////////////////////////////////////////////////////////////////////////////// +// Filter all tasks. void Command::filter (std::vector & output) { Timer timer ("Command::filter"); @@ -300,7 +302,6 @@ void Command::filter (std::vector & output) if (f.size ()) { const std::vector & pending = context.tdb2.pending.get_tasks (); - Expression e (f); output.clear ();