2008-08-08 00:01:22 +00:00
|
|
|
#ifndef EXPRESSOR_H
|
|
|
|
#define EXPRESSOR_H
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <boost/noncopyable.hpp>
|
|
|
|
#include <boost/function.hpp>
|
|
|
|
|
|
|
|
#include "aftypes.h"
|
|
|
|
|
2008-08-08 03:23:34 +00:00
|
|
|
namespace afp {
|
|
|
|
|
2008-08-08 00:01:22 +00:00
|
|
|
struct parser_grammar;
|
|
|
|
|
|
|
|
struct expressor : boost::noncopyable {
|
2008-08-08 03:23:34 +00:00
|
|
|
typedef boost::function<datum (std::vector<datum>)> func_t;
|
2008-08-08 00:01:22 +00:00
|
|
|
|
|
|
|
expressor();
|
|
|
|
~expressor();
|
|
|
|
|
2008-08-08 03:23:34 +00:00
|
|
|
datum evaluate(std::string const &expr) const;
|
2008-08-08 00:01:22 +00:00
|
|
|
|
2008-08-08 03:23:34 +00:00
|
|
|
void add_variable(std::string const &name, datum value);
|
2008-08-08 00:01:22 +00:00
|
|
|
void add_function(std::string const &name, func_t value);
|
|
|
|
|
|
|
|
private:
|
|
|
|
parser_grammar *grammar_;
|
|
|
|
};
|
|
|
|
|
2008-08-08 03:23:34 +00:00
|
|
|
} // namespace afp
|
|
|
|
|
2008-08-08 00:01:22 +00:00
|
|
|
#endif /* !EXPRESSOR_H */
|