mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-21 07:43:08 +02:00
E9
- Working towards arg date/duration eval.
This commit is contained in:
parent
e5ae145df2
commit
ffa5bc43fe
9 changed files with 74 additions and 129 deletions
|
@ -830,6 +830,7 @@ const A3 A3::tokenize (const A3& input) const
|
||||||
n.skipWS ();
|
n.skipWS ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
output.dump ("A3::tokenize");
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -863,6 +864,7 @@ const A3 A3::infix (const A3& input) const
|
||||||
previous = *arg;
|
previous = *arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
modified.dump ("A3::infix");
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1036,6 +1038,7 @@ const A3 A3::expand (const A3& input) const
|
||||||
previous = arg;
|
previous = arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expanded.dump ("A3::expand");
|
||||||
return expanded;
|
return expanded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1109,6 +1112,7 @@ const A3 A3::sequence (const A3& input) const
|
||||||
sequenced.push_back (*arg);
|
sequenced.push_back (*arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sequenced.dump ("A3::sequence");
|
||||||
return sequenced;
|
return sequenced;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1207,6 +1211,7 @@ const A3 A3::postfix (const A3& input) const
|
||||||
op_stack.pop_back ();
|
op_stack.pop_back ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
converted.dump ("A3::postfix");
|
||||||
return converted;
|
return converted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,6 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <Nibbler.h>
|
#include <Nibbler.h>
|
||||||
#include <Date.h>
|
|
||||||
#include <Duration.h>
|
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
#include <DOM.h>
|
#include <DOM.h>
|
||||||
|
|
|
@ -57,7 +57,6 @@ static const char* durations[] =
|
||||||
"minutes",
|
"minutes",
|
||||||
"mins",
|
"mins",
|
||||||
"min",
|
"min",
|
||||||
|
|
||||||
"mnths",
|
"mnths",
|
||||||
"monthly",
|
"monthly",
|
||||||
"months",
|
"months",
|
||||||
|
@ -66,7 +65,6 @@ static const char* durations[] =
|
||||||
"mo",
|
"mo",
|
||||||
"mths",
|
"mths",
|
||||||
"m",
|
"m",
|
||||||
|
|
||||||
"quarterly",
|
"quarterly",
|
||||||
"quarters",
|
"quarters",
|
||||||
"qrtrs",
|
"qrtrs",
|
||||||
|
|
160
src/E9.cpp
160
src/E9.cpp
|
@ -27,12 +27,24 @@
|
||||||
|
|
||||||
#include <iostream> // TODO Remove.
|
#include <iostream> // TODO Remove.
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Date.h>
|
||||||
|
#include <Duration.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <A3.h>
|
#include <A3.h>
|
||||||
#include <E9.h>
|
#include <E9.h>
|
||||||
|
|
||||||
extern Context context;
|
extern Context context;
|
||||||
|
|
||||||
|
std::ostream& operator<< (std::ostream& out, const Term& term)
|
||||||
|
{
|
||||||
|
out << term._raw << "/"
|
||||||
|
<< term._value << "/"
|
||||||
|
<< term._type << "/"
|
||||||
|
<< term._category;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Perform all the necessary steps prior to an eval call.
|
// Perform all the necessary steps prior to an eval call.
|
||||||
E9::E9 (const A3& args)
|
E9::E9 (const A3& args)
|
||||||
|
@ -79,6 +91,7 @@ void E9::eval (const Task& task, std::vector <Term>& value_stack)
|
||||||
{
|
{
|
||||||
// Case sensitivity is configurable.
|
// Case sensitivity is configurable.
|
||||||
bool case_sensitive = context.config.getBoolean ("search.case.sensitive");
|
bool case_sensitive = context.config.getBoolean ("search.case.sensitive");
|
||||||
|
std::string dateformat = context.config.get ("dateformat");
|
||||||
|
|
||||||
std::vector <Term>::iterator arg;
|
std::vector <Term>::iterator arg;
|
||||||
for (arg = _terms.begin (); arg != _terms.end (); ++arg)
|
for (arg = _terms.begin (); arg != _terms.end (); ++arg)
|
||||||
|
@ -167,6 +180,15 @@ void E9::eval (const Task& task, std::vector <Term>& value_stack)
|
||||||
// Operand.
|
// Operand.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Expand the value if possible.
|
||||||
|
if (arg->_category == "dom")
|
||||||
|
arg->_value = context.dom.get (arg->_raw, task);
|
||||||
|
else if (arg->_category == "date")
|
||||||
|
arg->_value = Date (arg->_raw, dateformat).toEpochString ();
|
||||||
|
else if (arg->_category == "duration")
|
||||||
|
arg->_value = (std::string)Duration (arg->_raw);
|
||||||
|
|
||||||
|
//std::cout << "# E9::eval operand " << *arg << "\n";
|
||||||
value_stack.push_back (*arg);
|
value_stack.push_back (*arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,12 +228,9 @@ bool E9::eval_match (Term& left, Term& right, bool case_sensitive)
|
||||||
void E9::operator_not (Term& result, Term& right)
|
void E9::operator_not (Term& result, Term& right)
|
||||||
{
|
{
|
||||||
// TODO This is not right.
|
// TODO This is not right.
|
||||||
result = Term (right._raw, coerce (right, "bool")._value, "bool");
|
result = Term (right._raw, coerce (right, "bool")._value, "bool", right._category);
|
||||||
|
|
||||||
std::cout << "# not " << right._raw << "/" << right._value << "/" << right._category
|
// std::cout << "# not " << right << " --> " << result << "\n";
|
||||||
<< " --> "
|
|
||||||
<< result._raw << "/" << result._value << "/" << result._category
|
|
||||||
<< "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -228,14 +247,7 @@ void E9::operator_and (Term& result, Term& left, Term& right)
|
||||||
result._category = "bool";
|
result._category = "bool";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// std::cout << "# " << left << " and " << right << " --> " << result << "\n";
|
||||||
std::cout << "# " << left._raw << "/" << left._value << "/" << left._category
|
|
||||||
<< " and "
|
|
||||||
<< right._raw << "/" << right._value << "/" << right._category
|
|
||||||
<< " --> "
|
|
||||||
<< result._raw << "/" << result._value << "/" << result._category
|
|
||||||
<< "\n";
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -252,14 +264,7 @@ void E9::operator_or (Term& result, Term& left, Term& right)
|
||||||
result._category = "bool";
|
result._category = "bool";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// std::cout << "# " << left << " or " << right << " --> " << result << "\n";
|
||||||
std::cout << "# " << left._raw << "/" << left._value << "/" << left._category
|
|
||||||
<< " or "
|
|
||||||
<< right._raw << "/" << right._value << "/" << right._category
|
|
||||||
<< " --> "
|
|
||||||
<< result._raw << "/" << result._value << "/" << result._category
|
|
||||||
<< "\n";
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -279,14 +284,7 @@ void E9::operator_xor (Term& result, Term& left, Term& right)
|
||||||
result._category = "bool";
|
result._category = "bool";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// std::cout << "# " << left << " xor " << right << " --> " << result << "\n";
|
||||||
std::cout << "# " << left._raw << "/" << left._value << "/" << left._category
|
|
||||||
<< " xor "
|
|
||||||
<< right._raw << "/" << right._value << "/" << right._category
|
|
||||||
<< " --> "
|
|
||||||
<< result._raw << "/" << result._value << "/" << result._category
|
|
||||||
<< "\n";
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -309,14 +307,7 @@ void E9::operator_lt (Term& result, Term& left, Term& right)
|
||||||
|
|
||||||
result._category = "bool";
|
result._category = "bool";
|
||||||
|
|
||||||
/*
|
// std::cout << "# " << left << " < " << right << " --> " << result << "\n";
|
||||||
std::cout << "# " << left._raw << "/" << left._value << "/" << left._category
|
|
||||||
<< " < "
|
|
||||||
<< right._raw << "/" << right._value << "/" << right._category
|
|
||||||
<< " --> "
|
|
||||||
<< result._raw << "/" << result._value << "/" << result._category
|
|
||||||
<< "\n";
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -340,14 +331,7 @@ void E9::operator_lte (Term& result, Term& left, Term& right)
|
||||||
|
|
||||||
result._category = "bool";
|
result._category = "bool";
|
||||||
|
|
||||||
/*
|
// std::cout << "# " << left << " <= " << right << " --> " << result << "\n";
|
||||||
std::cout << "# " << left._raw << "/" << left._value << "/" << left._category
|
|
||||||
<< " <= "
|
|
||||||
<< right._raw << "/" << right._value << "/" << right._category
|
|
||||||
<< " --> "
|
|
||||||
<< result._raw << "/" << result._value << "/" << result._category
|
|
||||||
<< "\n";
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -371,14 +355,7 @@ void E9::operator_gte (Term& result, Term& left, Term& right)
|
||||||
|
|
||||||
result._category = "bool";
|
result._category = "bool";
|
||||||
|
|
||||||
/*
|
// std::cout << "# " << left << " >= " << right << " --> " << result << "\n";
|
||||||
std::cout << "# " << left._raw << "/" << left._value << "/" << left._category
|
|
||||||
<< " >= "
|
|
||||||
<< right._raw << "/" << right._value << "/" << right._category
|
|
||||||
<< " --> "
|
|
||||||
<< result._raw << "/" << result._value << "/" << result._category
|
|
||||||
<< "\n";
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -401,14 +378,7 @@ void E9::operator_gt (Term& result, Term& left, Term& right)
|
||||||
|
|
||||||
result._category = "bool";
|
result._category = "bool";
|
||||||
|
|
||||||
/*
|
// std::cout << "# " << left << " > " << right << " --> " << result << "\n";
|
||||||
std::cout << "# " << left._raw << "/" << left._value << "/" << left._category
|
|
||||||
<< " > "
|
|
||||||
<< right._raw << "/" << right._value << "/" << right._category
|
|
||||||
<< " --> "
|
|
||||||
<< result._raw << "/" << result._value << "/" << result._category
|
|
||||||
<< "\n";
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -424,14 +394,7 @@ void E9::operator_inequal (
|
||||||
else
|
else
|
||||||
result._raw = result._value = "false";
|
result._raw = result._value = "false";
|
||||||
|
|
||||||
/*
|
// std::cout << "# " << left << " != " << right << " --> " << result << "\n";
|
||||||
std::cout << "# " << left._raw << "/" << left._value << "/" << left._category
|
|
||||||
<< " != "
|
|
||||||
<< right._raw << "/" << right._value << "/" << right._category
|
|
||||||
<< " --> "
|
|
||||||
<< result._raw << "/" << result._value << "/" << result._category
|
|
||||||
<< "\n";
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -478,14 +441,7 @@ void E9::operator_equal (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// std::cout << "# " << left << " = " << right << " --> " << result << "\n";
|
||||||
std::cout << "# " << left._raw << "/" << left._value << "/" << left._category
|
|
||||||
<< " = "
|
|
||||||
<< right._raw << "/" << right._value << "/" << right._category
|
|
||||||
<< " --> "
|
|
||||||
<< result._raw << "/" << result._value << "/" << result._category
|
|
||||||
<< "\n";
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -502,14 +458,7 @@ void E9::operator_match (
|
||||||
else
|
else
|
||||||
result._raw = result._value = "false";
|
result._raw = result._value = "false";
|
||||||
|
|
||||||
/*
|
// std::cout << "# " << left << " ~ " << right << " --> " << result << "\n";
|
||||||
std::cout << "# " << left._raw << "/" << left._value << "/" << left._category
|
|
||||||
<< " ~ "
|
|
||||||
<< right._raw << "/" << right._value << "/" << right._category
|
|
||||||
<< " --> "
|
|
||||||
<< result._raw << "/" << result._value << "/" << result._category
|
|
||||||
<< "\n";
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -536,62 +485,31 @@ void E9::operator_nomatch (
|
||||||
else
|
else
|
||||||
result._raw = result._value = "false";
|
result._raw = result._value = "false";
|
||||||
|
|
||||||
/*
|
// std::cout << "# " << left << " !~ " << right << " --> " << result << "\n";
|
||||||
std::cout << "# " << left._raw << "/" << left._value << "/" << left._category
|
|
||||||
<< " !~ "
|
|
||||||
<< right._raw << "/" << right._value << "/" << right._category
|
|
||||||
<< " --> "
|
|
||||||
<< result._raw << "/" << result._value << "/" << result._category
|
|
||||||
<< "\n";
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void E9::operator_multiply (Term& result, Term& left, Term& right)
|
void E9::operator_multiply (Term& result, Term& left, Term& right)
|
||||||
{
|
{
|
||||||
|
std::cout << "# " << left << " * " << right << " --> " << result << "\n";
|
||||||
std::cout << "# " << left._raw << "/" << left._value << "/" << left._category
|
|
||||||
<< " * "
|
|
||||||
<< right._raw << "/" << right._value << "/" << right._category
|
|
||||||
<< " --> "
|
|
||||||
<< result._raw << "/" << result._value << "/" << result._category
|
|
||||||
<< "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void E9::operator_divide (Term& result, Term& left, Term& right)
|
void E9::operator_divide (Term& result, Term& left, Term& right)
|
||||||
{
|
{
|
||||||
|
std::cout << "# " << left << " / " << right << " --> " << result << "\n";
|
||||||
std::cout << "# " << left._raw << "/" << left._value << "/" << left._category
|
|
||||||
<< " / "
|
|
||||||
<< right._raw << "/" << right._value << "/" << right._category
|
|
||||||
<< " --> "
|
|
||||||
<< result._raw << "/" << result._value << "/" << result._category
|
|
||||||
<< "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void E9::operator_add (Term& result, Term& left, Term& right)
|
void E9::operator_add (Term& result, Term& left, Term& right)
|
||||||
{
|
{
|
||||||
|
std::cout << "# " << left << " + " << right << " --> " << result << "\n";
|
||||||
std::cout << "# " << left._raw << "/" << left._value << "/" << left._category
|
|
||||||
<< " + "
|
|
||||||
<< right._raw << "/" << right._value << "/" << right._category
|
|
||||||
<< " --> "
|
|
||||||
<< result._raw << "/" << result._value << "/" << result._category
|
|
||||||
<< "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void E9::operator_subtract (Term& result, Term& left, Term& right)
|
void E9::operator_subtract (Term& result, Term& left, Term& right)
|
||||||
{
|
{
|
||||||
|
std::cout << "# " << left << " - " << right << " --> " << result << "\n";
|
||||||
std::cout << "# " << left._raw << "/" << left._value << "/" << left._category
|
|
||||||
<< " - "
|
|
||||||
<< right._raw << "/" << right._value << "/" << right._category
|
|
||||||
<< " --> "
|
|
||||||
<< result._raw << "/" << result._value << "/" << result._category
|
|
||||||
<< "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
8
src/E9.h
8
src/E9.h
|
@ -39,6 +39,7 @@ public:
|
||||||
Term ()
|
Term ()
|
||||||
: _raw ("")
|
: _raw ("")
|
||||||
, _value ("")
|
, _value ("")
|
||||||
|
, _type ("")
|
||||||
, _category ("")
|
, _category ("")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -46,6 +47,7 @@ public:
|
||||||
Term (const Arg& arg)
|
Term (const Arg& arg)
|
||||||
: _raw (arg._raw)
|
: _raw (arg._raw)
|
||||||
, _value (arg._raw)
|
, _value (arg._raw)
|
||||||
|
, _type ("string")
|
||||||
, _category (arg._category)
|
, _category (arg._category)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -53,9 +55,11 @@ public:
|
||||||
Term (
|
Term (
|
||||||
const std::string& raw,
|
const std::string& raw,
|
||||||
const std::string& value,
|
const std::string& value,
|
||||||
|
const std::string& type,
|
||||||
const std::string& category)
|
const std::string& category)
|
||||||
: _raw (raw)
|
: _raw (raw)
|
||||||
, _value (value)
|
, _value (value)
|
||||||
|
, _type (type)
|
||||||
, _category (category)
|
, _category (category)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -64,6 +68,7 @@ public:
|
||||||
{
|
{
|
||||||
_raw = other._raw;
|
_raw = other._raw;
|
||||||
_value = other._value;
|
_value = other._value;
|
||||||
|
_type = other._type;
|
||||||
_category = other._category;
|
_category = other._category;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +78,7 @@ public:
|
||||||
{
|
{
|
||||||
_raw = other._raw;
|
_raw = other._raw;
|
||||||
_value = other._value;
|
_value = other._value;
|
||||||
|
_type = other._type;
|
||||||
_category = other._category;
|
_category = other._category;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,12 +89,14 @@ public:
|
||||||
{
|
{
|
||||||
return _raw == other._raw &&
|
return _raw == other._raw &&
|
||||||
_value == other._value &&
|
_value == other._value &&
|
||||||
|
_type == other._type &&
|
||||||
_category == other._category;
|
_category == other._category;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::string _raw; // Raw input token, never modified
|
std::string _raw; // Raw input token, never modified
|
||||||
std::string _value; // Evaluated raw token, sometimes identical
|
std::string _value; // Evaluated raw token, sometimes identical
|
||||||
|
std::string _type; // Inferred type
|
||||||
std::string _category; // Categorized argument
|
std::string _category; // Categorized argument
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <iostream> // TODO Remove.
|
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <TDB2.h>
|
#include <TDB2.h>
|
||||||
|
@ -281,6 +280,11 @@ void TF2::load_lines ()
|
||||||
|
|
||||||
split (_lines, _contents, '\n');
|
split (_lines, _contents, '\n');
|
||||||
_loaded_lines = true;
|
_loaded_lines = true;
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (_lines.back () == "")
|
||||||
|
_lines.pop_back ();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -409,13 +409,19 @@ void Command::modify_task (
|
||||||
A3::extract_attr (arg->_raw, name, value);
|
A3::extract_attr (arg->_raw, name, value);
|
||||||
if (A3::is_attribute (name, name)) // Canonicalize
|
if (A3::is_attribute (name, name)) // Canonicalize
|
||||||
{
|
{
|
||||||
|
std::cout << "# Command::modify_task name='" << name << "' value='" << value << "'\n";
|
||||||
|
|
||||||
// All values must be eval'd first.
|
// All values must be eval'd first.
|
||||||
A3 fragment;
|
A3 fragment;
|
||||||
fragment.push_back (Arg (value, "attr"));
|
fragment.capture (value);
|
||||||
|
fragment = fragment.tokenize (fragment);
|
||||||
E9 e (fragment);
|
E9 e (fragment);
|
||||||
std::string result = e.evalExpression (task);
|
std::string result = e.evalExpression (task);
|
||||||
context.debug (std::string ("Eval '") + value + "' --> '" + result + "'");
|
context.debug (std::string ("Eval '") + value + "' --> '" + result + "'");
|
||||||
|
|
||||||
|
fragment.dump ("pre modify_task attr");
|
||||||
|
std::cout << "# modify_task result='" << result << "'\n";
|
||||||
|
|
||||||
// Dependencies must be resolved to UUIDs.
|
// Dependencies must be resolved to UUIDs.
|
||||||
if (name == "depends")
|
if (name == "depends")
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,7 +48,7 @@ int convertDuration (const std::string& input)
|
||||||
|
|
||||||
int main (int argc, char** argv)
|
int main (int argc, char** argv)
|
||||||
{
|
{
|
||||||
UnitTest t (628);
|
UnitTest t (629);
|
||||||
|
|
||||||
Duration d;
|
Duration d;
|
||||||
|
|
||||||
|
@ -570,6 +570,7 @@ int main (int argc, char** argv)
|
||||||
t.ok (d.valid ("0w"), "valid duration 0w");
|
t.ok (d.valid ("0w"), "valid duration 0w");
|
||||||
t.ok (d.valid ("1 wks"), "valid duration 1 wks");
|
t.ok (d.valid ("1 wks"), "valid duration 1 wks");
|
||||||
t.ok (d.valid ("1 wk"), "valid duration 1 wk");
|
t.ok (d.valid ("1 wk"), "valid duration 1 wk");
|
||||||
|
t.ok (d.valid ("1wk"), "valid duration 1wk");
|
||||||
t.ok (d.valid ("1w"), "valid duration 1w");
|
t.ok (d.valid ("1w"), "valid duration 1w");
|
||||||
t.ok (d.valid ("10 wks"), "valid duration 10 wks");
|
t.ok (d.valid ("10 wks"), "valid duration 10 wks");
|
||||||
t.ok (d.valid ("10 wk"), "valid duration 10 wk");
|
t.ok (d.valid ("10 wk"), "valid duration 10 wk");
|
||||||
|
|
|
@ -35,7 +35,7 @@ Context context;
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int main (int argc, char** argv)
|
int main (int argc, char** argv)
|
||||||
{
|
{
|
||||||
UnitTest t (258);
|
UnitTest t (262);
|
||||||
|
|
||||||
// void wrapText (std::vector <std::string>& lines, const std::string& text, const int width)
|
// void wrapText (std::vector <std::string>& lines, const std::string& text, const int width)
|
||||||
std::string text = "This is a test of the line wrapping code.";
|
std::string text = "This is a test of the line wrapping code.";
|
||||||
|
@ -155,6 +155,13 @@ int main (int argc, char** argv)
|
||||||
t.is (items[2], "bc", "split '-a-bc-def' '--' -> [2] 'bc'");
|
t.is (items[2], "bc", "split '-a-bc-def' '--' -> [2] 'bc'");
|
||||||
t.is (items[3], "def", "split '-a-bc-def' '--' -> [3] 'def'");
|
t.is (items[3], "def", "split '-a-bc-def' '--' -> [3] 'def'");
|
||||||
|
|
||||||
|
unsplit = "one\ntwo\nthree";
|
||||||
|
split (items, unsplit, "\n");
|
||||||
|
t.is (items.size (), (size_t) 3, "split 'one\\ntwo\\nthree' -> 'one', 'two', 'three'");
|
||||||
|
t.is (items[0], "one", "split 'one\\ntwo\\nthree' -> [0] 'one'");
|
||||||
|
t.is (items[1], "two", "split 'one\\ntwo\\nthree' -> [1] 'two'");
|
||||||
|
t.is (items[2], "three", "split 'one\\ntwo\\nthree' -> [2] 'three'");
|
||||||
|
|
||||||
// void splitq (std::vector<std::string>&, const std::string&, const char);
|
// void splitq (std::vector<std::string>&, const std::string&, const char);
|
||||||
unsplit = "one 'two' '' 'three four' \"five six seven\" eight'nine ten'";
|
unsplit = "one 'two' '' 'three four' \"five six seven\" eight'nine ten'";
|
||||||
splitq (items, unsplit, ' ');
|
splitq (items, unsplit, ' ');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue