mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Expression Refactor
- E9 now uses Arg object in place of Term. This means A3 and E9 are now using a common object.
This commit is contained in:
parent
816b07e868
commit
516e368df0
4 changed files with 163 additions and 241 deletions
109
src/E9.h
109
src/E9.h
|
@ -33,73 +33,6 @@
|
|||
#include <Task.h>
|
||||
#include <RX.h>
|
||||
|
||||
class Term
|
||||
{
|
||||
public:
|
||||
Term ()
|
||||
: _raw ("")
|
||||
, _value ("")
|
||||
, _type ("")
|
||||
, _category ("")
|
||||
{
|
||||
}
|
||||
|
||||
Term (const Arg& arg)
|
||||
: _raw (arg._raw)
|
||||
, _value (arg._raw)
|
||||
, _type ("string")
|
||||
, _category (arg._category)
|
||||
{
|
||||
}
|
||||
|
||||
Term (
|
||||
const std::string& raw,
|
||||
const std::string& value,
|
||||
const std::string& type,
|
||||
const std::string& category)
|
||||
: _raw (raw)
|
||||
, _value (value)
|
||||
, _type (type)
|
||||
, _category (category)
|
||||
{
|
||||
}
|
||||
|
||||
Term (const Term& other)
|
||||
{
|
||||
_raw = other._raw;
|
||||
_value = other._value;
|
||||
_type = other._type;
|
||||
_category = other._category;
|
||||
}
|
||||
|
||||
Term& operator= (const Term& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
_raw = other._raw;
|
||||
_value = other._value;
|
||||
_type = other._type;
|
||||
_category = other._category;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator== (const Term& other) const
|
||||
{
|
||||
return _raw == other._raw &&
|
||||
_value == other._value &&
|
||||
_type == other._type &&
|
||||
_category == other._category;
|
||||
}
|
||||
|
||||
public:
|
||||
std::string _raw; // Raw input token, never modified
|
||||
std::string _value; // Evaluated raw token, sometimes identical
|
||||
std::string _type; // Inferred type
|
||||
std::string _category; // Categorized argument
|
||||
};
|
||||
|
||||
class E9
|
||||
{
|
||||
public:
|
||||
|
@ -110,34 +43,34 @@ public:
|
|||
std::string evalExpression (const Task&);
|
||||
|
||||
private:
|
||||
void eval (const Task&, std::vector <Term>&);
|
||||
bool eval_match (Term&, Term&, bool);
|
||||
void eval (const Task&, std::vector <Arg>&);
|
||||
bool eval_match (Arg&, Arg&, bool);
|
||||
|
||||
// Unary.
|
||||
void operator_not (Term&, Term&);
|
||||
void operator_not (Arg&, Arg&);
|
||||
|
||||
// Binary.
|
||||
void operator_and (Term&, Term&, Term&);
|
||||
void operator_or (Term&, Term&, Term&);
|
||||
void operator_xor (Term&, Term&, Term&);
|
||||
void operator_lt (Term&, Term&, Term&);
|
||||
void operator_lte (Term&, Term&, Term&);
|
||||
void operator_gte (Term&, Term&, Term&);
|
||||
void operator_gt (Term&, Term&, Term&);
|
||||
void operator_inequal (Term&, Term&, Term&, bool);
|
||||
void operator_equal (Term&, Term&, Term&, bool);
|
||||
void operator_match (Term&, Term&, Term&, bool);
|
||||
void operator_nomatch (Term&, Term&, Term&, bool);
|
||||
void operator_multiply (Term&, Term&, Term&);
|
||||
void operator_divide (Term&, Term&, Term&);
|
||||
void operator_add (Term&, Term&, Term&);
|
||||
void operator_subtract (Term&, Term&, Term&);
|
||||
void operator_and (Arg&, Arg&, Arg&);
|
||||
void operator_or (Arg&, Arg&, Arg&);
|
||||
void operator_xor (Arg&, Arg&, Arg&);
|
||||
void operator_lt (Arg&, Arg&, Arg&);
|
||||
void operator_lte (Arg&, Arg&, Arg&);
|
||||
void operator_gte (Arg&, Arg&, Arg&);
|
||||
void operator_gt (Arg&, Arg&, Arg&);
|
||||
void operator_inequal (Arg&, Arg&, Arg&, bool);
|
||||
void operator_equal (Arg&, Arg&, Arg&, bool);
|
||||
void operator_match (Arg&, Arg&, Arg&, bool);
|
||||
void operator_nomatch (Arg&, Arg&, Arg&, bool);
|
||||
void operator_multiply (Arg&, Arg&, Arg&);
|
||||
void operator_divide (Arg&, Arg&, Arg&);
|
||||
void operator_add (Arg&, Arg&, Arg&);
|
||||
void operator_subtract (Arg&, Arg&, Arg&);
|
||||
|
||||
const Term coerce (const Term&, const std::string&);
|
||||
bool get_bool (const Term&);
|
||||
const Arg coerce (const Arg&, const std::string&);
|
||||
bool get_bool (const Arg&);
|
||||
|
||||
private:
|
||||
std::vector <Term> _terms;
|
||||
std::vector <Arg> _terms;
|
||||
std::map <std::string, RX> _regexes;
|
||||
std::string _dateformat;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue