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