Example #1
0
int CEvaluator::getArgumentValue(const string& name){
	if(m_vContext.size()>0) 
	{
		if(m_vContext.back()->find(name)==m_vContext.back()->end()){
			throw(EvaluationError("argument \""+name+"\" does not have an associated value."));
		}
		return (*m_vContext.back())[name];
	}
	throw(EvaluationError("getArgumentValue(): no argument defined."));
}
Example #2
0
 /// Add a new sample / observation pair
 /// - does not update the model!
 /// - we don't add NaN and inf observations
 void add_new_sample(const Eigen::VectorXd& s, const Eigen::VectorXd& v)
 {
     if (tools::is_nan_or_inf(v))
         throw EvaluationError();
     _samples.push_back(s);
     _observations.push_back(v);
 }
Example #3
0
void CEvaluator::visit ( CApply* e )
{
	CFunction *f= getFunction(e->getFunction());
	if(!f) {
		throw(EvaluationError("function \""+e->getFunction()+"\" is not defined."));
	}
	if(!f || (f->getNumArguments() != e->getNumArguments())) {
		throw(EvaluationError("number of arguments for function \""+e->getFunction()+"\" does not match declaration."));
	}
	map<string,int> *newContext= new map<string,int>();
	for(int i=0; i<f->getNumArguments();i++) {
		string tmp=f->getArgument(i)->getName();
		e->getArgument(i)->accept(this);
		int value=result;
	//	cout << "  "<< tmp <<"="<<value<<endl;
		(*newContext)[tmp]=value;
	}
	pushContext(newContext);
	CExpr *e2 = f->getExpression();
	e2->accept(this);
	delete popContext();
	//return result;
}
Example #4
0
void CEvaluator::visit ( CFunction* e )
{
	throw EvaluationError("tried to visit function"+e->getName());
}