[1118] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
[1505] | 3 | * > www.orxonox.net < |
---|
[1118] | 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Reto Grieder |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | /** |
---|
| 30 | @file |
---|
| 31 | @brief Declaration of FloatParser |
---|
| 32 | */ |
---|
[1505] | 33 | |
---|
| 34 | #ifndef _FloatParser_H__ |
---|
| 35 | #define _FloatParser_H__ |
---|
| 36 | |
---|
| 37 | #include "UtilPrereqs.h" |
---|
[6185] | 38 | |
---|
| 39 | #include <map> |
---|
[1505] | 40 | #include <string> |
---|
| 41 | |
---|
[2171] | 42 | namespace orxonox |
---|
[1505] | 43 | { |
---|
[2171] | 44 | class _UtilExport ExprParser |
---|
[1894] | 45 | { |
---|
[2171] | 46 | public: |
---|
| 47 | enum binary_operator |
---|
| 48 | { |
---|
| 49 | b_plus, |
---|
| 50 | b_minus, |
---|
| 51 | mal, |
---|
| 52 | durch, |
---|
| 53 | modulo, |
---|
| 54 | hoch, |
---|
| 55 | undef, |
---|
| 56 | oder, |
---|
| 57 | und, |
---|
| 58 | gleich, |
---|
| 59 | b_nicht, |
---|
| 60 | kleiner, |
---|
| 61 | groesser, |
---|
| 62 | ungleich, |
---|
| 63 | kleinergleich, |
---|
| 64 | groessergleich |
---|
| 65 | }; |
---|
[1505] | 66 | |
---|
[2171] | 67 | enum unary_operator |
---|
| 68 | { |
---|
| 69 | u_plus, |
---|
| 70 | u_minus, |
---|
| 71 | u_nicht |
---|
| 72 | }; |
---|
[1505] | 73 | |
---|
| 74 | |
---|
[6185] | 75 | ExprParser(); |
---|
| 76 | void parse(const std::string& str); |
---|
[3196] | 77 | const std::string& getRemains() { return this->remains_; } |
---|
| 78 | double getResult() { return this->result_; } |
---|
| 79 | bool getSuccess() { return !this->failed_; } |
---|
[1505] | 80 | |
---|
[6185] | 81 | void setVariable(const std::string& varname, double value); |
---|
| 82 | |
---|
[2171] | 83 | private: |
---|
| 84 | double parse_expr_1(); |
---|
| 85 | double parse_expr_2(); |
---|
| 86 | double parse_expr_3(); |
---|
| 87 | double parse_expr_4(); |
---|
| 88 | double parse_expr_5(); |
---|
| 89 | double parse_expr_6(); |
---|
| 90 | double parse_expr_7(); |
---|
| 91 | double parse_expr_8(); |
---|
| 92 | char* parse_word(char* str); |
---|
| 93 | binary_operator parse_binary_operator(); |
---|
| 94 | unary_operator parse_unary_operator(); |
---|
[1505] | 95 | |
---|
[2171] | 96 | double parse_argument(); |
---|
| 97 | double parse_last_argument(); |
---|
[1505] | 98 | |
---|
[2171] | 99 | binary_operator op; |
---|
| 100 | const char* reading_stream; |
---|
| 101 | bool failed_; |
---|
| 102 | double result_; |
---|
| 103 | std::string remains_; |
---|
[6185] | 104 | std::map<std::string, double> variables_; |
---|
[2171] | 105 | }; |
---|
[1505] | 106 | |
---|
[2171] | 107 | //Endzeichen für float expression: ')', '}', ']', ',', ';' |
---|
| 108 | _UtilExport bool parse_float(char* const, char**, double*); |
---|
| 109 | //Endzeichen angegeben |
---|
| 110 | _UtilExport bool parse_float(char* const, char**, char, double*); |
---|
| 111 | //Letzter Teil-float eines Vektors parsen (keine Vergleichs- und Logikoperationen) |
---|
| 112 | _UtilExport bool parse_vector_float(char* const, char**, bool, double*); |
---|
| 113 | } |
---|
[1505] | 114 | |
---|
| 115 | #endif /* _FloatParser_H__ */ |
---|