Orxonox  0.0.5 Codename: Arcturus
ExprParser.h
Go to the documentation of this file.
1 /*
2  * ORXONOX - the hottest 3D action shooter ever to exist
3  * > www.orxonox.net <
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 
35 #ifndef _FloatParser_H__
36 #define _FloatParser_H__
37 
38 #include "UtilPrereqs.h"
39 
40 #include <map>
41 #include <string>
42 
43 namespace orxonox
44 {
94  {
95  public:
97  {
113  groessergleich
114  };
115 
117  {
120  u_nicht
121  };
122 
123 
124  ExprParser();
125  void parse(const std::string& str);
126  const std::string& getRemains() { return this->remains_; }
127  float getResult() { return this->result_; }
128  bool getSuccess() { return !this->failed_; }
129 
130  void setVariable(const std::string& varname, float value);
131 
132  private:
133  float parse_expr_1();
134  float parse_expr_2();
135  float parse_expr_3();
136  float parse_expr_4();
137  float parse_expr_5();
138  float parse_expr_6();
139  float parse_expr_7();
140  float parse_expr_8();
141  void parse_word(char* str);
142  binary_operator parse_binary_operator();
143  unary_operator parse_unary_operator();
144 
145  float parse_argument();
146  float parse_last_argument();
147 
149  const char* reading_stream;
150  bool failed_;
151  float result_;
153  std::map<std::string, float> variables_;
154  };
155 
156  //Endzeichen für float expression: ')', '}', ']', ',', ';'
157  _UtilExport bool parse_float(char* const, char**, float*);
158  //Endzeichen angegeben
159  _UtilExport bool parse_float(char* const, char**, char, float*);
160  //Letzter Teil-float eines Vektors parsen (keine Vergleichs- und Logikoperationen)
161  _UtilExport bool parse_vector_float(char* const, char**, bool, float*);
162 }
163 
164 #endif /* _FloatParser_H__ */
binary_operator op
Definition: ExprParser.h:148
#define _UtilExport
Definition: UtilPrereqs.h:60
float getResult()
Definition: ExprParser.h:127
Definition: ExprParser.h:119
Definition: ExprParser.h:118
::std::string string
Definition: gtest-port.h:756
_UtilExport bool parse_vector_float(char *const, char **, bool, float *)
Parser for expressions like "3 * cos(5 + 4) / a" where a is a predeclared variable.
Definition: ExprParser.h:93
bool failed_
Definition: ExprParser.h:150
Definition: ExprParser.h:103
std::string remains_
Definition: ExprParser.h:152
std::map< std::string, float > variables_
Definition: ExprParser.h:153
Definition: ExprParser.h:100
bool getSuccess()
Definition: ExprParser.h:128
Definition: ExprParser.h:99
Definition: ExprParser.h:112
Definition: ExprParser.h:104
Definition: ExprParser.h:98
Definition: ExprParser.h:110
float result_
Definition: ExprParser.h:151
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
Shared library macros, enums, constants and forward declarations for the util library ...
const char * reading_stream
Definition: ExprParser.h:149
_UtilExport bool parse_float(char *const, char **, float *)
Definition: ExprParser.h:111
const std::string & getRemains()
Definition: ExprParser.h:126
Definition: ExprParser.h:107
Definition: ExprParser.h:101
Definition: ExprParser.h:109
Definition: ExprParser.h:108
binary_operator
Definition: ExprParser.h:96
Definition: ExprParser.h:106
unary_operator
Definition: ExprParser.h:116
Definition: ExprParser.h:105
Definition: ExprParser.h:102