mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Expression reboot
- A3 now tracks whether a command is read-only, and builds filters accordingly. - Implemented extract_filter, extract_modfications and extract_words stubs. - Removed all E9 implementation details - this is going to be written from scratch.
This commit is contained in:
parent
c344c07579
commit
91225d808f
6 changed files with 109 additions and 1076 deletions
82
src/A3.cpp
82
src/A3.cpp
|
@ -31,8 +31,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <sys/select.h>
|
||||
#include <Context.h>
|
||||
//#include <Nibbler.h>
|
||||
//#include <Lexer.h>
|
||||
#include <Directory.h>
|
||||
#include <ViewText.h>
|
||||
#include <text.h>
|
||||
|
@ -105,6 +103,7 @@ static struct
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
A3::A3 ()
|
||||
: _read_only_command (true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -200,6 +199,7 @@ void A3::categorize ()
|
|||
{
|
||||
found_command = true;
|
||||
arg->_category = "command";
|
||||
_read_only_command = context.commands[arg->_raw]->read_only ();
|
||||
}
|
||||
|
||||
// rc:<file>
|
||||
|
@ -522,6 +522,71 @@ const std::string A3::find_limit () const
|
|||
return "";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const A3 A3::extract_filter () const
|
||||
{
|
||||
A3 filter;
|
||||
bool before_command = true;
|
||||
std::vector <Arg>::const_iterator arg;
|
||||
for (arg = this->begin (); arg != this->end (); ++arg)
|
||||
{
|
||||
if (arg->_category == "command")
|
||||
before_command = false;
|
||||
|
||||
if (arg->_category == "program" ||
|
||||
arg->_category == "rc" ||
|
||||
arg->_category == "override" ||
|
||||
arg->_category == "command" ||
|
||||
arg->_category == "terminator")
|
||||
;
|
||||
|
||||
else if (before_command || _read_only_command)
|
||||
filter.push_back (*arg);
|
||||
}
|
||||
|
||||
return filter;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const A3 A3::extract_modifications () const
|
||||
{
|
||||
A3 mods;
|
||||
bool before_command = true;
|
||||
std::vector <Arg>::const_iterator arg;
|
||||
for (arg = this->begin (); arg != this->end (); ++arg)
|
||||
{
|
||||
if (arg->_category == "command")
|
||||
before_command = false;
|
||||
|
||||
else if (! before_command)
|
||||
mods.push_back (*arg);
|
||||
}
|
||||
|
||||
return mods;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const A3 A3::extract_words () const
|
||||
{
|
||||
A3 words;
|
||||
std::vector <Arg>::const_iterator arg;
|
||||
for (arg = this->begin (); arg != this->end (); ++arg)
|
||||
{
|
||||
if (arg->_category == "program" ||
|
||||
arg->_category == "rc" ||
|
||||
arg->_category == "override" ||
|
||||
arg->_category == "command" ||
|
||||
arg->_category == "terminator")
|
||||
;
|
||||
|
||||
else
|
||||
words.push_back (*arg);
|
||||
}
|
||||
|
||||
return words;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -547,17 +612,6 @@ std::vector <std::string> A3::operator_list ()
|
|||
return all;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string A3::find_limit ()
|
||||
{
|
||||
std::vector <Arg>::reverse_iterator arg;
|
||||
for (arg = this->rbegin (); arg != this->rend (); ++arg)
|
||||
if (arg->_first.find ("limit:") != std::string::npos)
|
||||
return arg->_first.substr (6);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool A3::is_multipart (
|
||||
const std::string& input,
|
||||
|
@ -1461,7 +1515,7 @@ void A3::dump (const std::string& label)
|
|||
color_map["rc"] = Color ("bold red on red");
|
||||
color_map["override"] = Color ("bold red on red");
|
||||
color_map["terminator"] = Color ("bold yellow on yellow");
|
||||
color_map["word"] = Color ("black on white");
|
||||
color_map["word"] = Color ("white on gray4");
|
||||
color_map["none"] = Color ("black on white");
|
||||
|
||||
/*
|
||||
|
|
7
src/A3.h
7
src/A3.h
|
@ -98,6 +98,10 @@ public:
|
|||
bool find_command (std::string&) const;
|
||||
const std::string find_limit () const;
|
||||
|
||||
const A3 extract_filter () const;
|
||||
const A3 extract_modifications () const;
|
||||
const A3 extract_words () const;
|
||||
|
||||
/*
|
||||
static std::vector <std::string> operator_list ();
|
||||
|
||||
|
@ -134,6 +138,9 @@ public:
|
|||
static bool valid_modifier (const std::string&);
|
||||
*/
|
||||
void dump (const std::string&);
|
||||
|
||||
private:
|
||||
bool _read_only_command;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
1039
src/E9.cpp
1039
src/E9.cpp
File diff suppressed because it is too large
Load diff
32
src/E9.h
32
src/E9.h
|
@ -29,44 +29,22 @@
|
|||
#define L10N // Localization complete.
|
||||
|
||||
#include <string>
|
||||
#include <stack>
|
||||
#include <Arguments.h>
|
||||
#include <A3.h>
|
||||
#include <Task.h>
|
||||
#include <RX.h>
|
||||
#include <Variant.h>
|
||||
|
||||
class E9
|
||||
{
|
||||
public:
|
||||
E9 (Arguments&);
|
||||
E9 (A3&);
|
||||
~E9 ();
|
||||
bool eval (const Task&);
|
||||
|
||||
bool evalFilter (const Task&);
|
||||
std::string evalE9 (const Task&);
|
||||
void eval (const Task&, std::vector <Variant>&);
|
||||
std::string evalExpression (const Task&);
|
||||
|
||||
private:
|
||||
void expand_sequence ();
|
||||
void implicit_and ();
|
||||
void expand_tag ();
|
||||
void expand_pattern ();
|
||||
void expand_attr ();
|
||||
void expand_attmod ();
|
||||
void expand_word ();
|
||||
void expand_tokens ();
|
||||
void postfix ();
|
||||
|
||||
void tokenize (const std::string&, const std::string&, std::vector <std::string>&, Arguments&);
|
||||
void create_variant (Variant&, const std::string&, const std::string&);
|
||||
bool is_new_style ();
|
||||
|
||||
private:
|
||||
bool eval_match (Variant&, Variant&, bool);
|
||||
|
||||
private:
|
||||
Arguments _args;
|
||||
A3 _args;
|
||||
std::map <std::string, RX> _regexes;
|
||||
bool _prepared;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -91,6 +91,9 @@ int CmdCustom::execute (std::string& output)
|
|||
context.a3.capture_first (*arg);
|
||||
}
|
||||
|
||||
context.a3.categorize ();
|
||||
context.a3.dump ("CmdCustom::execute");
|
||||
|
||||
// Load the data.
|
||||
// TODO Replace with TDB2.
|
||||
std::vector <Task> tasks;
|
||||
|
|
|
@ -268,6 +268,17 @@ void Command::filter (std::vector <Task>& input, std::vector <Task>& output)
|
|||
{
|
||||
Timer timer ("Command::filter");
|
||||
|
||||
/**/
|
||||
A3 filt = context.a3.extract_filter ();
|
||||
filt.dump ("extract_filter");
|
||||
|
||||
A3 mods = context.a3.extract_modifications ();
|
||||
mods.dump ("extract_modifications");
|
||||
|
||||
A3 words = context.a3.extract_words ();
|
||||
words.dump ("extract_words");
|
||||
/**/
|
||||
|
||||
Arguments f;
|
||||
if (read_only ())
|
||||
f = context.args.extract_read_only_filter ();
|
||||
|
@ -293,6 +304,17 @@ void Command::filter (std::vector <Task>& output)
|
|||
{
|
||||
Timer timer ("Command::filter");
|
||||
|
||||
/**/
|
||||
A3 filt = context.a3.extract_filter ();
|
||||
filt.dump ("extract_filter");
|
||||
|
||||
A3 mods = context.a3.extract_modifications ();
|
||||
mods.dump ("extract_modifications");
|
||||
|
||||
A3 words = context.a3.extract_words ();
|
||||
words.dump ("extract_words");
|
||||
/**/
|
||||
|
||||
Arguments f;
|
||||
if (read_only ())
|
||||
f = context.args.extract_read_only_filter ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue