/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: simplifier.h,v 1.6 2002/04/29 19:34:30 cparpart Exp $ // (This file contains the expression simplifier interface) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library 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 // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// #ifndef libmath_simplifier_h #define libmath_simplifier_h #include namespace math { /** * \todo: complete the simplifier implementation (using expr pattern matching). */ template class TSimplifier : public TNodeVisitor { public: /// Simplifies given expression and returns its result. static TNode *simplify(const TNode *AExpression); private: TNode *FResult; private: TSimplifier(); /// calculate() is used to calculate partial expressions to check its static value. T calculate(const TNode *) const; virtual void visit(TNumberNode *); virtual void visit(TSymbolNode *); virtual void visit(TParamNode *); virtual void visit(TPlusNode *); virtual void visit(TNegNode *); virtual void visit(TMulNode *); virtual void visit(TDivNode *); virtual void visit(TPowNode *); virtual void visit(TSqrtNode *); virtual void visit(TSinNode *); virtual void visit(TCosNode *); virtual void visit(TTanNode *); virtual void visit(TLnNode *); virtual void visit(TFuncNode *); virtual void visit(TIfNode *); virtual void visit(TEquNode *); virtual void visit(TUnEquNode *); virtual void visit(TGreaterNode *); virtual void visit(TLessNode *); virtual void visit(TGreaterEquNode *); virtual void visit(TLessEquNode *); }; } // namespace math #include #endif