You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

49 lines
2.4 KiB

#ifndef STORM_STORAGE_EXPRESSIONS_SUBSTITUTIONVISITOR_H_
#define STORM_STORAGE_EXPRESSIONS_SUBSTITUTIONVISITOR_H_
#include <stack>
#include "src/storage/expressions/Expression.h"
#include "src/storage/expressions/ExpressionVisitor.h"
namespace storm {
namespace expressions {
template<typename MapType>
class SubstitutionVisitor : public ExpressionVisitor {
public:
/*!
* Creates a new substitution visitor that uses the given map to replace variables.
*
* @param variableToExpressionMapping A mapping from variables to expressions.
*/
SubstitutionVisitor(MapType const& variableToExpressionMapping);
/*!
* Substitutes the identifiers in the given expression according to the previously given map and returns the
* resulting expression.
*
* @param expression The expression in which to substitute the identifiers.
* @return The expression in which all identifiers in the key set of the previously given mapping are
* substituted with the mapped-to expressions.
*/
Expression substitute(Expression const& expression);
virtual boost::any visit(IfThenElseExpression const& expression) override;
virtual boost::any visit(BinaryBooleanFunctionExpression const& expression) override;
virtual boost::any visit(BinaryNumericalFunctionExpression const& expression) override;
virtual boost::any visit(BinaryRelationExpression const& expression) override;
virtual boost::any visit(VariableExpression const& expression) override;
virtual boost::any visit(UnaryBooleanFunctionExpression const& expression) override;
virtual boost::any visit(UnaryNumericalFunctionExpression const& expression) override;
virtual boost::any visit(BooleanLiteralExpression const& expression) override;
virtual boost::any visit(IntegerLiteralExpression const& expression) override;
virtual boost::any visit(DoubleLiteralExpression const& expression) override;
private:
// A mapping of variables to expressions with which they shall be replaced.
MapType const& variableToExpressionMapping;
};
}
}
#endif /* STORM_STORAGE_EXPRESSIONS_SUBSTITUTIONVISITOR_H_ */