Index: trunk/SophyaLib/SysTools/Makefile
===================================================================
--- trunk/SophyaLib/SysTools/Makefile	(revision 2509)
+++ trunk/SophyaLib/SysTools/Makefile	(revision 2510)
@@ -3,7 +3,7 @@
 all: $(LIB)libSysTools.a
 clean:
-	rm -f $(OBJ)commander.o $(OBJ)ctimer.o $(OBJ)cxxcmplnk.o $(OBJ)pdlmgr.o $(OBJ)periodic.o $(OBJ)psighand.o $(OBJ)resusage.o $(OBJ)zthread.o $(OBJ)timing.o
+	rm -f $(OBJ)cexpre.o $(OBJ)commander.o $(OBJ)ctimer.o $(OBJ)cxxcmplnk.o $(OBJ)pdlmgr.o $(OBJ)periodic.o $(OBJ)psighand.o $(OBJ)resusage.o $(OBJ)rpneval.o $(OBJ)zthread.o $(OBJ)timing.o
 	rm -f $(LIB)libSysTools.a
-$(LIB)libSysTools.a : $(OBJ)commander.o $(OBJ)ctimer.o $(OBJ)cxxcmplnk.o $(OBJ)pdlmgr.o $(OBJ)periodic.o $(OBJ)psighand.o $(OBJ)resusage.o $(OBJ)timing.o $(OBJ)zthread.o
+$(LIB)libSysTools.a : $(OBJ)cexpre.o $(OBJ)commander.o $(OBJ)ctimer.o $(OBJ)cxxcmplnk.o $(OBJ)pdlmgr.o $(OBJ)periodic.o $(OBJ)psighand.o $(OBJ)resusage.o $(OBJ)rpneval.o $(OBJ)timing.o $(OBJ)zthread.o
 	$(ARCXX) $(ARCXXFLAGS) $@ $($(ARARGS))
 ifeq ($(CXX),cxx)
@@ -11,22 +11,48 @@
 endif 
  
+$(OBJ)cexpre.o: cexpre.cc cexpre.h $(INC)machdefs.h \
+  $(INC)osx_values.h \
+  $(INC)pexceptions.h
 $(OBJ)commander.o: commander.cc commander.h \
- $(INC)machdefs.h pdlmgr.h ctimer.h \
- $(INC)strutil.h \
- $(INC)strutilxx.h \
- $(INC)srandgen.h
-$(OBJ)ctimer.o: ctimer.cc $(INC)machdefs.h ctimer.h
+  $(INC)machdefs.h \
+  $(INC)osx_values.h pdlmgr.h \
+  $(INC)dvlist.h \
+  $(INC)objfio.h \
+  $(INC)anydataobj.h \
+  $(INC)ppersist.h \
+  $(INC)pexceptions.h \
+  $(INC)gnumd5.h \
+  $(INC)ppfbinstream.h \
+  $(INC)rawstream.h \
+  $(INC)ppfnametag.h \
+  $(INC)mutyv.h ctimer.h \
+  $(INC)strutil.h \
+  $(INC)strutilxx.h \
+  $(INC)srandgen.h
+$(OBJ)ctimer.o: ctimer.cc $(INC)machdefs.h \
+  $(INC)osx_values.h ctimer.h
 $(OBJ)cxxcmplnk.o: cxxcmplnk.cc cxxcmplnk.h \
- $(INC)machdefs.h
-$(OBJ)pdlmgr.o: pdlmgr.cc pdlmgr.h
+  $(INC)machdefs.h \
+  $(INC)osx_values.h
+$(OBJ)pdlmgr.o: pdlmgr.cc $(INC)machdefs.h \
+  $(INC)osx_values.h pdlmgr.h
 $(OBJ)periodic.o: periodic.cc $(INC)machdefs.h \
- periodic.h
+  $(INC)osx_values.h periodic.h
 $(OBJ)psighand.o: psighand.cc psighand.h \
- $(INC)machdefs.h \
- $(INC)pexceptions.h
+  $(INC)machdefs.h \
+  $(INC)osx_values.h \
+  $(INC)pexceptions.h
 $(OBJ)resusage.o: resusage.cc resusage.h \
- $(INC)machdefs.h
+  $(INC)machdefs.h \
+  $(INC)osx_values.h
+$(OBJ)rpneval.o: rpneval.cc rpneval.h \
+  $(INC)machdefs.h \
+  $(INC)osx_values.h \
+  $(INC)pexceptions.h \
+  $(INC)strutilxx.h \
+  $(INC)srandgen.h
 $(OBJ)zthread.o: zthread.cc zthread.h \
- $(INC)machdefs.h \
- $(INC)pexceptions.h
+  $(INC)machdefs.h \
+  $(INC)osx_values.h \
+  $(INC)pexceptions.h
 $(OBJ)timing.o: timing.c timing.h
Index: trunk/SophyaLib/SysTools/cexpre.cc
===================================================================
--- trunk/SophyaLib/SysTools/cexpre.cc	(revision 2510)
+++ trunk/SophyaLib/SysTools/cexpre.cc	(revision 2510)
@@ -0,0 +1,465 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include "cexpre.h"
+#include <stack>
+#include <math.h>
+
+namespace SOPHYA {
+
+long CExprBase::totnexp_create = 0;
+long CExprBase::totnexp_delete = 0;
+CExprBase::CExprBase()
+{
+  totnexp_create++;
+  // cout << "CExprBase::CExprBase()-Creation " << hex << this << dec << endl;
+}
+
+CExprBase::~CExprBase()
+{
+  totnexp_delete++;
+  // cout << "CExprBase::~CExprBase() " << hex << this << dec << endl;
+}
+
+void CExprBase::CheckThrow(const char * msg) const
+{
+  string errmsg;
+  bool ok = CheckE(errmsg);
+  if (ok) return;
+  else {
+    errmsg += msg;
+    throw CExprException(errmsg);
+  }
+}
+
+//---------------------------------------------------------
+class CE_NumberExp : public CExprBase {
+public:
+  CE_NumberExp(double v) { _val = v; }
+  CE_NumberExp(string const & s);
+  virtual ~CE_NumberExp() {}
+  virtual double Evaluate() const { return _val; }  
+  virtual void  Print(ostream& os) const { os << _val; }
+protected:
+  double _val;
+};
+
+CE_NumberExp::CE_NumberExp(string const & s)
+{
+  size_t l = s.length();
+  if (l < 1) { 
+    string errmsg = "CE_NumberExp::CE_NumberExp() Empty expression";
+    throw CExprException(errmsg);
+  }
+  if (s == "Pi") _val = M_PI;
+  else if (s == "E") _val = M_E;
+  else {
+    string errmsg = "CE_NumberExp::CE_NumberExp() Bad numerical constant: ";
+    errmsg += s;
+    
+    if ((s == "+") || (s == "-"))  throw CExprException(errmsg);
+    for(int k=0; k<l; k++) {
+      if ((!isdigit(s[k])) && !((k==0) && (s[k] != '+') || (s[k] != '-')) ) 
+	throw CExprException(errmsg);
+    }
+    _val = atof(s.c_str());
+  }
+}
+
+
+//---------------------------------------------------------
+class CE_BinExp : public CExprBase {
+public:
+  explicit CE_BinExp(char op, int prior); 
+  virtual ~CE_BinExp() { if (_e1) delete _e1; if (_e2) delete _e2; }
+  inline void SetE1(CExprBase * e) { _e1 = e; } 
+  inline void SetE2(CExprBase * e) { _e2 = e; }
+  virtual bool CheckE(string& errmsg) const; 
+  virtual void Print(ostream& os) const;
+  inline char BOpC() const { return _bop; } 
+  inline int  Priority() const { return _priority; } 
+ protected:
+  CExprBase * _e1;
+  CExprBase * _e2;
+  char _bop;     // Caractere identificateur d'operation (+,-,*,/ ...)
+  int _priority; // Niveau de priorite: 1= +,-  2: *,/  3: ^...
+};
+
+CE_BinExp::CE_BinExp(char op, int prior)
+{
+  _e1 = NULL; _e2 = NULL; 
+  _bop = op;
+  _priority = prior;
+}
+
+bool CE_BinExp::CheckE(string& errmsg) const 
+{	
+  if ((_e1 == NULL) || (_e2 == NULL)) {
+    errmsg += "CE_BinExp::CheckE: Binary expression-missing argument ";
+    return false;
+  }
+  return true;
+}
+
+void CE_BinExp::Print(ostream& os) const
+{ 
+  os << "(" << (*_e1) << _bop << (*_e2) << ")" ; 
+}
+
+//---------------------------------------------------------
+class CE_AddExp : public CE_BinExp {
+public:
+  CE_AddExp() : CE_BinExp('+',1) {}
+  virtual double Evaluate() const { CheckThrow("CE_AddExp::Evaluate"); return _e1->Evaluate()+_e2->Evaluate();
+ }
+};
+class CE_MulExp : public CE_BinExp {
+public:
+  CE_MulExp() : CE_BinExp('*',2) {}
+  virtual double Evaluate() const { CheckThrow("CE_MulExp::Evaluate"); return _e1->Evaluate()*_e2->Evaluate(); }
+};
+class CE_SubExp : public CE_BinExp {
+public:
+  CE_SubExp() : CE_BinExp('-',1) {}
+  virtual double Evaluate() const { CheckThrow("CE_SubExp::Evaluate"); return _e1->Evaluate()-_e2->Evaluate(); }
+};
+class CE_DivExp : public CE_BinExp {
+public:
+  CE_DivExp() : CE_BinExp('/',2) {}
+  virtual double Evaluate() const { CheckThrow("CE_DivExp::Evaluate"); return _e1->Evaluate()/_e2->Evaluate(); }
+};
+
+//---------------------------------------------------------
+typedef double (* f0exp) ();
+typedef double (* f1exp) (double x);
+typedef double (* f2exp) (double x, double y);
+typedef double (* f3exp) (double x, double y, double z);
+
+//---------------------------------------------------------
+#define FMXARG 3
+class CE_FuncExp : public CExprBase {
+public:
+  CE_FuncExp(string const & func);
+  virtual ~CE_FuncExp(); 
+  virtual double Evaluate() const ;
+  inline void AddArg(CExprBase * e);
+  virtual bool CheckE(string& errmsg) const; 
+  virtual void Print(ostream& os) const;
+protected:
+  f0exp _f0; 
+  f1exp _f1; 
+  f2exp _f2; 
+  f3exp _f3; 
+  int _ne, _maxne;
+  CExprBase * _e[FMXARG];
+  string _fname;
+};
+
+//---------------------------------------------------------
+CE_FuncExp::CE_FuncExp(string const & func)
+{
+  _ne = 0; _maxne = -1;
+  for(int k=0; k<FMXARG; k++)  _e[k] = NULL;
+  _f0 = NULL;
+  _f1 = NULL;
+  _f2 = NULL;
+  _f3 = NULL;
+  if (func == "sin") _f1 = sin;
+  else if (func == "cos") _f1 = cos;
+  else if (func == "tan") _f1 = tan;
+  else if (func == "asin") _f1 = asin;
+  else if (func == "acos") _f1 = acos;
+  else if (func == "atan") _f1 = atan;
+  else if (func == "atan2") _f2 = atan2;
+  else if (func == "exp") _f1 = exp;
+  else if (func == "log") _f1 = log;
+  else if (func == "log10") _f1 = log10;
+  else if (func == "pow") _f2 = pow;
+  else { 
+    string errmsg = "CE_FuncExp::CE_FuncExp() - Uknown function " ;
+    errmsg += func;
+    throw CExprException(errmsg);
+  } 
+  if (_f0)  _maxne = 0;
+  else if (_f1)  _maxne = 1;
+  else if (_f2) _maxne = 2;
+  else if (_f3) _maxne = 3;
+  _fname = func;
+}
+
+
+CE_FuncExp::~CE_FuncExp()
+{  
+for(int k=0; k<FMXARG; k++)  if (_e[k]) delete _e[k];
+}
+
+void CE_FuncExp::AddArg(CExprBase * e)
+{
+  if ((e != NULL) && (_ne < _maxne)) { _e[_ne] = e; _ne++; }
+  else  throw CExprException("CE_FuncExp::AddArg() e=NULL or too many arguments ");
+}
+
+double CE_FuncExp::Evaluate() const 
+{
+  if ((_ne != _maxne) || (_maxne < 1) ) {
+    throw CExprException("CE_FuncExp::Evaluate() - Wrong argument number ");
+  }
+  if (_ne == 1) return _f1(_e[0]->Evaluate());
+  else if (_ne == 2) return _f2(_e[0]->Evaluate(), _e[1]->Evaluate());
+  else if (_ne == 3) return _f3(_e[0]->Evaluate(), _e[1]->Evaluate(), 
+				_e[2]->Evaluate());
+  else return 0.;
+}
+
+bool CE_FuncExp::CheckE(string& errmsg) const
+{	
+  if ((_ne != _maxne) || (_maxne < 0) ) {
+    char buff[128];
+    sprintf(buff, "CE_FuncExp::CheckE() %s - Wrong argument number - ne=%d maxne=%d ", 
+	    _fname.c_str(), _ne, _maxne);
+    errmsg += buff;
+    return false;
+  }
+  return true;
+}
+
+void CE_FuncExp::Print(ostream& os) const
+{ 
+  if ((_ne != _maxne) || (_maxne < 1) ) 
+    os << _fname << "(ArgError)" ;
+  else {
+    if (_ne == 1) os << _fname << "(" << *(_e[0]) << ")";
+    else if (_ne == 2) os << _fname << "(" << *(_e[0]) << "," << *(_e[1]) << ")";
+    else if (_ne == 3) os << _fname << "(" << *(_e[0]) 
+			  << "," << *(_e[1]) << "," << *(_e[2]) << ")";
+  }
+}
+
+//---------------------------------------------------------
+CExpressionEvaluator::CExpressionEvaluator(string const & sex)
+{
+  _exp = NULL;
+  size_t off=0,stop=0;
+  string fname = "";
+  string errmsg;
+  _exp=  ParseString(0,fname,sex,off,stop,errmsg);
+  if (_exp == NULL)  throw CExprException(errmsg);
+}
+
+CExpressionEvaluator::~CExpressionEvaluator()
+{
+  if (_exp) delete _exp;
+}
+
+double CExpressionEvaluator::Evaluate() const
+{
+  if (_exp) return _exp->Evaluate();
+  else return 0.;
+}
+
+void CExpressionEvaluator::Print(ostream& os) const
+{
+  if (_exp) _exp->Print(os);
+  else os << "CExpressionEvaluator ???";
+}
+
+// cette fonction rearrange le stack des operations binaires en attente
+CExprBase* Arrange_CE_BinExpStack(stack<CE_BinExp* >& sbx, CExprBase* cex, CE_BinExp* nbx)
+{
+  while ( !sbx.empty() && (nbx->Priority() <= sbx.top()->Priority()) ) {
+    sbx.top()->SetE2(cex);
+    cex = sbx.top();  sbx.pop();
+  }
+  nbx->SetE1(cex);
+  sbx.push(nbx);
+  return NULL;
+}
+
+// cette fonction rearrange le stack des operations binaires en attente
+CExprBase* Arrange_CE_BinExpStack(stack<CE_BinExp* >& sbx, CExprBase* cex)
+{
+  if (sbx.empty())  return cex;
+  while ( !sbx.empty() ) {
+    sbx.top()->SetE2(cex);
+    cex = sbx.top();  sbx.pop();
+  }
+  return cex;
+}
+
+
+CExprBase* CExpressionEvaluator::ParseString(int extype, string fname, string const & sex, 
+					size_t off, size_t& stop, string& errmsg)
+{
+  size_t len = sex.length();
+  if (len < 1) { 
+    string errmsg = "CExpressionEvaluator::ParseString() Empty expression";
+    throw CExprException(errmsg);
+  }
+
+  CExprBase* rx = NULL;   // Expression resultat
+  stack< CE_BinExp* > sbx;  // Stack des expressions binaires
+  CE_FuncExp* fx = NULL;    // Expression fonction 
+  CExprBase* cx = NULL;       // Element d'expression (courante)
+
+  if (extype == 2)  fx = new CE_FuncExp(fname);
+
+  size_t p=0, q=0;
+  char lastopc=0, opc=0; // Last/current operation sign (+,-,*,/,...)
+  char bxopc=0;          // Binary operation sign 
+  bool finok = false;
+  bool fgcont = true;
+  bool checkok = true;
+  //  cout << " DBG-ParseString off= " << off << " sex[off]= " << sex[off] 
+  //	<< " extype= " << extype << endl;
+  p = stop = off;  
+  while ((p < len) && (fgcont) && (checkok) ) { 
+    //   cout << " DBG-2-ParseString p=" << p << " q=" << q << endl;
+
+    cx = NULL;
+    q = sex.find_first_of("+-*/(),",p);
+    if (q < len) {  // operateur trouve
+      opc = sex[q];  // signe operateur courant
+      switch (opc) {
+        case '(' : 
+	  if (q == p) { 
+	    string fname = "";
+	    cx = ParseString(1, fname, sex, q+1, stop, errmsg);
+	  }
+	  else cx = ParseString(2, sex.substr(p,q-p), sex, q+1, stop, errmsg);
+	  if (!cx)  { checkok = false; p = stop+1; }
+	  else { 
+	    if (rx) { 
+	      checkok = false; p = stop+1; fgcont = false; 
+	      delete cx;
+	      errmsg = "CExpressionEvaluator::ParseString()/ Syntax Error - rx&&cx (A)"; 
+	    }
+	    else {
+	      if (stop == len-1)  { 
+		rx = Arrange_CE_BinExpStack(sbx, cx);
+		finok = true;
+	      }
+	      else rx = cx;
+	      p = stop+1; lastopc = opc; 
+	    }
+	  }
+	  break;
+
+        case ')' : 
+        case ',' :
+	  if (extype == 0) {
+	    checkok = false; p = q;  fgcont = false; 
+	    errmsg = "CExpressionEvaluator::ParseString() Unexpected ) or ,";
+	  }
+          if ( (extype == 1) && (opc == ',')) {
+	    checkok = false; p = q;  fgcont = false; 
+	    errmsg = "CExpressionEvaluator::ParseString() Unexpected ,";
+	  }
+	  if ((q > p) && (rx)) {
+	    checkok = false; p = q;  fgcont = false; 
+	    errmsg = "CExpressionEvaluator::ParseString()/ Syntax Error - rx&&cx (B)"; 
+	  }
+	  if (q > p) cx = new CE_NumberExp(sex.substr(p,q-p));
+	  else cx = rx;
+	  
+	  if (!cx) {
+	    checkok = false; p = q;  fgcont = false; 
+	    errmsg = "CExpressionEvaluator::ParseString()/ Syntax Error - farg=NULL (BB)"; 
+	  }
+	  else {
+	    rx = Arrange_CE_BinExpStack(sbx, cx);
+	    if (extype == 2) {
+	      //	    cout << " DBG-ParseString-AddArg " << *(cx) << endl;
+	      fx->AddArg(rx);  rx = NULL;
+	    }
+	    if (opc == ')') { // Signe de fin de traitement d'une portion d'expression
+	      if (extype == 2) { rx = fx; fx = NULL; }
+	      stop = q;  lastopc = opc;
+	      fgcont = false;
+	      finok = true;
+	    }
+	    else {
+	      if (q == (len-1)) finok = true;
+	      p = q+1; lastopc = opc; 
+	    }
+	  }
+	  break;
+
+        case '+' :
+        case '-' :
+        case '*' :
+        case '/' :
+	  // Traitement des signes +/- qui pourrait faire partie d'une constante numerique
+	  if (!( ((opc=='+')||(opc=='-')) && ( (q==off) || ( (q==p) && (rx == NULL) ) ) ) ) {
+	    //		  ((lastopc=='+')||(lastopc=='-')||(lastopc=='*')||(lastopc=='/')) ) ) ) ) {
+	    CE_BinExp* nbx;
+	    if (opc == '+') { nbx = new CE_AddExp;  bxopc = '+'; }
+	    else if (opc == '-') { nbx = new CE_SubExp;   bxopc = '-'; }
+	    else if (opc == '*') { nbx = new CE_MulExp;  bxopc = '*'; }   
+	    else { nbx =  new CE_DivExp;  bxopc = '/'; }
+	    if ((p == q) && (rx == NULL)) {
+	      checkok = false; p = q;  fgcont = false; 
+	      delete nbx;
+	      errmsg = "CExpressionEvaluator::ParseString() Syntax Error - rx==NULL (C)";
+	    }
+	    else {
+	      if (p == q)  cx = rx;
+	      else cx = new CE_NumberExp(sex.substr(p,q-p));
+	      rx = Arrange_CE_BinExpStack(sbx, cx, nbx);
+	      p = q+1;  lastopc = opc;
+	    }
+	  }
+	  break;
+        default:
+	  throw CExprException("CExpressionEvaluator::ParseString() BUG-BUG-BUG");
+	  break;
+      }  // Fin de switch 
+    }
+    else {  // dernier element
+      if ( (p<len) && (rx != NULL)) {
+	checkok = false; p = len-1; fgcont = false; 
+	errmsg = "CExpressionEvaluator::ParseString() Syntax Error - rx!=NULL at end (D)";
+      }
+      else { 
+	if (p<len)  cx = new CE_NumberExp(sex.substr(p));
+	else cx = rx;
+	rx = Arrange_CE_BinExpStack(sbx, cx);
+	stop = p = len;  fgcont = false;      
+	finok = true;  
+      }
+    }
+  }
+  //  cout << " DBG-ParseString-out stop= " << stop << " sex[stop]= " << sex[stop] << endl; 
+  if (finok && checkok) { 
+    if( !sbx.empty() ) { 
+      checkok = false; 
+      errmsg = "CExpressionEvaluator::ParseString() !sbx.empty() at the end (E)";
+    }
+    else  { 
+      checkok = rx->CheckE(errmsg);
+    }
+  }
+  if (!finok || !checkok || !rx) {
+    char buff[128];
+    if (errmsg.length() < 1) {
+      errmsg = "CExpressionEvaluator::ParseString() Error - " ;
+      if (!finok) errmsg += " !finok " ;
+      if (!checkok) errmsg += " !checkok " ;
+      if (!rx)  errmsg += " !rx " ;
+      errmsg += " (F)";
+    }
+    sprintf(buff,"\n CExprError... S=[%s]  (p=%ld , len=%ld)", sex.c_str(), (long)p,(long)len);
+    errmsg += buff;
+    if (rx) delete rx;
+    rx = NULL;
+    while (!sbx.empty()) {
+      delete sbx.top();
+      sbx.pop();
+    }
+  }
+  if (fx) delete fx; 
+  return rx;
+}
+
+}   // End of namespace SOPHYA
+
Index: trunk/SophyaLib/SysTools/cexpre.h
===================================================================
--- trunk/SophyaLib/SysTools/cexpre.h	(revision 2510)
+++ trunk/SophyaLib/SysTools/cexpre.h	(revision 2510)
@@ -0,0 +1,66 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Evaluateur d'expression C   -   R. Ansari 03/2004
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef CEXPREVAL_SEEN
+#define CEXPREVAL_SEEN
+
+#include "machdefs.h"
+#include <iostream>
+#include <string>
+#include "pexceptions.h"
+
+using namespace std;
+namespace SOPHYA {
+
+//! Exception class used by  CExpressionEvaluator
+class CExprException : PException {
+  public:
+  explicit CExprException(const char * m) : PException(m) {}
+  explicit CExprException(const string& m) : PException(m) {}
+};
+
+//--------------------------------------------------------------------
+//! Base class for arithmetic expressions used by CExpressionEvaluator
+class CExprBase {
+public:
+  explicit CExprBase(); 
+  virtual ~CExprBase();
+  virtual double Evaluate() const = 0;
+  virtual bool   CheckE(string& errmsg) const { return true; }
+  virtual void   CheckThrow(const char * msg) const;
+  inline  void   CheckThrow(string const & msg) const { CheckThrow(msg.c_str()); }
+  virtual void   Print(ostream& os) const = 0;
+  static long    NbCreate() { return totnexp_create; }
+  static long    NbDelete() { return totnexp_delete; }
+protected:
+  static long totnexp_create;
+  static long totnexp_delete;
+};
+
+inline ostream& operator << (ostream& s, CExprBase const & ex)
+  {  ex.Print(s);  return(s);  }
+
+class CE_BinExp;
+class CE_FuncExp;
+//---------------------------------------------------------
+//! Class for evaluation of arithmetic expressions with C-like syntax
+class CExpressionEvaluator : public CExprBase {
+public:
+  CExpressionEvaluator(string const & sex);
+  virtual ~CExpressionEvaluator();
+  virtual double Evaluate() const;
+  inline double Value() const { return Evaluate(); }
+  virtual void  Print(ostream& os) const;
+
+protected:
+  CExprBase* ParseString(int extype, string fname, string const & sex, 
+		    size_t off, size_t& stop, string& errmsg);
+
+  CExprBase * _exp;
+};
+
+}   // End of namespace SOPHYA
+
+/* end of ifdef CEXPREVAL_SEEN */
+#endif
Index: trunk/SophyaLib/SysTools/objlist.list
===================================================================
--- trunk/SophyaLib/SysTools/objlist.list	(revision 2509)
+++ trunk/SophyaLib/SysTools/objlist.list	(revision 2510)
@@ -1,2 +1,3 @@
+cexpre.o
 commander.o
 ctimer.o
@@ -6,4 +7,5 @@
 psighand.o
 resusage.o
+rpneval.o
 timing.o
 zthread.o
Index: trunk/SophyaLib/SysTools/rpneval.cc
===================================================================
--- trunk/SophyaLib/SysTools/rpneval.cc	(revision 2510)
+++ trunk/SophyaLib/SysTools/rpneval.cc	(revision 2510)
@@ -0,0 +1,268 @@
+#include "rpneval.h"
+#include <stdlib.h>
+#include "strutilxx.h"
+#include "srandgen.h"
+#include <iostream>
+#include <math.h>
+
+namespace SOPHYA {
+
+/*!
+  \class SOPHYA::RPNExpressionEvaluator
+  \ingroup SysTools
+  Arithmetic expression (double precision float) evaluator 
+  in Reverse Polish Notation (RPN). This is an HP calculator 
+  like syntax. Space are used for separating the string 
+  expression into tokens. 
+*/
+
+RPNExpressionEvaluator::RPNExpressionEvaluator(string const & sex)
+{
+  vector<string> exe;
+  FillVStringFrString(sex, exe, ' ');
+  int rc = EvalRPNExpr(exe, 0);
+  if (rc != 0) throw RPNExprException("RPNExpressionEvaluator() - syntax error");  
+}
+
+RPNExpressionEvaluator::RPNExpressionEvaluator(vector<string> & exe, int off)
+{
+  int rc = EvalRPNExpr(exe, off);
+  if (rc != 0) throw RPNExprException("RPNExpressionEvaluator() - syntax error");
+}
+
+RPNExpressionEvaluator::~RPNExpressionEvaluator()
+{
+}
+
+/* Operations sur le stack RPN */
+/* --Methode-- */
+double RPNExpressionEvaluator::Evaluate() const
+{
+  double x;
+  if ( CheckStack( x) ) 
+    throw RPNExprException("RPNExpressionEvaluator::Evaluate() EmptyStack");
+  else return x;
+}
+  
+/* --Methode-- */
+int RPNExpressionEvaluator::EvalRPNExpr(vector<string> & args, int off)
+{
+  
+  if (args.size() <= off)  return 0;
+  double x,y;
+  x = y = 0.;
+  stack<double> rpnstack_;  // Stack des operations en RPN 
+  for(int k=off; k<args.size(); k++) {
+    // Les 4 operations de base + - * / 
+    if (args[k] == "+") { 
+      if ( CheckStack( x, y) ) return(1);
+      rpnstack_.top() = y+x;
+    }
+    else if (args[k] == "-") { 
+      if ( CheckStack( x, y) ) return(1);
+      rpnstack_.top() = y-x;
+    }
+    else if (args[k] == "*") { 
+      if ( CheckStack( x, y) ) return(1);
+      rpnstack_.top() = y*x;
+    }
+    else if (args[k] == "/") { 
+      if ( CheckStack( x, y) ) return(1);
+      rpnstack_.top() = y/x;
+    }
+    else if (args[k] == "%") { 
+      if ( CheckStack( x, y) ) return(1);
+      rpnstack_.top() = (int)y % (int)x;
+    }
+    // Les constantes : e , pi
+    else if (args[k] == "e") {
+      rpnstack_.push(M_E);
+    }
+    else if (args[k] == "pi") {
+      rpnstack_.push(M_PI);
+    }
+    // Les fonctions usuelles a 1 argument f(x)
+    else if (args[k] == "cos") {
+      if ( CheckStack( x) ) return(1);
+      rpnstack_.top() = cos(x);
+    }
+    else if (args[k] == "sin") {
+      if ( CheckStack( x) ) return(1);
+      rpnstack_.top() = sin(x);
+    }
+    else if (args[k] == "tan") {
+      if ( CheckStack( x) ) return(1);
+      rpnstack_.top() = tan(x);
+    }
+    else if (args[k] == "acos") {
+      if ( CheckStack( x) ) return(1);
+      rpnstack_.top() = acos(x);
+    }
+    else if (args[k] == "asin") {
+      if ( CheckStack( x) ) return(1);
+      rpnstack_.top() = asin(x);
+    }
+    else if (args[k] == "atan") {
+      if ( CheckStack( x) ) return(1);
+      rpnstack_.top() = atan(x);
+    }
+    else if (args[k] == "chs") {
+      if ( CheckStack( x) ) return(1);
+      rpnstack_.top() = -x;
+    }
+    else if (args[k] == "sqrt") {
+      if ( CheckStack( x) ) return(1);
+      rpnstack_.top() = sqrt(x);
+    }
+    else if (args[k] == "sq") {  // x^2 
+      if ( CheckStack( x) ) return(1);
+      rpnstack_.top() = x*x;
+    }
+    else if (args[k] == "log") {
+      if ( CheckStack( x) ) return(1);
+      rpnstack_.top() = log(x);
+    }
+    else if (args[k] == "log10") {
+      if ( CheckStack( x) ) return(1);
+      rpnstack_.top() = log10(x);
+    }
+    else if (args[k] == "exp") {
+      if ( CheckStack( x) ) return(1);
+      rpnstack_.top() = exp(x);
+    }
+    else if (args[k] == "fabs") {
+      if ( CheckStack( x) ) return(1);
+      rpnstack_.top() = fabs(x);
+    }
+    else if (args[k] == "floor") {
+      if ( CheckStack( x) ) return(1);
+      rpnstack_.top() = floor(x);
+    }
+    else if (args[k] == "ceil") {
+      if ( CheckStack( x) ) return(1);
+      rpnstack_.top() = ceil(x);
+    }
+    // trunc et nint vire - ca ne compile pas sous linux - Reza 01/2003
+    else if (args[k] == "deg2rad") {
+      if ( CheckStack( x) ) return(1);
+      rpnstack_.top() = x*M_PI/180.;
+    }
+    else if (args[k] == "rad2deg") {
+      if ( CheckStack( x) ) return(1);
+      rpnstack_.top() = x*180./M_PI;
+    }
+    // Les fonctions usuelles a 2 argument f(x,y)
+    else if (args[k] == "pow") { 
+      if ( CheckStack( x, y) ) return(1);
+      rpnstack_.top() = pow(y,x);
+    }
+    else if (args[k] == "atan2") { 
+      if ( CheckStack( x, y) ) return(1);
+      rpnstack_.top() = atan2(x,y);
+    }
+    // generateur aleatoire
+    else if (args[k] == "rand") { 
+      double rnd = drand01();
+      rpnstack_.push(rnd);
+    }
+    else if (args[k] == "norand") { 
+      double rnd = GauRnd(0., 1.);
+      rpnstack_.push(rnd);
+    }
+    // Fonction a N arguments  - Somme, produit, etc ...
+    else if ((args[k] == "sum") || (args[k] == "mean") || (args[k] == "sigmean") || 
+	     (args[k] == "sigma") || (args[k] == "sigma2") ) {
+      double sx, sx2;
+      int nn = SumStack( sx, sx2);
+      if (args[k] == "sum") rpnstack_.push(sx);
+      else { 
+	if (nn == 0) return 1;
+	double fnn = nn;
+	if ((args[k] == "sigma") || (args[k] == "sigmean")) 
+	  rpnstack_.push(sqrt(sx2/fnn-(x*x/(fnn*fnn))));
+	else if ((args[k] == "mean") || (args[k] == "sigmean"))  rpnstack_.push(sx/fnn);
+	else rpnstack_.push(sx2/fnn-(x*x/(fnn*fnn)));
+      }
+    }
+    else if (args[k] == "product") { 
+      double px;
+      int nn = ProductStack( px);
+      if (nn == 0) return(1);
+      rpnstack_.push(px);
+    }
+    // Fonctions de manipulation de stack
+    else if (args[k] == "print") { 
+      PrintStack();
+    }
+    else if (args[k] == "x<>y") {
+      if ( CheckStack( x, y) ) return(1);
+      rpnstack_.top() = x;  rpnstack_.push(y);
+    }
+    else if (args[k] == "pop") {
+      rpnstack_.pop();
+    }
+    else if (args[k] == "push") {
+      if (rpnstack_.empty()) rpnstack_.push(0.);
+      else rpnstack_.push(rpnstack_.top());
+    }
+    // On met un nombre sur le stack 
+    else {
+      char * esptr;
+      x = strtod(args[k].c_str(), &esptr);
+      //      if (ctof(args[k].c_str(),&x) < 0) {
+      if (esptr == args[k].c_str()) return 2; 
+      rpnstack_.push(x);
+    }
+
+  }
+  return(0);
+}
+
+inline void RPNExpressionEvaluator::PrintStack()
+{
+  if (rpnstack_.empty()) 
+    cout << "RPNExpressionEvaluator::PrintStack() Empty stack " << endl;
+  else {
+    stack<double> s;
+    s = rpnstack_;
+    int k = 0;
+    cout << "RPNExpressionEvaluator::PrintStack() Size()= " << s.size() << endl;
+    while( !s.empty() ) {
+      cout << "    " << k << ":  " << s.top() << "  ";
+      if (k == 0)  cout << " (x) " << endl;
+      else if (k == 1) cout << " (y) " << endl;
+      else if (k == 2) cout << " (z) " << endl;
+      else cout << endl;
+      s.pop(); k++;
+    }
+  }
+  
+} 
+
+int RPNExpressionEvaluator::SumStack(double& sx, double& sx2) 
+{
+  sx = sx2 = 0.;
+  int nn = 0;
+  double x = 0.;
+  while( !rpnstack_.empty() ) {
+    x = rpnstack_.top(); rpnstack_.pop();
+    sx += x; sx2 += x*x;
+    nn++;
+  } 
+  return(nn);  
+}
+
+int RPNExpressionEvaluator::ProductStack(double& px) 
+{
+  px = 1.;
+  int nn = 0;
+  double x = 0.;
+  while( !rpnstack_.empty() ) {
+    x = rpnstack_.top(); rpnstack_.pop();
+    px *= x;  nn++;
+  } 
+  return(nn);  
+}
+
+
+} // End of namespace SOPHYA
Index: trunk/SophyaLib/SysTools/rpneval.h
===================================================================
--- trunk/SophyaLib/SysTools/rpneval.h	(revision 2510)
+++ trunk/SophyaLib/SysTools/rpneval.h	(revision 2510)
@@ -0,0 +1,61 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Classe Evaluateur RPN (HP like)
+//           Mars 2004: Extrait de commander.cc
+// LAL-IN2P3/CNRS  DAPNIA/CEA
+
+#ifndef RPNEVALUATOR_H_SEEN
+#define RPNEVALUATOR_H_SEEN
+
+#include "machdefs.h"
+#include "pexceptions.h"
+#include <string>
+#include <vector>
+#include <stack>
+
+namespace SOPHYA {
+
+//! Exception class used by  RPNExpressionEvaluator
+
+class RPNExprException : public PException {
+  public:
+  explicit RPNExprException(const char * m) : PException(m) {}
+  explicit RPNExprException(const string& m) :  PException(m) {}
+};
+
+
+//! Class for evaluation of arithmetic expressions in RPN (Reverse Polish Notation)
+class RPNExpressionEvaluator {
+public:
+  explicit RPNExpressionEvaluator(string const & sex);
+  explicit RPNExpressionEvaluator(vector<string> & exe, int off=0);
+  virtual ~RPNExpressionEvaluator();
+  virtual double Evaluate() const;  // Return the value of the stack top
+  inline double Value() const { return Evaluate(); }
+
+protected:
+  int EvalRPNExpr(vector<string> & args, int off=0);
+  inline bool CheckStack(double& x) const 
+  {  
+    if (rpnstack_.empty()) return true; 
+    else { x = rpnstack_.top();  return false; }
+  }
+  inline bool CheckStack(double& x, double& y)
+  {
+    if (rpnstack_.size() < 2) return true; 
+    else { 
+      x = rpnstack_.top(); rpnstack_.pop(); 
+      y = rpnstack_.top();  return false; 
+    }
+  }
+
+  void PrintStack();
+  int SumStack(double& sx, double& sx2);
+  int ProductStack(double& px); 
+  
+  stack<double> rpnstack_;
+};
+
+} // namespace SOPHYA
+
+/* end of ifdef  RPNEVALUATOR_H_SEEN */
+#endif
