- Renamed A3t to Parser.
This commit is contained in:
Paul Beckingham 2014-05-25 09:44:22 -04:00
parent ecd64456ae
commit 79abddd03d
25 changed files with 240 additions and 241 deletions

View file

@ -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&);

View file

@ -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

View file

@ -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:<file>' command line override, and remove the argument from the
// Context::a3.
a3.categorize ();
a3t.findOverrides (); // rc:<file> rc.<name>:<value>
a3t.getOverrides (home_dir, rc_file); // <-- <file>
parser.findOverrides (); // rc:<file> rc.<name>:<value>
parser.getOverrides (home_dir, rc_file); // <-- <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=<location>
parser.getDataLocation (data_dir); // <-- rc.data.location=<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 <std::string, Column*>::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 <std::string> operators;
Eval::getOperators (operators);
std::vector <std::string>::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 (); // <task|tw|t|cal|calendar>
a3t.findCommand (); // <cmd>
a3t.findUUIDList (); // <uuid> Before findIdSequence
a3t.findIdSequence (); // <id>
a3t.injectDefaults (); // rc.default.command
parser.findBinary (); // <task|tw|t|cal|calendar>
parser.findCommand (); // <cmd>
parser.findUUIDList (); // <uuid> Before findIdSequence
parser.findIdSequence (); // <id>
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 ());

View file

@ -39,7 +39,7 @@
#include <File.h>
#include <Directory.h>
#include <A3.h>
#include <A3t.h>
#include <Parser.h>
#include <Timer.h>
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;

View file

@ -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 <Tree*>::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);
// <id>.<name>

View file

@ -74,12 +74,12 @@ void Filter::subset (const std::vector <Task>& input, std::vector <Task>& 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 <Task>& 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 <Task>& 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 <Tree*>::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") &&

View file

@ -29,7 +29,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <Context.h>
#include <A3t.h>
#include <Parser.h>
#include <Nibbler.h>
#include <Directory.h>
#include <main.h>
@ -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 <std::string> _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 <std::string, std::string> (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 <Tree*>::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:<file>
// rc.<name>[:=]<value>
void A3t::findOverrides ()
void Parser::findOverrides ()
{
std::vector <Tree*>::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 <Tree*>::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 <std::string> A3t::getWords () const
const std::vector <std::string> Parser::getWords () const
{
std::vector <std::string> words;
std::vector <Tree*>::const_iterator i;
@ -589,7 +589,7 @@ const std::vector <std::string> A3t::getWords () const
}
////////////////////////////////////////////////////////////////////////////////
std::string A3t::getLimit () const
std::string Parser::getLimit () const
{
std::vector <Tree*>::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 <Tree*>::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 <Tree*>::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 <Tree*>::iterator i;
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
@ -732,7 +732,7 @@ void A3t::findTag ()
////////////////////////////////////////////////////////////////////////////////
// <name>:['"][<value>]['"]
void A3t::findAttribute ()
void Parser::findAttribute ()
{
std::vector <Tree*>::iterator i;
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
@ -808,7 +808,7 @@ void A3t::findAttribute ()
////////////////////////////////////////////////////////////////////////////////
// <name>.<mod>[:=]['"]<value>['"]
void A3t::findAttributeModifier ()
void Parser::findAttributeModifier ()
{
std::vector <Tree*>::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 <Tree*>::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 <Tree*>::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 <std::multimap <std::string, std::string>::const_iterator, std::multimap <std::string, std::string>::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 <Tree*>::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 <Tree*>::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 <Tree*>::iterator prev = _tree->_branches.begin ();
std::vector <Tree*>::iterator i;
@ -1391,7 +1391,7 @@ bool A3t::insertOr ()
// ) ( --> ) and (
// <non-op> <non-op> --> <non-op> and <non-op>
//
bool A3t::insertAnd ()
bool Parser::insertAnd ()
{
std::vector <Tree*>::iterator prev = _tree->_branches.begin ();
std::vector <Tree*>::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 <Tree*>::iterator i;

View file

@ -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 <Tree.h>
#include <Path.h>
@ -32,11 +32,11 @@
#include <string>
#include <map>
class A3t
class Parser
{
public:
A3t ();
~A3t ();
Parser ();
~Parser ();
void initialize (int, const char**);
void clear ();
void appendStdin ();

View file

@ -26,7 +26,7 @@
#include <iostream>
#include <Context.h>
#include <A3t.h>
#include <Parser.h>
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";
}

View file

@ -208,7 +208,7 @@ Chart::Chart (char type)
// Set the title.
_title = "(";
std::vector <Tree*>::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") &&

View file

@ -75,7 +75,7 @@ int CmdCalc::execute (std::string& output)
// Compile all the args into one expression.
std::string expression;
std::vector <std::string> words = context.a3t.getWords ();
std::vector <std::string> words = context.parser.getWords ();
std::vector <std::string>::iterator word;
for (word = words.begin (); word != words.end (); ++word)
expression += *word + " ";

View file

@ -103,7 +103,7 @@ int CmdCalendar::execute (std::string& output)
int argYear = 0;
bool argWholeYear = false;
std::vector <std::string> words = context.a3t.getWords ();
std::vector <std::string> words = context.parser.getWords ();
std::vector <std::string>::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);

View file

@ -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 <std::string> words = context.a3t.getWords ();
std::vector <std::string> words = context.parser.getWords ();
std::vector <std::string>::iterator word;
for (word = words.begin (); word != words.end (); ++word)
if (closeEnough ("legend", *word))

View file

@ -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 <std::string> words = context.a3t.getWords ();
std::vector <std::string> words = context.parser.getWords ();
if (words.size () > 1)
throw std::string (STRING_CMD_COLUMNS_ARGS);

View file

@ -53,7 +53,7 @@ int CmdConfig::execute (std::string& output)
std::stringstream out;
// Get the non-attribute, non-fancy command line arguments.
std::vector <std::string> words = context.a3t.getWords ();
std::vector <std::string> words = context.parser.getWords ();
// Support:
// task config name value # set name to value

View file

@ -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")

View file

@ -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 ());
}

View file

@ -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 <std::string> words = context.a3t.getWords ();
std::vector <std::string> words = context.parser.getWords ();
if (words.size () == 0)
throw std::string (STRING_CMD_GET_NO_DOM);

View file

@ -54,7 +54,7 @@ int CmdImport::execute (std::string& output)
int count = 0;
// Use the description as a file name.
std::vector <std::string> words = context.a3t.getWords ();
std::vector <std::string> words = context.parser.getWords ();
if (! words.size ())
throw std::string (STRING_CMD_IMPORT_NOFILE);

View file

@ -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 <std::string> words = context.a3t.getWords ();
std::vector <std::string> words = context.parser.getWords ();
if (words.size () > 1)
throw std::string (STRING_CMD_SHOW_ARGS);

View file

@ -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 <std::string> words = context.a3t.getWords ();
std::vector <std::string> words = context.parser.getWords ();
std::vector <std::string>::iterator word;
for (word = words.begin (); word != words.end (); ++word)
{

View file

@ -73,7 +73,7 @@ int CmdTimesheet::execute (std::string& output)
// Determine how many reports to run.
int quantity = 1;
std::vector <std::string> words = context.a3t.getWords ();
std::vector <std::string> words = context.parser.getWords ();
if (words.size () == 1)
quantity = strtol (words[0].c_str (), NULL, 10);;

View file

@ -46,7 +46,7 @@ int CmdUndo::execute (std::string& output)
{
// Detect attempts to modify the task.
std::vector <Tree*>::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);

View file

@ -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 <Tree*>::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");

View file

@ -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");