mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Code Cleanup
- Eliminated obsolete Lisp code.
This commit is contained in:
parent
f1525df48a
commit
4245d83812
5 changed files with 8 additions and 253 deletions
|
@ -5,13 +5,13 @@ set (task_SRCS API.cpp API.h Att.cpp Att.h Cmd.cpp Cmd.h Color.cpp Color.h
|
|||
Config.cpp Config.h Context.cpp Context.h Date.cpp Date.h
|
||||
Directory.cpp Directory.h Duration.cpp Duration.h File.cpp
|
||||
File.h Filter.cpp Filter.h feedback.cpp Grid.cpp Grid.h Hooks.cpp
|
||||
Hooks.h JSON.cpp JSON.h Keymap.cpp Keymap.h Lisp.cpp Lisp.h
|
||||
Location.cpp Location.h Nibbler.cpp Nibbler.h Path.cpp Path.h
|
||||
Permission.cpp Permission.h Record.cpp Record.h Rectangle.cpp
|
||||
Rectangle.h Sequence.cpp Sequence.h Subst.cpp Subst.h TDB.cpp
|
||||
TDB.h Table.cpp Table.h Task.cpp Task.h Taskmod.cpp Taskmod.h
|
||||
Thread.cpp Thread.h Timer.cpp Timer.h Transport.cpp Transport.h
|
||||
TransportSSH.cpp TransportSSH.h TransportRSYNC.cpp TransportRSYNC.h
|
||||
Hooks.h JSON.cpp JSON.h Keymap.cpp Keymap.h Location.cpp
|
||||
Location.h Nibbler.cpp Nibbler.h Path.cpp Path.h Permission.cpp
|
||||
Permission.h Record.cpp Record.h Rectangle.cpp Rectangle.h
|
||||
Sequence.cpp Sequence.h Subst.cpp Subst.h TDB.cpp TDB.h Table.cpp
|
||||
Table.h Task.cpp Task.h Taskmod.cpp Taskmod.h Thread.cpp Thread.h
|
||||
Timer.cpp Timer.h Transport.cpp Transport.h TransportSSH.cpp
|
||||
TransportSSH.h TransportRSYNC.cpp TransportRSYNC.h
|
||||
TransportCurl.cpp TransportCurl.h Tree.cpp Tree.h burndown.cpp
|
||||
command.cpp custom.cpp dependency.cpp diag.cpp edit.cpp
|
||||
export.cpp history.cpp i18n.h import.cpp interactive.cpp
|
||||
|
|
125
src/Lisp.cpp
125
src/Lisp.cpp
|
@ -1,125 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include "Lisp.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Lisp::Lisp ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Lisp::~Lisp ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Tree* Lisp::parse (const std::string& input)
|
||||
{
|
||||
Tree* root = new Tree ("root");
|
||||
if (root)
|
||||
{
|
||||
Nibbler n (input);
|
||||
parseNode (root, n);
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Grammar
|
||||
// node ::= '(' list ')'
|
||||
// list ::= item [[space item] ...]
|
||||
// item ::= word | node
|
||||
void Lisp::parseNode (Tree* parent, Nibbler& n)
|
||||
{
|
||||
// Work on a stack-based copy, to allow backtracking.
|
||||
Nibbler attempt (n);
|
||||
|
||||
if (attempt.skip ('('))
|
||||
{
|
||||
Tree* b = new Tree ("");
|
||||
parent->addBranch (b);
|
||||
|
||||
parseList (b, attempt);
|
||||
if (attempt.skip (')'))
|
||||
{
|
||||
n = attempt;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw std::string ("Error: malformed node");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Lisp::parseList (Tree* parent, Nibbler& n)
|
||||
{
|
||||
// Work on a stack-based copy, to allow backtracking.
|
||||
Nibbler attempt (n);
|
||||
|
||||
parseItem (parent, attempt);
|
||||
|
||||
while (attempt.skip (' '))
|
||||
parseItem (parent, attempt);
|
||||
|
||||
n = attempt;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Lisp::parseItem (Tree* parent, Nibbler& n)
|
||||
{
|
||||
// Work on a stack-based copy, to allow backtracking.
|
||||
Nibbler attempt (n);
|
||||
|
||||
if (attempt.next () == '(')
|
||||
parseNode (parent, attempt);
|
||||
else
|
||||
parseWord (parent, attempt);
|
||||
|
||||
n = attempt;
|
||||
return;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// A word is any group of non-whitespace followed by a space or ')'.
|
||||
void Lisp::parseWord (Tree* parent, Nibbler& n)
|
||||
{
|
||||
// Work on a stack-based copy, to allow backtracking.
|
||||
Nibbler attempt (n);
|
||||
|
||||
std::string word;
|
||||
if (attempt.getUntilOneOf (" )", word))
|
||||
{
|
||||
parent->tag (word);
|
||||
n = attempt;
|
||||
return;
|
||||
}
|
||||
|
||||
throw std::string ("Error: failed to parse word");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
54
src/Lisp.h
54
src/Lisp.h
|
@ -1,54 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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_LISP
|
||||
#define INCLUDED_LISP
|
||||
|
||||
#include <string>
|
||||
#include "Tree.h"
|
||||
#include "Nibbler.h"
|
||||
|
||||
class Lisp
|
||||
{
|
||||
public:
|
||||
Lisp ();
|
||||
Lisp (const Lisp&);
|
||||
Lisp& operator= (const Lisp&);
|
||||
~Lisp ();
|
||||
|
||||
Tree* parse (const std::string&);
|
||||
|
||||
private:
|
||||
void parseNode (Tree*, Nibbler&);
|
||||
void parseList (Tree*, Nibbler&);
|
||||
void parseItem (Tree*, Nibbler&);
|
||||
void parseWord (Tree*, Nibbler&);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -6,8 +6,7 @@ include_directories (${CMAKE_SOURCE_DIR}/src
|
|||
set (test_SRCS date.t t.t tdb.t duration.t t.benchmark.t text.t autocomplete.t
|
||||
seq.t record.t att.t subst.t nibbler.t filt.t cmd.t config.t
|
||||
util.t color.t list.t path.t file.t grid.t directory.t rx.t
|
||||
taskmod.t lisp.t rectangle.t tree.t tree2.t uri.t json.t
|
||||
variant.t)
|
||||
taskmod.t rectangle.t tree.t tree2.t uri.t json.t variant.t)
|
||||
|
||||
add_custom_target (test ./run_all DEPENDS ${test_SRCS}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test)
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <iostream>
|
||||
#include "main.h"
|
||||
#include "test.h"
|
||||
#include "Context.h"
|
||||
#include "Lisp.h"
|
||||
|
||||
Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest test (6);
|
||||
|
||||
// (one)
|
||||
// t -> "one" (no tags)
|
||||
// -> no child nodes
|
||||
Lisp l;
|
||||
Tree* t = l.parse ("(one)");
|
||||
//t->dump ();
|
||||
|
||||
test.is (t->branches (), 1, "(one) -> 1 node under root");
|
||||
test.is ((*t)[0]->tags (), 1, "(one) -> 1 tag");
|
||||
test.is ((*t)[0]->branches (), 0, "(one) -> 0 child nodes");
|
||||
delete t;
|
||||
|
||||
// (one two)
|
||||
// t -> "one" (tag: "two")
|
||||
// -> no child nodes
|
||||
t = l.parse ("(one two)");
|
||||
//t->dump ();
|
||||
|
||||
test.is (t->branches (), 1, "(one two) -> 1 node under root");
|
||||
test.is ((*t)[0]->tags (), 2, "(one) -> 2 tags");
|
||||
test.is ((*t)[0]->branches (), 0, "(one two) -> 0 child nodes");
|
||||
delete t;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue