diff --git a/src/A3.h b/src/A3.h index 231dd036e..57eb469da 100644 --- a/src/A3.h +++ b/src/A3.h @@ -41,7 +41,6 @@ public: A3& operator= (const A3&); ~A3 (); - void capture (int, const char**); void capture (const std::string&); void capture_first (const std::string&); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4cc58b0ad..0160feb7e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,7 +6,6 @@ include_directories (${CMAKE_SOURCE_DIR} ${TASK_INCLUDE_DIRS}) set (task_SRCS A3.cpp A3.h - A3t.cpp A3t.h Alias.cpp Alias.h Arg.cpp Arg.h Color.cpp Color.h @@ -28,6 +27,7 @@ set (task_SRCS A3.cpp A3.h Msg.cpp Msg.h Nibbler.cpp Nibbler.h OldDuration.cpp OldDuration.h + Parser.cpp Parser.h Path.cpp Path.h RX.cpp RX.h TDB2.cpp TDB2.h diff --git a/src/Context.cpp b/src/Context.cpp index 4cbb88b63..e6ffcaa79 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -104,18 +104,18 @@ int Context::initialize (int argc, const char** argv) // Initialize the command line parser. a3.capture (argc, argv); - a3t.initialize (argc, argv); // task arg0 arg1 ... + parser.initialize (argc, argv); // task arg0 arg1 ... // echo one two -- three | task zero --> task zero one two // 'three' is left in the input buffer. a3.append_stdin (); - a3t.appendStdin (); // echo stdin0 | task ... + parser.appendStdin (); // echo stdin0 | task ... // Process 'rc:' command line override, and remove the argument from the // Context::a3. a3.categorize (); - a3t.findOverrides (); // rc: rc.: - a3t.getOverrides (home_dir, rc_file); // <-- + parser.findOverrides (); // rc: rc.: + parser.getOverrides (home_dir, rc_file); // <-- // TASKRC environment variable overrides the command line. char* override = getenv ("TASKRC"); @@ -132,7 +132,7 @@ int Context::initialize (int argc, const char** argv) // The data location, Context::data_dir, is determined from the assumed // location (~/.task), or set by data.location in the config file, or // overridden by rc.data.location on the command line. - a3t.getDataLocation (data_dir); // <-- rc.data.location= + parser.getDataLocation (data_dir); // <-- rc.data.location= override = getenv ("TASKDATA"); if (override) @@ -144,14 +144,14 @@ int Context::initialize (int argc, const char** argv) // Create missing config file and data directory, if necessary. a3.apply_overrides (); - a3t.applyOverrides (); + parser.applyOverrides (); createDefaultConfig (); // Handle Aliases. loadAliases (); a3.resolve_aliases (); aliases2.load (); - aliases2.resolve (a3t.tree ()); + aliases2.resolve (parser.tree ()); // Initialize the color rules, if necessary. if (color ()) @@ -163,39 +163,39 @@ int Context::initialize (int argc, const char** argv) for (cmd = commands.begin (); cmd != commands.end (); ++cmd) { if (cmd->first[0] == '_') - a3t.entity ("helper", cmd->first); + parser.entity ("helper", cmd->first); else if (cmd->second->read_only ()) - a3t.entity ("readcmd", cmd->first); + parser.entity ("readcmd", cmd->first); else - a3t.entity ("writecmd", cmd->first); + parser.entity ("writecmd", cmd->first); } // Instantiate built-in column objects. Column::factory (columns); std::map ::iterator col; for (col = columns.begin (); col != columns.end (); ++col) - a3t.entity ("attribute", col->first); + parser.entity ("attribute", col->first); // Entities: Pseudo-attributes. - a3t.entity ("pseudo", "limit"); + parser.entity ("pseudo", "limit"); // Entities: Modifiers. for (unsigned int i = 0; i < NUM_MODIFIER_NAMES; ++i) - a3t.entity ("modifier", modifierNames[i]); + parser.entity ("modifier", modifierNames[i]); // Entities: Operators. std::vector operators; Eval::getOperators (operators); std::vector ::iterator op; for (op = operators.begin (); op != operators.end (); ++op) - a3t.entity ("operator", *op); + parser.entity ("operator", *op); // Now the entities are loaded, parsing may resume. - a3t.findBinary (); // - a3t.findCommand (); // - a3t.findUUIDList (); // Before findIdSequence - a3t.findIdSequence (); // - a3t.injectDefaults (); // rc.default.command + parser.findBinary (); // + parser.findCommand (); // + parser.findUUIDList (); // Before findIdSequence + parser.findIdSequence (); // + parser.injectDefaults (); // rc.default.command // Static initialization to decouple code. staticInitialization (); @@ -214,7 +214,7 @@ int Context::initialize (int argc, const char** argv) a3.dump ("Context::initialize"); // Parse the command line. - Tree* parseTree = a3t.parse (); + Tree* parseTree = parser.parse (); if (parseTree && config.getBoolean ("debug")) debug (parseTree->dump ()); diff --git a/src/Context.h b/src/Context.h index 28af481ec..96883464e 100644 --- a/src/Context.h +++ b/src/Context.h @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include class Context @@ -85,7 +85,7 @@ private: public: std::string program; A3 a3; - A3t a3t; + Parser parser; std::string home_dir; File rc_file; Path data_dir; diff --git a/src/DOM.cpp b/src/DOM.cpp index 0b365cbc8..a0a007ffe 100644 --- a/src/DOM.cpp +++ b/src/DOM.cpp @@ -89,12 +89,12 @@ const std::string DOM::get (const std::string& name) if (len > 8 && name.substr (0, 8) == "context.") { - if (name == "context.program") return context.a3t.tree ()->_branches[0]->attribute ("raw"); + if (name == "context.program") return context.parser.tree ()->_branches[0]->attribute ("raw"); else if (name == "context.args") { std::string combined; std::vector ::iterator i; - for (i = context.a3t.tree ()->_branches.begin (); i != context.a3t.tree ()->_branches.end (); ++i) + for (i = context.parser.tree ()->_branches.begin (); i != context.parser.tree ()->_branches.end (); ++i) { if (combined != "") combined += " "; @@ -170,7 +170,7 @@ const std::string DOM::get (const std::string& name, const Task& task) return format (task.urgency_c ()); std::string canonical; - if (task.size () && context.a3t.canonicalize (canonical, "attribute", name)) + if (task.size () && context.parser.canonicalize (canonical, "attribute", name)) return task.get (canonical); // . diff --git a/src/Filter.cpp b/src/Filter.cpp index fa319535a..6804574e2 100644 --- a/src/Filter.cpp +++ b/src/Filter.cpp @@ -74,12 +74,12 @@ void Filter::subset (const std::vector & input, std::vector & output if (context.config.getBoolean ("debug")) { - Tree* t = context.a3t.tree (); + Tree* t = context.parser.tree (); if (t) context.debug (t->dump ()); } - std::string filterExpr = context.a3t.getFilterExpression (); + std::string filterExpr = context.parser.getFilterExpression (); context.debug ("\033[1;37;42mFILTER\033[0m " + filterExpr); if (filterExpr.length ()) @@ -120,12 +120,12 @@ void Filter::subset (std::vector & output) if (context.config.getBoolean ("debug")) { - Tree* t = context.a3t.tree (); + Tree* t = context.parser.tree (); if (t) context.debug (t->dump ()); } - std::string filterExpr = context.a3t.getFilterExpression (); + std::string filterExpr = context.parser.getFilterExpression (); context.debug ("\033[1;37;42mFILTER\033[0m " + filterExpr); if (filterExpr.length ()) @@ -201,7 +201,7 @@ void Filter::subset (std::vector & output) // term, then completed.data does not need to be loaded. bool Filter::pendingOnly () { - Tree* tree = context.a3t.tree (); + Tree* tree = context.parser.tree (); // If the filter starts with "status:pending", the completed.data does not // need to be accessed.. @@ -248,13 +248,13 @@ bool Filter::pendingOnly () // all tasks to be modified. This is usually not intended. void Filter::safety () { - Tree* tree = context.a3t.tree (); + Tree* tree = context.parser.tree (); std::vector ::iterator i; for (i = tree->_branches.begin (); i != tree->_branches.end (); ++i) { if ((*i)->hasTag ("WRITECMD")) { - if (context.a3t.getFilterExpression () == "") + if (context.parser.getFilterExpression () == "") { // If user is willing to be asked, this can be avoided. if (context.config.getBoolean ("confirmation") && diff --git a/src/A3t.cpp b/src/Parser.cpp similarity index 97% rename from src/A3t.cpp rename to src/Parser.cpp index 7f8a2d7d2..7b422988d 100644 --- a/src/A3t.cpp +++ b/src/Parser.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -50,7 +50,7 @@ static int minimumMatchLength = 3; const int safetyValveDefault = 10; //////////////////////////////////////////////////////////////////////////////// -A3t::A3t () +Parser::Parser () { _tree = new Tree ("root"); if (! _tree) @@ -58,14 +58,14 @@ A3t::A3t () } //////////////////////////////////////////////////////////////////////////////// -A3t::~A3t () +Parser::~Parser () { delete _tree; } //////////////////////////////////////////////////////////////////////////////// // char** argv --> std::vector _args -void A3t::initialize (int argc, const char** argv) +void Parser::initialize (int argc, const char** argv) { // Set up constants. minimumMatchLength = strtol (context.config.get ("abbreviation.minimum").c_str (), NULL, 10); @@ -81,7 +81,7 @@ void A3t::initialize (int argc, const char** argv) } //////////////////////////////////////////////////////////////////////////////// -void A3t::clear () +void Parser::clear () { delete _tree; @@ -95,7 +95,7 @@ void A3t::clear () // // echo one two -- three | task zero --> task zero one two // 'three' is left in the input buffer. -void A3t::appendStdin () +void Parser::appendStdin () { #ifdef FEATURE_STDIN // Use 'select' to determine whether there is any std::cin content buffered @@ -133,13 +133,13 @@ void A3t::appendStdin () } //////////////////////////////////////////////////////////////////////////////// -Tree* A3t::tree () +Tree* Parser::tree () { return _tree; } //////////////////////////////////////////////////////////////////////////////// -Tree* A3t::parse () +Tree* Parser::parse () { findTerminator (); findSubstitution (); @@ -160,14 +160,14 @@ Tree* A3t::parse () } //////////////////////////////////////////////////////////////////////////////// -void A3t::entity (const std::string& name, const std::string& value) +void Parser::entity (const std::string& name, const std::string& value) { _entities.insert (std::pair (name, value)); } //////////////////////////////////////////////////////////////////////////////// // Search for 'value' in _entities category, return canonicalized value. -bool A3t::canonicalize ( +bool Parser::canonicalize ( std::string& canonicalized, const std::string& category, const std::string& value) const @@ -195,7 +195,7 @@ bool A3t::canonicalize ( //////////////////////////////////////////////////////////////////////////////// // Locate and tag the binary. -void A3t::findBinary () +void Parser::findBinary () { if (_tree->_branches.size () >= 1) { @@ -224,7 +224,7 @@ void A3t::findBinary () //////////////////////////////////////////////////////////////////////////////// // The parser override operator terminates all subsequent cleverness, leaving // all args in the raw state. -void A3t::findTerminator () +void Parser::findTerminator () { bool found = false; std::vector ::iterator i; @@ -248,7 +248,7 @@ void A3t::findTerminator () //////////////////////////////////////////////////////////////////////////////// // Walk the top-level tree branches, looking for the first raw value that // autoCompletes to a valid command/report. -void A3t::findCommand () +void Parser::findCommand () { // There can be only one. // Scan for an existing CMD tag, to short-circuit scanning for another. @@ -323,7 +323,7 @@ void A3t::findCommand () //////////////////////////////////////////////////////////////////////////////// // rc: // rc.[:=] -void A3t::findOverrides () +void Parser::findOverrides () { std::vector ::iterator i; for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i) @@ -362,7 +362,7 @@ void A3t::findOverrides () //////////////////////////////////////////////////////////////////////////////// // Look for RC and return file as a File. -void A3t::getOverrides ( +void Parser::getOverrides ( std::string& home, File& rc) { @@ -390,7 +390,7 @@ void A3t::getOverrides ( //////////////////////////////////////////////////////////////////////////////// // Look for CONFIG data.location and return value as a Path. -void A3t::getDataLocation (Path& data) +void Parser::getDataLocation (Path& data) { std::string location = context.config.get ("data.location"); if (location != "") @@ -414,7 +414,7 @@ void A3t::getDataLocation (Path& data) //////////////////////////////////////////////////////////////////////////////// // Takes all CONFIG name/value pairs and overrides configuration. // leaving only the plain args. -void A3t::applyOverrides () +void Parser::applyOverrides () { std::vector ::iterator i; for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i) @@ -430,7 +430,7 @@ void A3t::applyOverrides () } //////////////////////////////////////////////////////////////////////////////// -void A3t::injectDefaults () +void Parser::injectDefaults () { // Scan the top-level branches for evidence of ID, UUID, overrides and other // arguments. @@ -502,7 +502,7 @@ void A3t::injectDefaults () } //////////////////////////////////////////////////////////////////////////////// -Tree* A3t::captureFirst (const std::string& arg) +Tree* Parser::captureFirst (const std::string& arg) { // Insert the arg as the new first branch. Tree* t = new Tree ("argIns"); @@ -524,7 +524,7 @@ Tree* A3t::captureFirst (const std::string& arg) } //////////////////////////////////////////////////////////////////////////////// -const std::string A3t::getFilterExpression () +const std::string Parser::getFilterExpression () { // Construct an efficient ID/UUID clause. std::string sequence = ""; @@ -570,7 +570,7 @@ const std::string A3t::getFilterExpression () } //////////////////////////////////////////////////////////////////////////////// -const std::vector A3t::getWords () const +const std::vector Parser::getWords () const { std::vector words; std::vector ::const_iterator i; @@ -589,7 +589,7 @@ const std::vector A3t::getWords () const } //////////////////////////////////////////////////////////////////////////////// -std::string A3t::getLimit () const +std::string Parser::getLimit () const { std::vector ::const_iterator i; for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i) @@ -610,7 +610,7 @@ std::string A3t::getLimit () const //////////////////////////////////////////////////////////////////////////////// // /pattern/ --> description ~ pattern -void A3t::findPattern () +void Parser::findPattern () { std::vector ::iterator i; for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i) @@ -648,7 +648,7 @@ void A3t::findPattern () //////////////////////////////////////////////////////////////////////////////// // /from/to/[g] -void A3t::findSubstitution () +void Parser::findSubstitution () { std::vector ::iterator i; for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i) @@ -689,7 +689,7 @@ void A3t::findSubstitution () //////////////////////////////////////////////////////////////////////////////// // +tag -void A3t::findTag () +void Parser::findTag () { std::vector ::iterator i; for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i) @@ -732,7 +732,7 @@ void A3t::findTag () //////////////////////////////////////////////////////////////////////////////// // :['"][]['"] -void A3t::findAttribute () +void Parser::findAttribute () { std::vector ::iterator i; for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i) @@ -808,7 +808,7 @@ void A3t::findAttribute () //////////////////////////////////////////////////////////////////////////////// // .[:=]['"]['"] -void A3t::findAttributeModifier () +void Parser::findAttributeModifier () { std::vector ::iterator i; for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i) @@ -1014,7 +1014,7 @@ void A3t::findAttributeModifier () // // The sequence is "1 2". // -void A3t::findIdSequence () +void Parser::findIdSequence () { std::vector ::iterator i; for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i) @@ -1143,7 +1143,7 @@ void A3t::findIdSequence () } //////////////////////////////////////////////////////////////////////////////// -void A3t::findUUIDList () +void Parser::findUUIDList () { std::vector ::iterator i; for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i) @@ -1214,7 +1214,7 @@ void A3t::findUUIDList () } //////////////////////////////////////////////////////////////////////////////// -void A3t::findOperator () +void Parser::findOperator () { // Find the category. std::pair ::const_iterator, std::multimap ::const_iterator> c; @@ -1255,7 +1255,7 @@ void A3t::findOperator () //////////////////////////////////////////////////////////////////////////////// // Anything before CMD, but not BINARY, RC or CONFIG --> FILTER // Anything after READCMD, but not BINARY, RC or CONFIG --> FILTER -void A3t::findFilter () +void Parser::findFilter () { bool before_cmd = true; bool after_readcmd = false; @@ -1295,7 +1295,7 @@ void A3t::findFilter () } //////////////////////////////////////////////////////////////////////////////// -void A3t::findModifications () +void Parser::findModifications () { bool after_writecmd = false; std::vector ::iterator i; @@ -1320,7 +1320,7 @@ void A3t::findModifications () //////////////////////////////////////////////////////////////////////////////// // This is called after parsing. The intention is to find plain arguments that // are not otherwise recognized, and potentially promote them to patterns. -void A3t::findPlainArgs () +void Parser::findPlainArgs () { std::vector ::iterator i; for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i) @@ -1335,7 +1335,7 @@ void A3t::findPlainArgs () } //////////////////////////////////////////////////////////////////////////////// -void A3t::findMissingOperators () +void Parser::findMissingOperators () { while (insertOr ()) ; @@ -1346,7 +1346,7 @@ void A3t::findMissingOperators () //////////////////////////////////////////////////////////////////////////////// // Two consecutive ID/UUID arguments get an 'or' inserted between them. -bool A3t::insertOr () +bool Parser::insertOr () { std::vector ::iterator prev = _tree->_branches.begin (); std::vector ::iterator i; @@ -1391,7 +1391,7 @@ bool A3t::insertOr () // ) ( --> ) and ( // --> and // -bool A3t::insertAnd () +bool Parser::insertAnd () { std::vector ::iterator prev = _tree->_branches.begin (); std::vector ::iterator i; @@ -1445,7 +1445,7 @@ bool A3t::insertAnd () //////////////////////////////////////////////////////////////////////////////// // Validate the parse tree. -void A3t::validate () +void Parser::validate () { // Look for any unrecognized original args. std::vector ::iterator i; diff --git a/src/A3t.h b/src/Parser.h similarity index 96% rename from src/A3t.h rename to src/Parser.h index a2b45476b..5333740ef 100644 --- a/src/A3t.h +++ b/src/Parser.h @@ -23,8 +23,8 @@ // http://www.opensource.org/licenses/mit-license.php // //////////////////////////////////////////////////////////////////////////////// -#ifndef INCLUDED_A3T -#define INCLUDED_A3T +#ifndef INCLUDED_PARSER +#define INCLUDED_PARSER #include #include @@ -32,11 +32,11 @@ #include #include -class A3t +class Parser { public: - A3t (); - ~A3t (); + Parser (); + ~Parser (); void initialize (int, const char**); void clear (); void appendStdin (); diff --git a/src/args.cpp b/src/args.cpp index 8b91dbdc1..af09d9d8b 100644 --- a/src/args.cpp +++ b/src/args.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include Context context; @@ -35,177 +35,177 @@ int main (int argc, const char** argv) { try { - A3t a3t; - a3t.initialize (argc, argv); - a3t.appendStdin (); - a3t.findOverrides (); + Parser parser; + parser.initialize (argc, argv); + parser.appendStdin (); + parser.findOverrides (); Alias alias; - alias.resolve (a3t.tree ()); + alias.resolve (parser.tree ()); // Reports. - a3t.entity ("report", "active"); - a3t.entity ("report", "all"); - a3t.entity ("report", "blocked"); - a3t.entity ("report", "blocking"); - a3t.entity ("report", "burndown.daily"); - a3t.entity ("report", "burndown.monthly"); - a3t.entity ("report", "burndown.weekly"); - a3t.entity ("report", "completed"); - a3t.entity ("report", "ghistory.annual"); - a3t.entity ("report", "ghistory.monthly"); - a3t.entity ("report", "history.annual"); - a3t.entity ("report", "history.monthly"); - a3t.entity ("report", "information"); - a3t.entity ("report", "list"); - a3t.entity ("report", "long"); - a3t.entity ("report", "ls"); - a3t.entity ("report", "minimal"); - a3t.entity ("report", "newest"); - a3t.entity ("report", "next"); - a3t.entity ("report", "oldest"); - a3t.entity ("report", "overdue"); - a3t.entity ("report", "projects"); - a3t.entity ("report", "ready"); - a3t.entity ("report", "recurring"); - a3t.entity ("report", "summary"); - a3t.entity ("report", "tags"); - a3t.entity ("report", "unblocked"); - a3t.entity ("report", "waiting"); + parser.entity ("report", "active"); + parser.entity ("report", "all"); + parser.entity ("report", "blocked"); + parser.entity ("report", "blocking"); + parser.entity ("report", "burndown.daily"); + parser.entity ("report", "burndown.monthly"); + parser.entity ("report", "burndown.weekly"); + parser.entity ("report", "completed"); + parser.entity ("report", "ghistory.annual"); + parser.entity ("report", "ghistory.monthly"); + parser.entity ("report", "history.annual"); + parser.entity ("report", "history.monthly"); + parser.entity ("report", "information"); + parser.entity ("report", "list"); + parser.entity ("report", "long"); + parser.entity ("report", "ls"); + parser.entity ("report", "minimal"); + parser.entity ("report", "newest"); + parser.entity ("report", "next"); + parser.entity ("report", "oldest"); + parser.entity ("report", "overdue"); + parser.entity ("report", "projects"); + parser.entity ("report", "ready"); + parser.entity ("report", "recurring"); + parser.entity ("report", "summary"); + parser.entity ("report", "tags"); + parser.entity ("report", "unblocked"); + parser.entity ("report", "waiting"); // Read-only commands. - a3t.entity ("readcmd", "export"); - a3t.entity ("readcmd", "info"); - a3t.entity ("readcmd", "list"); - a3t.entity ("readcmd", "next"); - a3t.entity ("readcmd", "projects"); + parser.entity ("readcmd", "export"); + parser.entity ("readcmd", "info"); + parser.entity ("readcmd", "list"); + parser.entity ("readcmd", "next"); + parser.entity ("readcmd", "projects"); // Write commands. - a3t.entity ("writecmd", "add"); - a3t.entity ("writecmd", "annotate"); - a3t.entity ("writecmd", "delete"); - a3t.entity ("writecmd", "denotate"); - a3t.entity ("writecmd", "done"); - a3t.entity ("writecmd", "modify"); - a3t.entity ("writecmd", "start"); - a3t.entity ("writecmd", "stop"); + parser.entity ("writecmd", "add"); + parser.entity ("writecmd", "annotate"); + parser.entity ("writecmd", "delete"); + parser.entity ("writecmd", "denotate"); + parser.entity ("writecmd", "done"); + parser.entity ("writecmd", "modify"); + parser.entity ("writecmd", "start"); + parser.entity ("writecmd", "stop"); // Special commands. - a3t.entity ("specialcmd", "calendar"); - a3t.entity ("specialcmd", "edit"); - a3t.entity ("writecmd", "import"); + parser.entity ("specialcmd", "calendar"); + parser.entity ("specialcmd", "edit"); + parser.entity ("writecmd", "import"); // Helper commands. - a3t.entity ("helper", "_aliases"); - a3t.entity ("helper", "_columns"); - a3t.entity ("helper", "_commands"); - a3t.entity ("helper", "_config"); - a3t.entity ("helper", "_get"); - a3t.entity ("helper", "_ids"); - a3t.entity ("helper", "_projects"); - a3t.entity ("helper", "_show"); - a3t.entity ("helper", "_tags"); - a3t.entity ("helper", "_udas"); - a3t.entity ("helper", "_urgency"); - a3t.entity ("helper", "_uuids"); - a3t.entity ("helper", "_version"); - a3t.entity ("helper", "_zshcommands"); - a3t.entity ("helper", "_zshids"); - a3t.entity ("helper", "_zshuuids"); + parser.entity ("helper", "_aliases"); + parser.entity ("helper", "_columns"); + parser.entity ("helper", "_commands"); + parser.entity ("helper", "_config"); + parser.entity ("helper", "_get"); + parser.entity ("helper", "_ids"); + parser.entity ("helper", "_projects"); + parser.entity ("helper", "_show"); + parser.entity ("helper", "_tags"); + parser.entity ("helper", "_udas"); + parser.entity ("helper", "_urgency"); + parser.entity ("helper", "_uuids"); + parser.entity ("helper", "_version"); + parser.entity ("helper", "_zshcommands"); + parser.entity ("helper", "_zshids"); + parser.entity ("helper", "_zshuuids"); // Attributes (columns). - a3t.entity ("attribute", "depends"); - a3t.entity ("attribute", "description"); - a3t.entity ("attribute", "due"); - a3t.entity ("attribute", "end"); - a3t.entity ("attribute", "entry"); - a3t.entity ("attribute", "id"); - a3t.entity ("attribute", "imask"); - a3t.entity ("attribute", "mask"); - a3t.entity ("attribute", "modified"); - a3t.entity ("attribute", "parent"); - a3t.entity ("attribute", "priority"); - a3t.entity ("attribute", "project"); - a3t.entity ("attribute", "recur"); - a3t.entity ("attribute", "scheduled"); - a3t.entity ("attribute", "start"); - a3t.entity ("attribute", "status"); - a3t.entity ("attribute", "tags"); - a3t.entity ("attribute", "until"); - a3t.entity ("attribute", "urgency"); - a3t.entity ("attribute", "uuid"); - a3t.entity ("attribute", "wait"); + parser.entity ("attribute", "depends"); + parser.entity ("attribute", "description"); + parser.entity ("attribute", "due"); + parser.entity ("attribute", "end"); + parser.entity ("attribute", "entry"); + parser.entity ("attribute", "id"); + parser.entity ("attribute", "imask"); + parser.entity ("attribute", "mask"); + parser.entity ("attribute", "modified"); + parser.entity ("attribute", "parent"); + parser.entity ("attribute", "priority"); + parser.entity ("attribute", "project"); + parser.entity ("attribute", "recur"); + parser.entity ("attribute", "scheduled"); + parser.entity ("attribute", "start"); + parser.entity ("attribute", "status"); + parser.entity ("attribute", "tags"); + parser.entity ("attribute", "until"); + parser.entity ("attribute", "urgency"); + parser.entity ("attribute", "uuid"); + parser.entity ("attribute", "wait"); // Pseudo-attributes. - a3t.entity ("pseudo", "limit"); + parser.entity ("pseudo", "limit"); // UDAs. - a3t.entity ("attribute", "duration"); - a3t.entity ("uda", "duration"); + parser.entity ("attribute", "duration"); + parser.entity ("uda", "duration"); // Modifiers. - a3t.entity ("modifier", "before"); - a3t.entity ("modifier", "under"); - a3t.entity ("modifier", "below"); - a3t.entity ("modifier", "after"); - a3t.entity ("modifier", "over"); - a3t.entity ("modifier", "above"); - a3t.entity ("modifier", "none"); - a3t.entity ("modifier", "any"); - a3t.entity ("modifier", "is"); - a3t.entity ("modifier", "equals"); - a3t.entity ("modifier", "isnt"); - a3t.entity ("modifier", "not"); - a3t.entity ("modifier", "has"); - a3t.entity ("modifier", "contains"); - a3t.entity ("modifier", "hasnt"); - a3t.entity ("modifier", "startswith"); - a3t.entity ("modifier", "left"); - a3t.entity ("modifier", "endswith"); - a3t.entity ("modifier", "right"); - a3t.entity ("modifier", "word"); - a3t.entity ("modifier", "noword"); + parser.entity ("modifier", "before"); + parser.entity ("modifier", "under"); + parser.entity ("modifier", "below"); + parser.entity ("modifier", "after"); + parser.entity ("modifier", "over"); + parser.entity ("modifier", "above"); + parser.entity ("modifier", "none"); + parser.entity ("modifier", "any"); + parser.entity ("modifier", "is"); + parser.entity ("modifier", "equals"); + parser.entity ("modifier", "isnt"); + parser.entity ("modifier", "not"); + parser.entity ("modifier", "has"); + parser.entity ("modifier", "contains"); + parser.entity ("modifier", "hasnt"); + parser.entity ("modifier", "startswith"); + parser.entity ("modifier", "left"); + parser.entity ("modifier", "endswith"); + parser.entity ("modifier", "right"); + parser.entity ("modifier", "word"); + parser.entity ("modifier", "noword"); // Operators. - a3t.entity ("operator", "^"); - a3t.entity ("operator", "!"); - a3t.entity ("operator", "_neg_"); - a3t.entity ("operator", "_pos_"); - a3t.entity ("operator", "_hastag_"); - a3t.entity ("operator", "_notag_"); - a3t.entity ("operator", "*"); - a3t.entity ("operator", "/"); - a3t.entity ("operator", "%"); - a3t.entity ("operator", "+"); - a3t.entity ("operator", "-"); - a3t.entity ("operator", "<="); - a3t.entity ("operator", ">="); - a3t.entity ("operator", ">"); - a3t.entity ("operator", "<"); - a3t.entity ("operator", "="); - a3t.entity ("operator", "=="); - a3t.entity ("operator", "!="); - a3t.entity ("operator", "~"); - a3t.entity ("operator", "!~"); - a3t.entity ("operator", "and"); - a3t.entity ("operator", "or"); - a3t.entity ("operator", "xor"); - a3t.entity ("operator", "("); - a3t.entity ("operator", ")"); + parser.entity ("operator", "^"); + parser.entity ("operator", "!"); + parser.entity ("operator", "_neg_"); + parser.entity ("operator", "_pos_"); + parser.entity ("operator", "_hastag_"); + parser.entity ("operator", "_notag_"); + parser.entity ("operator", "*"); + parser.entity ("operator", "/"); + parser.entity ("operator", "%"); + parser.entity ("operator", "+"); + parser.entity ("operator", "-"); + parser.entity ("operator", "<="); + parser.entity ("operator", ">="); + parser.entity ("operator", ">"); + parser.entity ("operator", "<"); + parser.entity ("operator", "="); + parser.entity ("operator", "=="); + parser.entity ("operator", "!="); + parser.entity ("operator", "~"); + parser.entity ("operator", "!~"); + parser.entity ("operator", "and"); + parser.entity ("operator", "or"); + parser.entity ("operator", "xor"); + parser.entity ("operator", "("); + parser.entity ("operator", ")"); - a3t.findBinary (); - a3t.findCommand (); - a3t.findUUIDList (); - a3t.findIdSequence (); - a3t.injectDefaults (); + parser.findBinary (); + parser.findCommand (); + parser.findUUIDList (); + parser.findIdSequence (); + parser.injectDefaults (); - Tree* tree = a3t.parse (); + Tree* tree = parser.parse (); if (tree) std::cout << tree->dump (); std::cout << "\n" << " \033[1;37;42mFILTER\033[0m " - << a3t.getFilterExpression () + << parser.getFilterExpression () << "\n"; } diff --git a/src/commands/CmdBurndown.cpp b/src/commands/CmdBurndown.cpp index 6603656fe..060b539e2 100644 --- a/src/commands/CmdBurndown.cpp +++ b/src/commands/CmdBurndown.cpp @@ -208,7 +208,7 @@ Chart::Chart (char type) // Set the title. _title = "("; std::vector ::iterator i; - for (i = context.a3t.tree ()->_branches.begin (); i != context.a3t.tree ()->_branches.end (); ++i) + for (i = context.parser.tree ()->_branches.begin (); i != context.parser.tree ()->_branches.end (); ++i) { if (! (*i)->hasTag ("BINARY") && ! (*i)->hasTag ("RC") && diff --git a/src/commands/CmdCalc.cpp b/src/commands/CmdCalc.cpp index ab86327fc..9789663e2 100644 --- a/src/commands/CmdCalc.cpp +++ b/src/commands/CmdCalc.cpp @@ -75,7 +75,7 @@ int CmdCalc::execute (std::string& output) // Compile all the args into one expression. std::string expression; - std::vector words = context.a3t.getWords (); + std::vector words = context.parser.getWords (); std::vector ::iterator word; for (word = words.begin (); word != words.end (); ++word) expression += *word + " "; diff --git a/src/commands/CmdCalendar.cpp b/src/commands/CmdCalendar.cpp index 27d08b8b6..fa67c3333 100644 --- a/src/commands/CmdCalendar.cpp +++ b/src/commands/CmdCalendar.cpp @@ -103,7 +103,7 @@ int CmdCalendar::execute (std::string& output) int argYear = 0; bool argWholeYear = false; - std::vector words = context.a3t.getWords (); + std::vector words = context.parser.getWords (); std::vector ::iterator arg; for (arg = words.begin (); arg != words.end (); ++arg) @@ -338,9 +338,9 @@ int CmdCalendar::execute (std::string& output) std::string report_filter = context.config.get ("report." + report + ".filter"); - context.a3t.clear (); - context.a3t.captureFirst ("task"); - context.a3t.parse (); + context.parser.clear (); + context.parser.captureFirst ("task"); + context.parser.parse (); report_filter += " due.after:" + after + " due.before:" + before + " -nocal"; context.config.set ("report." + report + ".filter", report_filter); diff --git a/src/commands/CmdColor.cpp b/src/commands/CmdColor.cpp index e2523fe47..ca92c99f4 100644 --- a/src/commands/CmdColor.cpp +++ b/src/commands/CmdColor.cpp @@ -54,7 +54,7 @@ int CmdColor::execute (std::string& output) #ifdef FEATURE_COLOR // Get the non-attribute, non-fancy command line arguments. bool legend = false; - std::vector words = context.a3t.getWords (); + std::vector words = context.parser.getWords (); std::vector ::iterator word; for (word = words.begin (); word != words.end (); ++word) if (closeEnough ("legend", *word)) diff --git a/src/commands/CmdColumns.cpp b/src/commands/CmdColumns.cpp index 3eea09b4d..4199884ce 100644 --- a/src/commands/CmdColumns.cpp +++ b/src/commands/CmdColumns.cpp @@ -51,7 +51,7 @@ int CmdColumns::execute (std::string& output) { // Obtain the arguments from the description. That way, things like '--' // have already been handled. - std::vector words = context.a3t.getWords (); + std::vector words = context.parser.getWords (); if (words.size () > 1) throw std::string (STRING_CMD_COLUMNS_ARGS); diff --git a/src/commands/CmdConfig.cpp b/src/commands/CmdConfig.cpp index e185492a2..a87aadacb 100644 --- a/src/commands/CmdConfig.cpp +++ b/src/commands/CmdConfig.cpp @@ -53,7 +53,7 @@ int CmdConfig::execute (std::string& output) std::stringstream out; // Get the non-attribute, non-fancy command line arguments. - std::vector words = context.a3t.getWords (); + std::vector words = context.parser.getWords (); // Support: // task config name value # set name to value diff --git a/src/commands/CmdCustom.cpp b/src/commands/CmdCustom.cpp index ce1f5a36a..5b0808032 100644 --- a/src/commands/CmdCustom.cpp +++ b/src/commands/CmdCustom.cpp @@ -92,13 +92,13 @@ int CmdCustom::execute (std::string& output) // TODO Obsolete, but for now prevents 'operator mismatch' errors. context.a3.capture_first (*arg); - Tree* t = context.a3t.captureFirst (*arg); + Tree* t = context.parser.captureFirst (*arg); t->tag ("CUSTOM"); t->tag ("FILTER"); } // TODO Obsolete, but for now prevents 'operator mismatch' errors.. - context.a3t.parse (); + context.parser.parse (); context.a3.categorize (); // Apply filter. @@ -239,7 +239,7 @@ void CmdCustom::getLimits (const std::string& report, int& rows, int& lines) // If the custom report has a defined limit, then allow a numeric override. // This is an integer specified as a filter (limit:10). - std::string limit = context.a3t.getLimit (); + std::string limit = context.parser.getLimit (); if (limit != "") { if (limit == "page") diff --git a/src/commands/CmdExec.cpp b/src/commands/CmdExec.cpp index 3a058d1fe..001f61c90 100644 --- a/src/commands/CmdExec.cpp +++ b/src/commands/CmdExec.cpp @@ -48,7 +48,7 @@ CmdExec::CmdExec () int CmdExec::execute (std::string& output) { std::string command_line; - join (command_line, " ", context.a3t.getWords ()); + join (command_line, " ", context.parser.getWords ()); return system (command_line.c_str ()); } diff --git a/src/commands/CmdGet.cpp b/src/commands/CmdGet.cpp index afb76b84f..e481b47ec 100644 --- a/src/commands/CmdGet.cpp +++ b/src/commands/CmdGet.cpp @@ -48,7 +48,7 @@ int CmdGet::execute (std::string& output) { // Obtain the arguments from the description. That way, things like '--' // have already been handled. - std::vector words = context.a3t.getWords (); + std::vector words = context.parser.getWords (); if (words.size () == 0) throw std::string (STRING_CMD_GET_NO_DOM); diff --git a/src/commands/CmdImport.cpp b/src/commands/CmdImport.cpp index 7f33ec426..044ff6643 100644 --- a/src/commands/CmdImport.cpp +++ b/src/commands/CmdImport.cpp @@ -54,7 +54,7 @@ int CmdImport::execute (std::string& output) int count = 0; // Use the description as a file name. - std::vector words = context.a3t.getWords (); + std::vector words = context.parser.getWords (); if (! words.size ()) throw std::string (STRING_CMD_IMPORT_NOFILE); diff --git a/src/commands/CmdShow.cpp b/src/commands/CmdShow.cpp index 513af1d01..d23346063 100644 --- a/src/commands/CmdShow.cpp +++ b/src/commands/CmdShow.cpp @@ -56,7 +56,7 @@ int CmdShow::execute (std::string& output) // Obtain the arguments from the description. That way, things like '--' // have already been handled. - std::vector words = context.a3t.getWords (); + std::vector words = context.parser.getWords (); if (words.size () > 1) throw std::string (STRING_CMD_SHOW_ARGS); diff --git a/src/commands/CmdSync.cpp b/src/commands/CmdSync.cpp index 17d8a1ba8..528875d32 100644 --- a/src/commands/CmdSync.cpp +++ b/src/commands/CmdSync.cpp @@ -56,7 +56,7 @@ int CmdSync::execute (std::string& output) // Loog for the 'init' keyword to indicate one-time pending.data upload. bool first_time_init = false; - std::vector words = context.a3t.getWords (); + std::vector words = context.parser.getWords (); std::vector ::iterator word; for (word = words.begin (); word != words.end (); ++word) { diff --git a/src/commands/CmdTimesheet.cpp b/src/commands/CmdTimesheet.cpp index 8852bf1cd..ec8024c89 100644 --- a/src/commands/CmdTimesheet.cpp +++ b/src/commands/CmdTimesheet.cpp @@ -73,7 +73,7 @@ int CmdTimesheet::execute (std::string& output) // Determine how many reports to run. int quantity = 1; - std::vector words = context.a3t.getWords (); + std::vector words = context.parser.getWords (); if (words.size () == 1) quantity = strtol (words[0].c_str (), NULL, 10);; diff --git a/src/commands/CmdUndo.cpp b/src/commands/CmdUndo.cpp index b3ff41cb9..b6103bde3 100644 --- a/src/commands/CmdUndo.cpp +++ b/src/commands/CmdUndo.cpp @@ -46,7 +46,7 @@ int CmdUndo::execute (std::string& output) { // Detect attempts to modify the task. std::vector ::iterator i; - for (i = context.a3t.tree ()->_branches.begin (); i != context.a3t.tree ()->_branches.end (); ++i) + for (i = context.parser.tree ()->_branches.begin (); i != context.parser.tree ()->_branches.end (); ++i) if ((*i)->hasTag ("MODIFICATION")) throw std::string (STRING_CMD_UNDO_MODS); diff --git a/src/shell/main.cpp b/src/shell/main.cpp index 63b23a5e4..4018ce8db 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -110,12 +110,12 @@ int main (int argc, const char** argv) // Make a copy because context.clear will delete them. std::string permanent_overrides; std::vector ::iterator i; - for (i = context.a3t.tree ()->_branches.begin (); i != context.a3t.tree ()->_branches.end (); ++i) + for (i = context.parser.tree ()->_branches.begin (); i != context.parser.tree ()->_branches.end (); ++i) { if ((*i)->hasTag ("RC") || (*i)->hasTag ("CONFIG")) { - if (i != context.a3t.tree ()->_branches.begin ()) + if (i != context.parser.tree ()->_branches.begin ()) permanent_overrides += " "; permanent_overrides += (*i)->attribute ("raw"); diff --git a/test/dom.t.cpp b/test/dom.t.cpp index 86661ea86..361b93d75 100644 --- a/test/dom.t.cpp +++ b/test/dom.t.cpp @@ -46,7 +46,7 @@ int main (int argc, char** argv) { // Prime the pump. const char* fake_argv[] = {"task"}; - context.a3t.initialize (1, fake_argv); + context.parser.initialize (1, fake_argv); DOM dom; t.is (dom.get ("system.version"), VERSION, "DOM system.version -> VERSION");