ExpressionTreeWalker Class Reference

An evaluator for arithmetic expressions. More...

#include <ExpressionTreeWalker.hpp>

Inherits ExpressionParserTokenTypes.

Collaboration diagram for ExpressionTreeWalker:

Collaboration graph
[legend]

List of all members.

Public Member Functions

void setUtilities (class UAPUtilities *_utilities)
 Sets the UAPUtilities object to use to resolve parameters.
void setContext (class UAPNode *_context=NULL)
 Sets the UAPNode object to use to resolve attributes of an element.
void setMathConstants (const std::map< std::string, double > &_mathConstants)
 Sets the map of mathematical constants to use during evaluation.
double evaluate (ANTLR_USE_NAMESPACE(antlr) RefAST _t)
 Evaluates an expression to a double-precision constant.
double evaluate_function (ANTLR_USE_NAMESPACE(antlr) RefAST _t)
 Evaluates a function call to a double-precision constant.
std::string subs_params (ANTLR_USE_NAMESPACE(antlr) RefAST _t)
 Substitutes the corresponding values for any named parameters and/or AML paths in the expression.
void twConst (ANTLR_USE_NAMESPACE(antlr) RefAST _t)
 Substitutes the corresponding value for any named parameter.
std::string amlPath (ANTLR_USE_NAMESPACE(antlr) RefAST _t)
 Evaluates an AML path to an arithmetic expression that can be further evaluated.


Detailed Description

An evaluator for arithmetic expressions.

(You can use this standalone, but you should really only use this class with the Universal Accelerator Parser library). Reads a TokenStream and invokes the appropriate methods in this class.

Once you instantiate the tree walker, you must call the methods setContext (with or without an argument), and setUtilities with an instance of UAPUtilities.

The evaluate method evaluates an expression.

See also:
antlr::TokenStream

Definition at line 49 of file ExpressionTreeWalker.hpp.


Member Function Documentation

std::string ExpressionTreeWalker::amlPath ( ANTLR_USE_NAMESPACE(antlr) RefAST  _t  ) 

Evaluates an AML path to an arithmetic expression that can be further evaluated.

Definition at line 792 of file ExpressionTreeWalker.cpp.

double ExpressionTreeWalker::evaluate ( ANTLR_USE_NAMESPACE(antlr) RefAST  _t  ) 

Evaluates an expression to a double-precision constant.

Definition at line 23 of file ExpressionTreeWalker.cpp.

double ExpressionTreeWalker::evaluate_function ( ANTLR_USE_NAMESPACE(antlr) RefAST  _t  ) 

Evaluates a function call to a double-precision constant.

Definition at line 220 of file ExpressionTreeWalker.cpp.

void ExpressionTreeWalker::setContext ( class UAPNode _context = NULL  )  [inline]

Sets the UAPNode object to use to resolve attributes of an element.

Parameters:
_context the UAPNode object
See also:
UAPNode

Definition at line 77 of file ExpressionTreeWalker.hpp.

void ExpressionTreeWalker::setMathConstants ( const std::map< std::string, double > &  _mathConstants  )  [inline]

Sets the map of mathematical constants to use during evaluation.

Parameters:
_mathConstants the map of <string, double> pairs of mathematical constants.

Definition at line 84 of file ExpressionTreeWalker.hpp.

void ExpressionTreeWalker::setUtilities ( class UAPUtilities _utilities  )  [inline]

Sets the UAPUtilities object to use to resolve parameters.

Parameters:
_utilities the UAPUtilities object
See also:
UAPUtilities

Definition at line 69 of file ExpressionTreeWalker.hpp.

std::string ExpressionTreeWalker::subs_params ( ANTLR_USE_NAMESPACE(antlr) RefAST  _t  ) 

Substitutes the corresponding values for any named parameters and/or AML paths in the expression.

Definition at line 501 of file ExpressionTreeWalker.cpp.

void ExpressionTreeWalker::twConst ( ANTLR_USE_NAMESPACE(antlr) RefAST  _t  ) 

Substitutes the corresponding value for any named parameter.

Definition at line 731 of file ExpressionTreeWalker.cpp.


Generated on Fri Feb 12 15:47:57 2010 for Universal Accelerator Parser by  doxygen 1.5.7