#include "CLHEP/Evaluator/Evaluator.h"
#include <iostream>
#include <string.h>
#include <assert.h>
Go to the source code of this file.
◆ main()
Definition at line 16 of file testEvaluator.cc.
16 {
17 char exp[240];
19
20 eval.setVariable(
" dummy ", 0.);
21 assert(
eval.findVariable(
" dummy ") );
23
25 eval.setSystemOfUnits();
26 std::cout.precision(15);
27 for(;;) {
28 std::cout << "CALC> ";
29
30
31
32
33 std::cin.get(exp, 240);
34 std::cin.ignore();
35 if ( !std::cin || strcmp(exp,"exit") == 0 || strcmp(exp,"quit") == 0) {
36 std::cout << std::endl;
37 break;
38 }
39 double value =
eval.evaluate(exp);
40 switch(
eval.status()) {
42 std::cout << value << std::endl;
43 break;
45 continue;
46 default:
47 std::cout << "------";
48 for (
int i=0; i<
eval.error_position(); i++) std::cout <<
"-";
49 std::cout << "^" << std::endl;
51 }
52 std::cout << std::endl;
53 }
54 return 0;
55}
double eval(std::string expr, int &numbad, std::ofstream &os)