33 namespace expression_parser {
58 return "INVALID_TOKEN_TYPE";
74 return "SUBTRACT_SYMBOL";
76 return "MULTIPLY_SYMBOL";
78 return "DIVIDE_SYMBOL";
80 return "ERROR IN token_type_name -- unrecognized token type!";
88 return c >=
'0' && c <=
'9';
93 return ( c >=
'a' && c <=
'z' ) || ( c >=
'A' && c <=
'Z' );
138 return "VARIABLE(" +
name_ +
")";
259 std::ostringstream ostream;
260 ostream <<
"Tokens:\n";
263 iter != iter_end; ++iter ) {
264 ostream << (*iter)->to_string() <<
"\n";
266 return ostream.str();
272 std::cerr <<
"TokenSet parsing error" << std::endl;
276 iter != iter_end; ++iter ) {
278 std::cerr << count <<
": " << (*iter)->to_string() << std::endl;
303 if ( name.size() == 0 ) {
306 utility_exit_with_message(
"Error in ArithmeticScanner::add_variable. Illegal variable name beginning with a numeral: " + name );
312 utility_exit_with_message(
"Error in ArithmeticScanner::add_variable. Variable name conflicts with already added function name: " + name );
314 variables_.insert( std::make_pair( name, 1 ));
318 std::string
const &
name,
322 if ( name.size() == 0 ) {
325 utility_exit_with_message(
"Error in ArithmeticScanner::add_function. Illegal function name beginning with a numeral: " + name );
326 }
else if ( nargs == 0 ) {
330 utility_exit_with_message(
"Error in ArithmeticScanner::add_function. Function name has already conflicts with already added variable name: " + name );
336 functions_.insert( std::make_pair( name, nargs ));
343 Size pos_token_begin( 0 ), pos_curr( 0 );
344 bool scanning_literal =
false;
345 while ( pos_curr <= input_string.size() ) {
347 if ( pos_token_begin != pos_curr ) {
349 if ( scanning_literal ) {
351 if ( pos_curr == input_string.size() ) {
354 char curr_char = input_string[ pos_curr ];
355 if ( curr_char ==
' ' || curr_char ==
'(' ||
356 curr_char ==
')' || curr_char ==
',' ||
357 curr_char ==
'+' || curr_char ==
'*' ||
358 curr_char ==
'/' || curr_char ==
'\t' ) {
360 }
else if ( curr_char ==
'-' ) {
363 assert( pos_curr > 0 );
364 if ( pos_token_begin + 1 != pos_curr &&
365 input_string[ pos_curr - 1 ] ==
'e' &&
366 pos_curr + 1 < input_string.size() &&
367 is_numeral( input_string[ pos_curr + 1 ] ) ) {
374 std::string literal_string = input_string.substr( pos_token_begin, pos_curr - pos_token_begin );
376 pos_token_begin = pos_curr;
382 if ( pos_curr == input_string.size() ) {
385 char curr_char = input_string[ pos_curr ];
386 if ( curr_char ==
' ' || curr_char ==
'(' ||
387 curr_char ==
')' || curr_char ==
',' ||
388 curr_char ==
'+' || curr_char ==
'*' ||
389 curr_char ==
'/' || curr_char ==
'-' || curr_char ==
'\t' ) {
395 std::string identifier_string = input_string.substr( pos_token_begin, pos_curr - pos_token_begin );
397 pos_token_begin = pos_curr;
402 }
else if ( pos_curr == input_string.size() ) {
404 }
else if ( input_string[ pos_curr ] !=
' ' && input_string[ pos_curr ] !=
'\t' ) {
405 scanning_literal =
false;
407 if ( input_string[ pos_curr ] ==
'(' ) {
410 }
else if ( input_string[ pos_curr ] ==
')' ) {
413 }
else if ( input_string[ pos_curr ] ==
',' ) {
416 }
else if ( input_string[ pos_curr ] ==
'+' ) {
419 }
else if ( input_string[ pos_curr ] ==
'-' ) {
420 if ( pos_curr + 1 < input_string.size() &&
421 (
is_numeral(input_string[ pos_curr + 1 ]) || input_string[ pos_curr + 1 ] ==
'.') ) {
422 scanning_literal =
true;
423 pos_token_begin = pos_curr;
428 }
else if ( input_string[ pos_curr ] ==
'*' ) {
431 }
else if ( input_string[ pos_curr ] ==
'/' ) {
434 }
else if (
is_numeral( input_string[ pos_curr ] ) ) {
435 scanning_literal =
true;
436 pos_token_begin = pos_curr;
437 }
else if (
is_letter( input_string[ pos_curr ] ) || input_string[ pos_curr ] ==
'$' ) {
438 pos_token_begin = pos_curr;
459 bool found_e =
false;
bool found_point =
false;
460 for (
Size ii = 0;
ii < input_string.size(); ++
ii ) {
462 if ( input_string[ ii ] ==
'e' || input_string[ ii ] ==
'E' ) {
471 if ( input_string[ ii ] ==
'.' ) {
472 if ( ! found_point ) {
480 if ( input_string[ ii ] ==
'-' ) {
482 ( ii + 1 < input_string.size() &&
is_numeral( input_string[ ii + 1 ] ) &&
483 ( input_string[ ii-1 ] ==
'e' || input_string[ ii-1 ] ==
'E' )) ) {
498 if ( input_string.size() == 0 ) {
502 if ( !
is_letter( input_string[ 0 ] ) && input_string[ 0 ] !=
'$' ) {
506 for (
Size ii = 1;
ii < input_string.size(); ++
ii ) {
507 char iichar = input_string[
ii ];
524 utility_exit_with_message(
"Error in scan_identifier: Failed to find input_string in either variables_ or functions_ maps\n" + input_string );
531 std::cerr <<
"An error has occurred. ArithmeticScanner contents: " << std::endl;
534 iter != iter_end; ++iter ) {
535 std::cerr <<
"variable: " << iter->first << std::endl;
539 iter != iter_end; ++iter ) {
540 std::cerr <<
"functions: " << iter->first <<
" #args: " << iter->second << std::endl;
567 visitor.
visit( *
this );
573 if ( tokens.
empty() ) {
580 child1->parse( tokens );
583 child2->parse( tokens );
606 visitor.
visit( *
this );
612 if ( tokens.
empty() ) {
617 if ( ! tokens.
empty() ) {
624 function_ =
FunctionTokenCOP( utility::pointer::dynamic_pointer_cast< numeric::expression_parser::FunctionToken const > ( toptoken ) );
629 if ( func_nargs == 0 ) {
644 exp->parse( tokens );
645 if ( tokens.
top()->type() !=
COMMA ) {
650 assert( tokens.
top()->type() ==
COMMA );
656 exp->parse( tokens );
690 visitor.
visit( *
this );
697 if ( tokens.
empty() ) {
702 factor->parse( tokens );
705 rest_term->parse( tokens );
726 visitor.
visit( *
this );
735 func->parse( tokens );
739 val->parse( tokens );
744 exp->parse( tokens );
765 is_literal_( false ),
766 literal_value_( 0.0 ),
767 variable_name_(
"UNASSIGNED_VARIABLE_NAME" )
775 visitor.
visit( *
this );
781 if ( tokens.
empty() ) {
789 if ( vartok->name() ==
"UNASSIGNED_VARIABLE_NAME" ) {
790 utility_exit_with_message(
"Illegal variable name in ArithmeticASTValue -- UNASSIGNED_VARIABLE_NAME is a reserved string" );
794 }
else if ( toptoken ==
LITERAL ) {
814 utility_exit_with_message(
"Illegal access of literal_value() for ArithmeticASTValue that is not a literal (and is instead a variable).");
822 utility_exit_with_message(
"Illegal access of variable_name for ArithmeticASTValue that is not a variable (and is instead a literal).");
825 utility_exit_with_message(
"Illegal access of variable_name for ArithmeticASTValue; variable name has not been assigned");
835 visitor.
visit( *
this );
841 if ( tokens.
empty() ) {
849 factor->parse( tokens );
852 restterm->parse( tokens );
875 utility_exit_with_message(
"Internal error in ArithmeticASTRestTerm: Invalid multiply/divide symbol, yet non-empty child list");
878 utility_exit_with_message(
"Error accessinig ArithmeticASTRestTerm rest_term_token; should not be accessed for childless object.");
892 visitor.
visit( *
this );
898 if ( tokens.
empty() )
return;
904 term->parse( tokens );
907 restexpr->parse( tokens );
930 utility_exit_with_message(
"Internal error in ArithmeticASTRestExpression: Invalid multiply/divide symbol, yet non-empty child list");
932 utility_exit_with_message(
"Error accessinig ArithmeticASTRestExpression rest_expression_token; should not be accessed for childless object.");
946 indentation_level_( 0 ),
947 last_dispatch_to_unknown_type_( false )
959 iter_end = node.
children_end(); iter != iter_end; ++iter ) {
960 (*iter)->visit( *
this );
972 Size count_args( 0 );
978 iter_end = node.
children_end(); iter != iter_end; ++iter ) {
980 (*iter)->visit( *
this );
981 if ( count_args != node.
function()->nargs() ) {
1000 iter_end = node.
children_end(); iter != iter_end; ++iter ) {
1001 (*iter)->visit( *
this );
1017 node.
child()->visit( *
this );
1050 iter_end = node.
children_end(); iter != iter_end; ++iter ) {
1051 (*iter)->visit( *
this );
1073 iter_end = node.
children_end(); iter != iter_end; ++iter ) {
1074 (*iter)->visit( *
this );
1089 std::cerr <<
"ERROR -- Infinite loop catch. Two consequitive dispatch failures from ASTPrinter. ASTNode derived class unhandled in dispatch!" << std::endl;
1094 node.
visit( *
this );
1101 node.
visit( *
this );
1149 expressions.reserve( 2 );
1152 iter_end = node.
children_end(); iter != iter_end; ++iter ) {
1153 (*iter)->visit( *
this );
1160 if ( expressions.size() == 1 ) {
1163 }
else if ( expressions.size() == 2 ) {
1177 Size count_args = 0;
1179 iter_end = node.
children_end(); iter != iter_end; ++iter ) {
1181 (*iter)->visit( *
this );
1195 "Drived classes also failed to recognize this function.");
1203 expressions.reserve( 2 );
1206 iter_end = node.
children_end(); iter != iter_end; ++iter ) {
1208 (*iter)->visit( *
this );
1214 if ( expressions.size() == 1 ) {
1217 }
else if ( expressions.size() == 2 ) {
1229 node.
child()->visit( *
this );
1254 expressions.reserve( 2 );
1257 iter_end = node.
children_end(); iter != iter_end; ++iter ) {
1259 (*iter)->visit( *
this );
1276 if ( expressions.size() == 1 ) {
1278 }
else if ( expressions.size() == 2 ) {
1301 expressions.reserve( 2 );
1304 iter_end = node.
children_end(); iter != iter_end; ++iter ) {
1306 (*iter)->visit( *
this );
1321 if ( expressions.size() == 1 ) {
1323 }
else if ( expressions.size() == 2 ) {
1355 utility_exit_with_message(
"ExpressionCreator::handle_variable_expression called.\nThis method should be overridden by the derived class.");
1365 Size count_args = args.size();
1366 std::string fname =
function->name();
1367 if ( fname ==
"max" ) {
1368 if ( count_args != 2 ) {
1373 }
else if ( fname ==
"min" ) {
1374 if ( count_args != 2 ) {
1379 }
else if ( fname ==
"sqrt" ) {
1380 if ( count_args != 1 ) {
1393 std::list< std::string >
const & varnames
1397 iter_end = varnames.end(); iter != iter_end; ++iter ) {
1417 utility_exit_with_message(
"Error in SimpleExpressionCreator::handle_variable_expression; non-variable (literal) node given!" +
1432 + varname +
"' not found in variables_ map" );
1438 std::map< std::string, VariableExpressionOP >
1458 if ( parent_result )
return parent_result;
1460 std::string
const fname =
function->name();
1461 if ( fname ==
"EQUALS" ) {
1462 assert( args.size() == 2 );
1464 }
else if ( fname ==
"GT" ) {
1465 assert( args.size() == 2 );
1467 }
else if ( fname ==
"GTE" ) {
1468 assert( args.size() == 2 );
1470 }
else if ( fname ==
"LT" ) {
1471 assert( args.size() == 2 );
1473 }
else if ( fname ==
"LTE" ) {
1474 assert( args.size() == 2 );
1476 }
else if ( fname ==
"AND" ) {
1477 assert( args.size() == 2 );
1479 }
else if ( fname ==
"OR" ) {
1480 assert( args.size() == 2 );
1482 }
else if ( fname ==
"NOT" ) {
1483 assert( args.size() == 1 );
1516 std::list< std::string >
1519 std::list< std::string > empty;
1558 if (
name_ == varname ) {
1564 std::list< std::string >
1567 std::list< std::string > myname;
1568 myname.push_back(
name_ );
1589 std::list< std::string >
1592 return ex_->active_variables();
1621 std::list< std::string >
1624 std::list< std::string > childrens_vars;
1625 std::list< std::string > e1_vars =
e1_->active_variables();
1626 std::list< std::string > e2_vars =
e2_->active_variables();
1627 childrens_vars.splice( childrens_vars.end(), e1_vars );
1628 childrens_vars.splice( childrens_vars.end(), e2_vars );
1629 return childrens_vars;
1638 return std::sqrt( (*
ex())() );
1672 if ( ! dex_dvar )
return 0;
1674 if ( (*
ex())() > 0 ) {
1689 return (*
e1())() + (*
e2())();
1698 if ( ! de1 && ! de2 ) {
1700 }
else if ( de1 && de2 ) {
1717 return (*
e1())() - (*
e2())();
1726 if ( ! de1 && ! de2 ) {
1728 }
else if ( de1 && de2 ) {
1746 return (*
e1())() * (*
e2())();
1755 if ( ! de1 && ! de2 ) {
1757 }
else if ( de1 && de2 ) {
1776 return (*
e1())() / (*
e2())();
1785 if ( ! de1 && ! de2 ) {
1787 }
else if ( de1 && de2 ) {
1821 if ( ! de1 && ! de2 ) {
1832 std::list< std::string >
1835 return (*
e1())() > (*
e2())() ?
e1()->active_variables() :
e2()->active_variables();
1855 if ( ! de1 && ! de2 ) {
1866 std::list< std::string >
1869 return (*
e1())() < (*
e2())() ?
e1()->active_variables() :
e2()->active_variables();
1898 if ( ! dee1 && ! dee2 )
return 0;
1906 std::list< std::string >
1909 return (*
e1_)() > (*
e2_)() ?
ee1_->active_variables() :
ee2_->active_variables();
1937 if ( ! dee1 && ! dee2 )
return 0;
1945 std::list< std::string >
1948 return (*
e1_)() < (*
e2_)() ?
ee1_->active_variables() :
ee2_->active_variables();
1960 return (*
e1())() == (*
e2())();
1980 return (*
e1())() > (*
e2())();
2000 return (*
e1())() >= (*
e2())();
2020 return (*
e1())() < (*
e2())();
2040 return (*
e1())() <= (*
e2())();
2061 return (*
e1())() != 0.0 && (*
e2())() != 0.0;
2080 return (*
e1())() != 0.0 || (*
e2())() != 0.0;
2099 return (*
ex())() == 0.0 ? 1.0 : 0.0;
2115 condition_( condition ),
2116 then_expression_( then_expression ),
2117 else_expression_( else_expression )
2125 if ( condition_val == 0.0 ) {
2157 std::list< std::string >
2161 if ( condition_val == 0.0 ) {
2175 expr_ast.
parse( *tokens );
2186 expr_ast.
parse( *tokens );
virtual void visit(ASTVisitor &visitor) const
ocstream cerr(std::cerr)
Wrapper around std::cerr.
void set_value(numeric::Real value)
utility::pointer::shared_ptr< LiteralExpression > LiteralExpressionOP
#define utility_exit_with_message(m)
Exit with file + line + message.
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< DivideExpression > DivideExpressionOP
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)
utility::pointer::shared_ptr< LiteralToken const > LiteralTokenCOP
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
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.
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?
utility::pointer::shared_ptr< SubtractExpression > SubtractExpressionOP
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)
utility::pointer::shared_ptr< ArithmeticASTValue > ArithmeticASTValueOP
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.
void increment_indentation()
utility::pointer::shared_ptr< ArithmeticASTRestTerm > ArithmeticASTRestTermOP
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)
utility::pointer::shared_ptr< SquarerootExpression > SquarerootExpressionOP
virtual ~EqualsExpression()
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_
utility::pointer::shared_ptr< ArithmeticASTExpression > ArithmeticASTExpressionOP
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
TokenType rest_term_token_
T const from_string(std::string const &s, T)
virtual std::list< std::string > active_variables() const
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
Program exit functions and macros.
FunctionTokenCOP function() 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 &)
T abs(T const &x)
std::abs( x ) == | x |
void set_value(numeric::Real value)
utility::pointer::shared_ptr< TokenSet > TokenSetOP
ExpressionCOP last_constructed_expression_
utility::pointer::shared_ptr< Expression > ExpressionOP
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 ~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 &)
Parse tree for arithmetic operations.
FunctionTokenCOP function_
utility::pointer::shared_ptr< ArithmeticASTFunction > ArithmeticASTFunctionOP
virtual TokenType type() const
std::string variable_name_
utility::pointer::shared_ptr< MultiplyExpression > MultiplyExpressionOP
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
utility::pointer::shared_ptr< VariableToken const > VariableTokenCOP
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
utility::pointer::shared_ptr< ArithmeticASTTerm > ArithmeticASTTermOP
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
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 ...
std::string to_string(const T &t)
VariableExpressionOP get_variable(std::string const &varname)
Some std::string helper functions.
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...
utility::pointer::shared_ptr< ArithmeticASTFactor > ArithmeticASTFactorOP
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_
utility::pointer::shared_ptr< ArithmeticASTRestExpression > ArithmeticASTRestExpressionOP
ArithmeticASTNodeCOP child() const
utility::pointer::shared_ptr< LiteralExpression const > LiteralExpressionCOP
numeric::Real literal_value_
ArithmeticASTRestExpression()
virtual numeric::Real operator()() const
void set_second_expression(ExpressionCOP e2)
ExpressionCOP then_expression_
void set_first_expression(ExpressionCOP e1)