43#include <boost/function.hpp>
44#include <boost/shared_ptr.hpp>
45#include <boost/phoenix/core.hpp>
46#include <boost/phoenix/function.hpp>
47#include <boost/phoenix/operator.hpp>
89 void SetValue(
double dval,
unsigned idx);
102 void SetError(
double dval,
unsigned idx);
173 template <
typename PErrorHandler>
176 using namespace boost::phoenix::arg_names;
177 namespace phx = boost::phoenix;
178 using boost::phoenix::function;
180 "**ERROR** ", _2, phx::cref(error_handler_.
iters)[_1]);
273 std::vector<double> &val,
274 std::vector<double> &err);
280 void add_var(std::string
const& name);
287 bool find_var(std::string
const &name);
295 bool find_var(std::string
const &name,
unsigned int &idx);
305 std::string
pos_to_var(std::string
const &name,
bool &ok);
318 void(
int tag, std::string
const& what)>
455 unsigned int find_var(std::string
const &name);
The PVarHandler class manages variable data during evaluation.
void SetName(std::string name)
Sets the variable name.
std::string GetName()
Gets the variable name.
std::vector< double > fError
Vector of error values (one per run)
std::vector< double > GetError()
Gets all error values.
std::string fName
Variable name.
std::vector< double > GetValue()
Gets all values.
PVarHandler()
Default constructor initializing an unnamed variable.
void SetError(std::vector< double > &dval)
Sets all error values for this variable.
double GetValue(unsigned int idx)
Gets a single value at a specific index.
unsigned int GetSize()
Gets the size of the variable data.
double GetError(unsigned int idx)
Gets a single error value at a specific index.
std::vector< double > fValue
Vector of values (one per run)
void SetValue(std::vector< double > &dval)
Sets all values for this variable.
std::list< statement > statement_list
Type alias for a list of statements forming a program.
boost::variant< variable_declaration, assignment > statement
Variant type representing a single statement.
The PErrorHandler struct handles parsing and semantic errors.
std::vector< Iterator > iters
Vector mapping AST node IDs to source positions (used by PAnnotation)
Represents an assignment statement.
Represents a complete expression with operator precedence.
Represents a function call with a single argument.
Represents an empty/null AST node.
Represents a binary operation with an operator and right operand.
Represents a power operation.
Represents a unary operation applied to an operand.
Represents a variable declaration with optional initialization.
Represents a variable in an expression.
std::vector< double > result_type
Return type for all visitor methods (vector of values)
PProgEval(std::vector< PVarHandler > var)
Constructor that initializes the evaluator with variables.
unsigned int find_var(std::string const &name)
Finds a variable index by name.
std::vector< double > operator()(ast::nil)
Evaluates a nil node (should never be called).
void print_result()
Prints all variable results to standard output (debugging).
std::vector< PVarHandler > fVariable
Variable table with values and errors.
PVarHandler getVar(const std::string name, bool &ok)
Retrieves a variable by name after evaluation.
bool find_var(std::string const &name)
Checks if a variable exists in the symbol table.
std::vector< PVarHandler > fVariable
Symbol table of declared variables.
bool result_type
Return type for all visitor methods.
std::string pos_to_var(std::string const &name, bool &ok)
Converts position-based variable reference to variable name.
PProgram(PErrorHandler &error_handler_)
Constructor that sets up the error handler.
std::vector< PVarHandler > getVars()
Gets all variables from the symbol table.
void add_predef_var_values(const std::string &name, std::vector< double > &val, std::vector< double > &err)
Injects predefined variable values from collection data.
std::map< int, std::string > fVarPos
Map from position index to variable name.
boost::function< void(int tag, std::string const &what)> error_handler
Error handler function for reporting semantic errors.
void add_var(std::string const &name)
Adds a variable to the symbol table.
bool operator()(ast::nil)
Visitor for nil AST nodes (should never be called).