14 #ifndef INCLUDED_numeric_expression_parser_Arithmetic_HH
15 #define INCLUDED_numeric_expression_parser_Arithmetic_HH
35 namespace expression_parser {
107 std::string
name()
const;
108 void name( std::string
const & name );
127 std::string
name()
const;
128 void name( std::string
const & name );
176 std::string
print()
const;
606 std::map< std::string, VariableExpressionOP >
657 std::list< std::string >
680 std::list< std::string >
700 std::string
name()
const;
708 std::list< std::string >
727 std::list< std::string >
749 std::list< std::string >
894 std::list< std::string >
915 std::list< std::string >
937 std::list< std::string >
962 std::list< std::string >
1144 std::list< std::string >
virtual void visit(ASTVisitor &visitor) const
void set_value(numeric::Real value)
std::list< ArithmeticASTNodeCOP >::const_iterator children_begin() const
virtual ExpressionCOP differentiate(std::string const &varname) const
Returns the expression for the partial derivative of this expression by the variable named varname...
ArithmeticASTNodeCOP child_
void set_token_type(TokenType type)
utility::pointer::shared_ptr< Expression const > ExpressionCOP
std::list< ArithmeticASTNodeCOP > children_
virtual ExpressionCOP differentiate(std::string const &varname) const
Returns the expression for the partial derivative of this expression by the variable named varname...
std::string print() const
ExpressionCOP semi_constructed_expression_
std::string ast_string(ArithmeticASTNode const &node)
std::map< std::string, VariableExpressionOP > variables() const
virtual ExpressionCOP differentiate(std::string const &varname) const
Returns the expression for the partial derivative of this expression by the variable named varname...
std::ostringstream ostrstream_
void add_variable(std::string const &varname)
std::map< std::string, numeric::Size > functions_
utility::pointer::shared_ptr< Token const > TokenCOP
void log_error() const
print the contents of functions_ and variables_ to std error
virtual std::string to_string() const =0
std::list< ArithmeticASTNodeCOP >::const_iterator children_end() const
virtual ExpressionCOP differentiate(std::string const &varname) const
Returns the expression for the partial derivative of this expression by the variable named varname...
virtual std::string to_string() const
virtual ExpressionCOP differentiate(std::string const &varname) const
Returns the expression for the partial derivative of this expression by the variable named varname...
virtual ~TokenSet()
Automatically generated virtual destructor for class deriving directly from ReferenceCount.
utility::keys::KeyLookup< KeyType >::const_iterator const_iterator
Key collection iterators.
virtual ExpressionCOP differentiate(std::string const &varname) const =0
Returns the expression for the partial derivative of this expression by the variable named varname...
ReferenceCount base class – dispatch class.
Double-dispatch visitor pattern for abstract syntax tree.
TokenType rest_expression_token() const
virtual void visit(ASTVisitor &visitor) const =0
bool empty() const
Are there no more tokens remaining?
virtual numeric::Real operator()() const
virtual ExpressionCOP differentiate(std::string const &varname) const
Returns null, since the derivative for a literal is always zero.
numeric::Real literal_value() const
std::string variable_name() const
void decrement_indentation()
numeric::Real value() const
void pretty(bool setting)
numeric::Size nargs() const
virtual void visit(ASTVisitor &visitor) const
TokenType rest_expression_token_
virtual numeric::Real operator()() const
std::list< ArithmeticASTNodeCOP >::const_iterator children_begin() const
virtual numeric::Real operator()() const
Returns the difference between expression 1 and expression 2.
SimpleExpressionCreator parent
void increment_indentation()
virtual ~ArithmeticASTNode()
Automatically generated virtual destructor for class deriving directly from ReferenceCount.
std::list< ArithmeticASTNodeCOP > children_
virtual void visit(ASTVisitor &visitor) const
virtual void visit(ArithmeticASTExpression const &)
virtual ~ASTVisitor()
Automatically generated virtual destructor for class deriving directly from ReferenceCount.
std::map< std::string, VariableExpressionOP > variables_
void add_standard_functions()
Add the functions min, max and sqrt.
LiteralTokenOP scan_literal(std::string const &input_string) const
virtual void parse(TokenSet &tokens)
virtual ~EqualsExpression()
utility::vector1< ExpressionCOP > expressions_
ExpressionCOP then_expression() const
std::list< ArithmeticASTNodeCOP > children_
std::list< TokenCOP >::iterator curr_pos_
virtual numeric::Real operator()() const
virtual numeric::Real operator()() const
virtual TokenType type() const
virtual numeric::Real operator()() const
Returns the min of e1 and e2.
ExpressionCOP else_expression_
TokenSetOP scan(std::string const &input_string)
void finish_indented_line()
utility::pointer::shared_ptr< Token > TokenOP
virtual ExpressionCOP differentiate(std::string const &varname) const
Returns the expression for the partial derivative of this expression by the variable named varname...
virtual ExpressionCOP handle_variable_expression(ArithmeticASTValue const &)
Factory method to be implemented by derived classes which may wish to handle variable expressions in ...
virtual ExpressionCOP differentiate(std::string const &varname) const
virtual std::string to_string() const
virtual TokenType type() const
virtual numeric::Real operator()() const =0
TokenType rest_term_token_
virtual std::list< std::string > active_variables() const
Base class for reference-counted polymorphic classes.
Traverse the AST and print it to standard out.
void append(TokenCOP token)
virtual ExpressionCOP differentiate(std::string const &varname) const
Returns the expression for the partial derivative of this expression by the variable named varname...
virtual void visit(ASTVisitor &visitor) const
BooleanExpressionScanner()
virtual numeric::Real operator()() const
Returns the sum of expression 1 and expression 2.
virtual numeric::Real operator()() const
utility::pointer::shared_ptr< ArithmeticASTNode const > ArithmeticASTNodeCOP
virtual std::list< std::string > active_variables() const
std::list< ArithmeticASTNodeCOP > children_
SimpleExpressionCreator()
virtual void parse(TokenSet &tokens)
virtual ExpressionCOP differentiate(std::string const &varname) const
Returns the expression for the partial derivative of this expression by the variable named varname...
std::list< ArithmeticASTNodeCOP > children_
virtual numeric::Real operator()() const
virtual void parse(TokenSet &tokens)
virtual numeric::Real operator()() const
virtual void visit(ASTVisitor &visitor) const
virtual ExpressionCOP handle_variable_expression(ArithmeticASTValue const &)
Factory method to be implemented by derived classes which may wish to handle variable expressions in ...
virtual void visit(ArithmeticASTExpression const &)
void set_value(numeric::Real value)
utility::pointer::shared_ptr< TokenSet > TokenSetOP
ExpressionCOP last_constructed_expression_
std::string token_type_name(TokenType tt)
bool last_dispatch_to_unknown_type_
virtual void parse(TokenSet &tokens)
virtual void visit(ASTVisitor &visitor) const
virtual ExpressionCOP differentiate(std::string const &varname) const
Returns the literal expression 1 if name_ == varname_ and null otherwise.
ExpressionCOP parse_string_to_boolean_expression(std::string const &input_string)
virtual TokenType type() const =0
virtual ~GTE_Expression()
rosetta project type declarations. Should be kept updated with core/types.hh. This exists because num...
Greater Than or Equal To.
Class to traverse the abstract syntax tree produced by the parsing of a properly-formed string in the...
virtual numeric::Real operator()() const
utility::pointer::shared_ptr< VariableExpression > VariableExpressionOP
virtual ExpressionCOP handle_function_expression(FunctionTokenCOP function, utility::vector1< ExpressionCOP > const &args)
Factory method to be implemented by derived classes which may wish to handle function expressions in ...
virtual numeric::Real operator()() const
Returns the max of e1 and e2.
virtual numeric::Real operator()() const
virtual ~LTE_Expression()
virtual numeric::Real operator()() const
ExpressionCOP parse_string_to_expression(std::string const &input_string)
virtual ExpressionCOP differentiate(std::string const &varname) const
Returns the expression for the partial derivative of this expression by the variable named varname...
void log_error() const
Print contents after parser has encountered an error.
virtual numeric::Real operator()() const
Returns the product of expression 1 and expression 2.
ExpressionCOP else_expression() const
TokenType rest_term_token() const
std::list< ArithmeticASTNodeCOP >::const_iterator children_begin() const
BooleanExpressionCreator()
virtual ExpressionCOP differentiate(std::string const &varname) const
Returns the expression for the partial derivative of this expression by the variable named varname...
utility::pointer::shared_ptr< FunctionToken const > FunctionTokenCOP
ArithmeticScanner()
Constructor which adds the "standard" set of min, max and sqrt functions.
virtual ExpressionCOP differentiate(std::string const &varname) const
Returns the expression for the partial derivative of this expression by the variable named varname...
std::list< ArithmeticASTNodeCOP >::const_iterator children_begin() const
ExpressionCOP create_expression_tree(ArithmeticASTExpression const &)
FunctionTokenCOP function_
virtual TokenType type() const
std::string variable_name_
vector1: std::vector with 1-based indexing
virtual ~Expression()
Automatically generated virtual destructor for class deriving directly from ReferenceCount.
TokenOP scan_identifier(std::string const &input_string) const
virtual void parse(TokenSet &tokens)
ExpressionCOP condition() const
VariableExpression(std::string const &name)
either a variable or a literal.
std::list< ArithmeticASTNodeCOP >::const_iterator children_end() const
virtual void parse(TokenSet &tokens)
std::list< ArithmeticASTNodeCOP >::const_iterator children_end() const
virtual ~Token()
Automatically generated virtual destructor for class deriving directly from ReferenceCount.
virtual std::list< std::string > active_variables() const
void add_function(std::string const &name, numeric::Size nargs)
virtual ExpressionCOP differentiate(std::string const &varname) const
Returns the expression for the partial derivative of this expression by the variable named varname...
virtual void visit(ArithmeticASTExpression const &)=0
virtual ExpressionCOP differentiate(std::string const &varname) const
virtual numeric::Real operator()() const
virtual std::list< std::string > active_variables() const =0
std::list< ArithmeticASTNodeCOP >::const_iterator children_end() const
void add_variable(std::string const &name)
std::list< TokenCOP > tokens_
rule< Scanner, string_closure::context_t > name
virtual ExpressionCOP differentiate(std::string const &varname) const
Returns the expression for the partial derivative of this expression by the variable named varname...
virtual ExpressionCOP differentiate(std::string const &varname) const
Returns the expression for the partial derivative of this expression by the variable named varname...
virtual numeric::Real operator()() const
std::list< ArithmeticASTNodeCOP >::const_iterator children_end() const
virtual std::list< std::string > active_variables() const
virtual std::string to_string() const
Parse tree for arithmetic operations class forward declarations.
virtual std::list< std::string > active_variables() const
virtual ExpressionCOP handle_function_expression(FunctionTokenCOP function, utility::vector1< ExpressionCOP > const &args)
Factory method to be implemented by derived classes which may wish to handle function expressions in ...
VariableExpressionOP get_variable(std::string const &varname)
virtual std::list< std::string > active_variables() const
AbsoluteValueExpression()
Base class for Abstract Syntax Tree (AST) for the simple Arithmetic language defined here...
virtual void parse(TokenSet &tokens)
void print_to_curr_pos() const
in the event of an error message, print the tokens up to the current token.
void set_expression(ExpressionCOP ex)
utility::pointer::shared_ptr< LiteralToken > LiteralTokenOP
std::list< ArithmeticASTNodeCOP >::const_iterator children_begin() const
ITEExpression(ExpressionCOP condition, ExpressionCOP then_clause, ExpressionCOP else_clause)
virtual ~ArithmeticScanner()
Automatically generated virtual destructor for class deriving directly from ReferenceCount.
virtual TokenType type() const
virtual void visit(ASTVisitor &visitor) const
EXPRESSION.
virtual ExpressionCOP differentiate(std::string const &varname) const
Returns the expression for the partial derivative of this expression by the variable named varname...
virtual numeric::Real operator()() const
Returns the quotient of expression 1 and expression 2.
virtual std::list< std::string > active_variables() const
virtual std::string to_string() const
std::map< std::string, numeric::Size > variables_
ArithmeticASTNodeCOP child() const
ExpressionCreator grandparent
numeric::Real literal_value_
Pure virtual base class to define arbitrary expressions for scripting arithmetic operations (e...
ArithmeticASTRestExpression()
virtual numeric::Real operator()() const
void set_second_expression(ExpressionCOP e2)
ExpressionCOP then_expression_
void set_first_expression(ExpressionCOP e1)