1 /** \file mpIOprt.h 2 \brief Definition of base classes needed for parser operator definitions. 3 4 <pre> 5 __________ ____ ___ 6 _____ __ _\______ \_____ _______ ______ __________\ \/ / 7 / \| | \ ___/\__ \\_ __ \/ ___// __ \_ __ \ / 8 | Y Y \ | / | / __ \| | \/\___ \\ ___/| | \/ \ 9 |__|_| /____/|____| (____ /__| /____ >\___ >__| /___/\ \ 10 \/ \/ \/ \/ \_/ 11 Copyright (C) 2016 Ingo Berg 12 All rights reserved. 13 14 muParserX - A C++ math parser library with array and string support 15 Copyright (c) 2016, Ingo Berg 16 All rights reserved. 17 18 Redistribution and use in source and binary forms, with or without 19 modification, are permitted provided that the following conditions are met: 20 21 * Redistributions of source code must retain the above copyright notice, 22 this list of conditions and the following disclaimer. 23 * Redistributions in binary form must reproduce the above copyright notice, 24 this list of conditions and the following disclaimer in the documentation 25 and/or other materials provided with the distribution. 26 27 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 28 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 29 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 30 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 31 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 32 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 33 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 34 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 POSSIBILITY OF SUCH DAMAGE. 37 </pre> 38 */ 39 #ifndef MUP_IPARSER_OPERATOR_H 40 #define MUP_IPARSER_OPERATOR_H 41 42 #include "mpICallback.h" 43 #include "mpIPrecedence.h" 44 45 46 MUP_NAMESPACE_START 47 48 //------------------------------------------------------------------------------ 49 /** \brief Interface for binary operators. 50 \ingroup binop 51 52 All classes representing binary operator callbacks must be derived from 53 this base class. 54 */ 55 class IOprtBin : public ICallback, 56 public IPrecedence 57 { 58 public: 59 60 IOprtBin(const char_type *a_szIdent, int nPrec, EOprtAsct eAsc); 61 virtual ~IOprtBin(); 62 virtual string_type AsciiDump() const; 63 64 //------------------------------------------ 65 // IPrecedence implementation 66 //------------------------------------------ 67 68 virtual IPrecedence* AsIPrecedence(); 69 virtual EOprtAsct GetAssociativity() const; 70 virtual int GetPri() const; 71 72 private: 73 int m_nPrec; 74 EOprtAsct m_eAsc; 75 }; // class IOperator 76 77 78 //------------------------------------------------------------------------------ 79 /** \brief Interface for unary postfix operators. 80 \ingroup postfix 81 */ 82 class IOprtPostfix : public ICallback 83 { 84 public: 85 IOprtPostfix(const char_type *a_szIdent); 86 virtual ~IOprtPostfix(); 87 virtual string_type AsciiDump() const; 88 }; // class IOperator 89 90 91 //------------------------------------------------------------------------------ 92 /** \brief Interface for unary infix operators. 93 \ingroup infix 94 */ 95 class IOprtInfix : public ICallback, 96 public IPrecedence 97 { 98 public: 99 IOprtInfix(const char_type *a_szIdent, int nPrec); 100 virtual ~IOprtInfix(); 101 virtual string_type AsciiDump() const; 102 103 //------------------------------------------ 104 // IPrecedence implementation 105 //------------------------------------------ 106 107 virtual IPrecedence* AsIPrecedence(); 108 virtual int GetPri() const; 109 virtual EOprtAsct GetAssociativity() const; 110 111 private: 112 int m_nPrec; 113 }; // class IOperator 114 } // namespace mu 115 116 #endif 117 118