Expressions reboot

- Created A3.{h,cpp} which will be a simpler, lightweight version of
  Arguments.{h,cpp} that does less, but does it better.
- Created E9.{h,cpp} which will be a better implementation of
  Expression.{h,cpp} that does less, but does it better.
- Integrated A3 into Context::initialize, and Arguments and A3 will
  coexist until A3 surpasses Arguments.
This commit is contained in:
Paul Beckingham
2011-07-23 13:38:33 -04:00
parent 1164ea5cf1
commit 5b5978952a
8 changed files with 2839 additions and 14 deletions

73
src/E9.h Normal file
View File

@@ -0,0 +1,73 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez.
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 of the License, or (at your option) any later
// version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details.
//
// You should have received a copy of the GNU General Public License along with
// this program; if not, write to the
//
// Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor,
// Boston, MA
// 02110-1301
// USA
//
////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_E9
#define INCLUDED_E9
#define L10N // Localization complete.
#include <string>
#include <stack>
#include <Arguments.h>
#include <Task.h>
#include <RX.h>
#include <Variant.h>
class E9
{
public:
E9 (Arguments&);
~E9 ();
bool eval (const Task&);
bool evalFilter (const Task&);
std::string evalE9 (const Task&);
void eval (const Task&, std::vector <Variant>&);
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;
std::map <std::string, RX> _regexes;
bool _prepared;
};
#endif
////////////////////////////////////////////////////////////////////////////////