193{
194
195 std::string expr {expr_mod};
196 std::string::size_type start_index = 0;
197 std::string::size_type end_index = 0;
198 while(true)
199 {
200 start_index = expr.find('[', start_index);
201 if(start_index == std::string::npos) break;
202 std::string::size_type boundary_index = expr.find(']', start_index);
203 expr.replace(start_index,1,1,'_');
204 end_index = expr.find(',', start_index);
205 if(end_index != std::string::npos && end_index < boundary_index)
206 {
207 start_index++;
208 std::string var1 = expr.substr(start_index, end_index-start_index);
210 std::stringstream ss1;
211 std::string str1;
212 ss1 << eval1;
213 ss1 >> str1;
214 expr.replace(start_index, end_index-start_index, str1, 0, str1.size());
215 }
216 else
217 {
218 end_index = boundary_index;
219 if(end_index != std::string::npos)
220 {
221 start_index++;
222 std::string var1 = expr.substr(start_index, end_index-start_index);
224 std::stringstream ss1;
225 std::string str1;
226 ss1 << eval1;
227 ss1 >> str1;
228 expr.replace(start_index, end_index-start_index, str1, 0, str1.size());
229 }
230 }
231 }
232 start_index = 0;
233 end_index = 0;
234 while(true)
235 {
236 start_index = expr.find(',', start_index);
237 if(start_index == std::string::npos) break;
238 expr.replace(start_index,1,1,'_');
239 end_index = expr.find(']', start_index);
240 start_index++;
241 std::string var2 = expr.substr(start_index, end_index-start_index);
243 std::stringstream ss2;
244 std::string str2;
245 ss2 << eval2;
246 ss2 >> str2;
247 expr.replace(start_index, end_index-start_index, str2, 0, str2.size());
248 }
249 start_index = 0;
250 end_index = 0;
251 while(true)
252 {
253 start_index = expr.find(']', start_index);
254 if(start_index == std::string::npos) break;
255 expr.replace(start_index,1,1,'_');
256 }
258 if(
m_calc.status() != HepTool::Evaluator::OK )
259 {
260 std::cerr << expr << std::endl;
261 for (
int i=0;
i<
m_calc.error_position();
i++)
262 {
263 std::cerr << "-";
264 }
265 std::cerr << "^\a" << std::endl;
267 std::cerr << std::endl;
268 }
270}
double EvaluateString(const std::string &str)