From c3bf3b79a4de18fcdbd7532aa4da4204ea09aa52 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 1 Sep 2013 13:57:24 -0400 Subject: [PATCH] A3t::initialize - Migrated ctor functionality over to the new initialize method, for integration with Context. --- src/parser/A3t.cpp | 17 +++++++++++------ src/parser/A3t.h | 3 ++- src/parser/args.cpp | 3 ++- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/parser/A3t.cpp b/src/parser/A3t.cpp index 552dcaa38..55843be1d 100644 --- a/src/parser/A3t.cpp +++ b/src/parser/A3t.cpp @@ -36,12 +36,22 @@ static const int minimumMatchLength = 3; //////////////////////////////////////////////////////////////////////////////// -A3t::A3t (int argc, char** argv) +A3t::A3t () { _tree = new Tree ("root"); if (! _tree) throw std::string ("Failed to allocate memory for parse tree."); +} +//////////////////////////////////////////////////////////////////////////////// +A3t::~A3t () +{ + delete _tree; +} + +//////////////////////////////////////////////////////////////////////////////// +void A3t::initialize (int argc, char** argv) +{ for (int i = 0; i < argc; ++i) { Tree* branch = _tree->addBranch (new Tree (format ("arg{1}", i))); @@ -51,11 +61,6 @@ A3t::A3t (int argc, char** argv) } } -//////////////////////////////////////////////////////////////////////////////// -A3t::~A3t () -{ -} - //////////////////////////////////////////////////////////////////////////////// Tree* A3t::parse () { diff --git a/src/parser/A3t.h b/src/parser/A3t.h index 17440fabd..f7498d71b 100644 --- a/src/parser/A3t.h +++ b/src/parser/A3t.h @@ -34,8 +34,9 @@ class A3t { public: - A3t (int, char**); + A3t (); ~A3t (); + void initialize (int, char**); Tree* parse (); void entity (const std::string&, const std::string&); bool canonicalize (std::string&, const std::string&, const std::string&) const; diff --git a/src/parser/args.cpp b/src/parser/args.cpp index d0435db5e..c20bc1450 100644 --- a/src/parser/args.cpp +++ b/src/parser/args.cpp @@ -39,7 +39,8 @@ int main (int argc, char** argv) // Prepare the Context object. - A3t a3t (argc, argv); + A3t a3t; + a3t.initialize (argc, argv); // Reports. a3t.entity ("report", "list");