CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
testEvaluator.cc File Reference
#include "CLHEP/Evaluator/Evaluator.h"
#include <iostream>
#include <string.h>
#include <assert.h>

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )

Definition at line 16 of file testEvaluator.cc.

16 {
17 char exp[240];
19
20 eval.setVariable(" dummy ", 0.); // these three lines have been
21 assert( eval.findVariable(" dummy ") ); // included just for test
22 eval.clear(); // ===========================
23
24 eval.setStdMath(); // set standard constants and functions
25 eval.setSystemOfUnits(); // set SI units
26 std::cout.precision(15);
27 for(;;) {
28 std::cout << "CALC> ";
29
30 // In principle, next two lines could be replaced with just
31 // std::cin.getline(exp, 240); but that does not work on DEC
32 // because of bug in the cxx V6.1-027 compiler.
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; // exit
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;
50 eval.print_error();
51 }
52 std::cout << std::endl;
53 }
54 return 0;
55}
double eval(std::string expr, int &numbad, std::ofstream &os)
Definition: testBug66214.cc:11