/* Example programs from the book Scientific and Engineering Programming in C++: An Introduction with Advanced Techniques and Examples, Addison-Wesley, 1994. (c) COPYRIGHT INTERNATIONAL BUSINESS MACHINES CORPORATION 1994. ALL RIGHTS RESERVED. See README file for further details. */ #ifndef FAMakerH #define FAMakerH #include "Function/FunctionalAlgebra.h" #include "Array/ConcreteFormedArray1d.h" #include "examples/ch17/Lexer.h" class FAMaker { public: FAMaker(const String& input); FunctionalAlgebra function(); FunctionalAlgebra term(); FunctionalAlgebra exp(); FunctionalAlgebra add(); FunctionalAlgebra subtract(); FunctionalAlgebra multiply(); FunctionalAlgebra divide(); FunctionalAlgebra cos(); FunctionalAlgebra sin(); // Add functions here and in constructor. // ... Exception classes SyntaxErr and FunctionUndefined ... class SyntaxErr : public SciEngErr { public: virtual String message() const; }; class FunctionUndefined : public SciEngErr { public: FunctionUndefined(const String& name) : the_name(name) {} virtual String message() const; private: String the_name; }; private: Lexer lexer; typedef FunctionalAlgebra (FAMaker::*ParserFunction)(); ConcreteFormedArray1d function_names; ConcreteFormedArray1d functions; ParserFunction lookup(const String& function_name) const; void skipComma(); }; #endif