| 246 | {} |
| 247 | |
| 248 | FormulaParser::ValueType FormulaParser::parse(const std::string& input) |
| 249 | { |
| 250 | std::string::const_iterator iter = input.begin(); |
| 251 | std::string::const_iterator end = input.end(); |
| 252 | FormulaParser::ValueType result = static_cast<FormulaParser::ValueType>(0); |
| 253 | |
| 254 | try |
| 255 | { |
| 256 | if (!qi::phrase_parse(iter, end, Grammar(*this), ascii::space, result)) |
| 257 | { |
| 258 | mitkThrowException(FormulaParserException) << "Could not parse '" << input << |
| 259 | "': Grammar could not be applied to the input " << "at all."; |
| 260 | } |
| 261 | } |
| 262 | catch (qi::expectation_failure<Iter>& e) |
| 263 | { |
| 264 | std::string parsed = ""; |
| 265 | |
| 266 | for (Iter i = input.begin(); i != e.first; i++) |
| 267 | { |
| 268 | parsed += *i; |
| 269 | } |
| 270 | mitkThrowException(FormulaParserException) << "Error while parsing '" << input << |
| 271 | "': Unexpected character '" << *e.first << "' after '" << parsed << "'"; |
| 272 | } |
| 273 | |
| 274 | return result; |
| 275 | }; |
| 276 | |
| 277 | FormulaParser::ValueType FormulaParser::lookupVariable(const std::string var) |
| 278 | { |