From 4245d83812dac372f965d6e23ad2dc41547f68da Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 10 Apr 2011 20:41:38 -0400 Subject: [PATCH] Code Cleanup - Eliminated obsolete Lisp code. --- src/CMakeLists.txt | 14 ++--- src/Lisp.cpp | 125 -------------------------------------------- src/Lisp.h | 54 ------------------- test/CMakeLists.txt | 3 +- test/lisp.t.cpp | 65 ----------------------- 5 files changed, 8 insertions(+), 253 deletions(-) delete mode 100644 src/Lisp.cpp delete mode 100644 src/Lisp.h delete mode 100644 test/lisp.t.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0ab856c5a..62a58fd87 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/Lisp.cpp b/src/Lisp.cpp deleted file mode 100644 index 98ae53aa1..000000000 --- a/src/Lisp.cpp +++ /dev/null @@ -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"); -} - -//////////////////////////////////////////////////////////////////////////////// diff --git a/src/Lisp.h b/src/Lisp.h deleted file mode 100644 index 43a95ade1..000000000 --- a/src/Lisp.h +++ /dev/null @@ -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 -#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 - -//////////////////////////////////////////////////////////////////////////////// - diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 67cbe8923..5d66dc250 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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) diff --git a/test/lisp.t.cpp b/test/lisp.t.cpp deleted file mode 100644 index f8e072abb..000000000 --- a/test/lisp.t.cpp +++ /dev/null @@ -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 -#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; -} -