59 changed files with 2100 additions and 1871 deletions
-
32src/adapters/ExplicitModelAdapter.cpp
-
33src/ir/Assignment.cpp
-
26src/ir/Assignment.h
-
27src/ir/BooleanVariable.cpp
-
28src/ir/BooleanVariable.h
-
49src/ir/Command.cpp
-
26src/ir/Command.h
-
33src/ir/IntegerVariable.cpp
-
30src/ir/IntegerVariable.h
-
82src/ir/Module.cpp
-
34src/ir/Module.h
-
46src/ir/Program.cpp
-
16src/ir/Program.h
-
34src/ir/RewardModel.cpp
-
16src/ir/RewardModel.h
-
8src/ir/StateReward.cpp
-
14src/ir/StateReward.h
-
12src/ir/TransitionReward.cpp
-
21src/ir/TransitionReward.h
-
62src/ir/Update.cpp
-
26src/ir/Update.h
-
45src/ir/Variable.cpp
-
38src/ir/Variable.h
-
4src/ir/expressions/BaseExpression.h
-
2src/ir/expressions/BinaryBooleanFunctionExpression.cpp
-
4src/ir/expressions/BinaryBooleanFunctionExpression.h
-
2src/ir/expressions/BinaryNumericalFunctionExpression.cpp
-
2src/ir/expressions/BinaryNumericalFunctionExpression.h
-
2src/ir/expressions/BinaryRelationExpression.cpp
-
2src/ir/expressions/BinaryRelationExpression.h
-
2src/ir/expressions/BooleanConstantExpression.cpp
-
2src/ir/expressions/BooleanConstantExpression.h
-
2src/ir/expressions/BooleanLiteralExpression.cpp
-
2src/ir/expressions/BooleanLiteralExpression.h
-
6src/ir/expressions/ConstantExpression.cpp
-
4src/ir/expressions/ConstantExpression.h
-
14src/ir/expressions/DoubleConstantExpression.cpp
-
7src/ir/expressions/DoubleConstantExpression.h
-
10src/ir/expressions/DoubleLiteralExpression.cpp
-
4src/ir/expressions/DoubleLiteralExpression.h
-
6src/ir/expressions/Expressions.h
-
59src/ir/expressions/IntegerConstantExpression.cpp
-
107src/ir/expressions/IntegerConstantExpression.h
-
57src/ir/expressions/IntegerLiteral.h
-
40src/ir/expressions/IntegerLiteralExpression.cpp
-
46src/ir/expressions/IntegerLiteralExpression.h
-
56src/ir/expressions/UnaryBooleanFunctionExpression.cpp
-
94src/ir/expressions/UnaryBooleanFunctionExpression.h
-
24src/ir/expressions/UnaryExpression.cpp
-
42src/ir/expressions/UnaryExpression.h
-
69src/ir/expressions/UnaryNumericalFunctionExpression.cpp
-
112src/ir/expressions/UnaryNumericalFunctionExpression.h
-
41src/ir/expressions/VariableExpression.cpp
-
67src/ir/expressions/VariableExpression.h
-
10src/parser/prismparser/BaseGrammar.h
-
24src/parser/prismparser/PrismGrammar.cpp
-
8src/parser/prismparser/PrismGrammar.h
-
22src/parser/prismparser/VariableState.cpp
-
12src/parser/prismparser/VariableState.h
@ -0,0 +1,59 @@ |
|||
/*
|
|||
* IntegerConstantExpression.cpp |
|||
* |
|||
* Created on: 10.06.2013 |
|||
* Author: Christian Dehnert |
|||
*/ |
|||
|
|||
#include "IntegerConstantExpression.h"
|
|||
|
|||
namespace storm { |
|||
namespace ir { |
|||
namespace expressions { |
|||
|
|||
IntegerConstantExpression::IntegerConstantExpression(std::string const& constantName) : ConstantExpression(int_, constantName), value(0), defined(false) { |
|||
// Nothing to do here.
|
|||
} |
|||
|
|||
std::shared_ptr<BaseExpression> IntegerConstantExpression::clone(std::map<std::string, std::string> const& renaming, storm::parser::prism::VariableState const& variableState) const { |
|||
return std::shared_ptr<BaseExpression>(new IntegerConstantExpression(*this)); |
|||
} |
|||
|
|||
int_fast64_t IntegerConstantExpression::getValueAsInt(std::pair<std::vector<bool>, std::vector<int_fast64_t>> const* variableValues) const { |
|||
if (!defined) { |
|||
throw storm::exceptions::ExpressionEvaluationException() << "Cannot evaluate expression: " |
|||
<< "Integer constant '" << this->getConstantName() << "' is undefined."; |
|||
} else { |
|||
return value; |
|||
} |
|||
} |
|||
|
|||
void IntegerConstantExpression::accept(ExpressionVisitor* visitor) { |
|||
visitor->visit(this); |
|||
} |
|||
|
|||
std::string IntegerConstantExpression::toString() const { |
|||
std::stringstream result; |
|||
result << this->getConstantName(); |
|||
if (defined) { |
|||
result << "[" << value << "]"; |
|||
} |
|||
return result.str(); |
|||
} |
|||
|
|||
bool IntegerConstantExpression::isDefined() const { |
|||
return defined; |
|||
} |
|||
|
|||
int_fast64_t IntegerConstantExpression::getValue() const { |
|||
return value; |
|||
} |
|||
|
|||
void IntegerConstantExpression::define(int_fast64_t value) { |
|||
defined = true; |
|||
this->value = value; |
|||
} |
|||
|
|||
} // namespace expressions
|
|||
} // namespace ir
|
|||
} // namespace storm
|
@ -1,57 +0,0 @@ |
|||
/* |
|||
* IntegerLiteral.h |
|||
* |
|||
* Created on: 03.01.2013 |
|||
* Author: chris |
|||
*/ |
|||
|
|||
#ifndef INTEGERLITERAL_H_ |
|||
#define INTEGERLITERAL_H_ |
|||
|
|||
#include "src/ir/expressions/BaseExpression.h" |
|||
|
|||
namespace storm { |
|||
|
|||
namespace ir { |
|||
|
|||
namespace expressions { |
|||
|
|||
class IntegerLiteral : public BaseExpression { |
|||
public: |
|||
int_fast64_t value; |
|||
|
|||
IntegerLiteral(int_fast64_t value) : BaseExpression(int_), value(value) { |
|||
} |
|||
|
|||
virtual ~IntegerLiteral() { |
|||
} |
|||
|
|||
virtual std::shared_ptr<BaseExpression> clone(std::map<std::string, std::string> const& renaming, parser::prismparser::VariableState const& variableState) const { |
|||
return std::shared_ptr<BaseExpression>(new IntegerLiteral(this->value)); |
|||
} |
|||
|
|||
virtual int_fast64_t getValueAsInt(std::pair<std::vector<bool>, std::vector<int_fast64_t>> const* variableValues) const { |
|||
return value; |
|||
} |
|||
|
|||
virtual void accept(ExpressionVisitor* visitor) { |
|||
visitor->visit(this); |
|||
} |
|||
|
|||
virtual std::string toString() const { |
|||
return boost::lexical_cast<std::string>(value); |
|||
} |
|||
virtual std::string dump(std::string prefix) const { |
|||
std::stringstream result; |
|||
result << prefix << "IntegerLiteral " << this->toString() << std::endl; |
|||
return result.str(); |
|||
} |
|||
}; |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
#endif /* INTEGERLITERAL_H_ */ |
@ -0,0 +1,40 @@ |
|||
/*
|
|||
* IntegerLiteralExpression.cpp |
|||
* |
|||
* Created on: 03.01.2013 |
|||
* Author: Christian Dehnert |
|||
*/ |
|||
|
|||
#include <sstream>
|
|||
|
|||
#include "IntegerLiteralExpression.h"
|
|||
|
|||
namespace storm { |
|||
namespace ir { |
|||
namespace expressions { |
|||
|
|||
IntegerLiteralExpression::IntegerLiteralExpression(int_fast64_t value) : BaseExpression(int_), value(value) { |
|||
// Nothing to do here.
|
|||
} |
|||
|
|||
std::shared_ptr<BaseExpression> IntegerLiteralExpression::clone(std::map<std::string, std::string> const& renaming, storm::parser::prism::VariableState const& variableState) const { |
|||
return std::shared_ptr<BaseExpression>(new IntegerLiteralExpression(this->value)); |
|||
} |
|||
|
|||
int_fast64_t IntegerLiteralExpression::getValueAsInt(std::pair<std::vector<bool>, std::vector<int_fast64_t>> const* variableValues) const { |
|||
return value; |
|||
} |
|||
|
|||
void IntegerLiteralExpression::accept(ExpressionVisitor* visitor) { |
|||
visitor->visit(this); |
|||
} |
|||
|
|||
std::string IntegerLiteralExpression::toString() const { |
|||
std::stringstream result; |
|||
result << value; |
|||
return result.str(); |
|||
} |
|||
|
|||
} // namespace expressions
|
|||
} // namespace ir
|
|||
} // namespace storm
|
@ -0,0 +1,46 @@ |
|||
/* |
|||
* IntegerLiteralExpression.h |
|||
* |
|||
* Created on: 03.01.2013 |
|||
* Author: Christian Dehnert |
|||
*/ |
|||
|
|||
#ifndef STORM_IR_EXPRESSIONS_INTEGERLITERALEXPRESSION_H_ |
|||
#define STORM_IR_EXPRESSIONS_INTEGERLITERALEXPRESSION_H_ |
|||
|
|||
#include "src/ir/expressions/BaseExpression.h" |
|||
|
|||
namespace storm { |
|||
namespace ir { |
|||
namespace expressions { |
|||
|
|||
/*! |
|||
* A class representing an integer literal. |
|||
*/ |
|||
class IntegerLiteralExpression : public BaseExpression { |
|||
public: |
|||
/*! |
|||
* Creates an integer literal expression with the given value. |
|||
* |
|||
* @param value The value for the integer literal. |
|||
*/ |
|||
IntegerLiteralExpression(int_fast64_t value); |
|||
|
|||
virtual std::shared_ptr<BaseExpression> clone(std::map<std::string, std::string> const& renaming, storm::parser::prism::VariableState const& variableState) const override; |
|||
|
|||
virtual int_fast64_t getValueAsInt(std::pair<std::vector<bool>, std::vector<int_fast64_t>> const* variableValues) const override; |
|||
|
|||
virtual void accept(ExpressionVisitor* visitor) override; |
|||
|
|||
virtual std::string toString() const override; |
|||
|
|||
private: |
|||
// The value of the double literal. |
|||
int_fast64_t value; |
|||
}; |
|||
|
|||
} // namespace expressions |
|||
} // namespace ir |
|||
} // namespace storm |
|||
|
|||
#endif /* STORM_IR_EXPRESSIONS_INTEGERLITERALEXPRESSION_H_ */ |
@ -0,0 +1,56 @@ |
|||
/*
|
|||
* UnaryBooleanFunctionExpression.cpp |
|||
* |
|||
* Created on: 10.06.2013 |
|||
* Author: Christian Dehnert |
|||
*/ |
|||
|
|||
#ifndef STORM_IR_EXPRESSIONS_UNARYBOOLEANFUNCTIONEXPRESSION_H_
|
|||
#define STORM_IR_EXPRESSIONS_UNARYBOOLEANFUNCTIONEXPRESSION_H_
|
|||
|
|||
#include <sstream>
|
|||
|
|||
#include "UnaryBooleanFunctionExpression.h"
|
|||
|
|||
namespace storm { |
|||
namespace ir { |
|||
namespace expressions { |
|||
|
|||
UnaryBooleanFunctionExpression::UnaryBooleanFunctionExpression(std::shared_ptr<BaseExpression> child, FunctionType functionType) : UnaryExpression(bool_, child), functionType(functionType) { |
|||
// Nothing to do here.
|
|||
} |
|||
|
|||
std::shared_ptr<BaseExpression> UnaryBooleanFunctionExpression::clone(std::map<std::string, std::string> const& renaming, storm::parser::prism::VariableState const& variableState) const { |
|||
return std::shared_ptr<BaseExpression>(new UnaryBooleanFunctionExpression(this->getChild()->clone(renaming, variableState), this->functionType)); |
|||
} |
|||
|
|||
FunctionType UnaryBooleanFunctionExpression::getFunctionType() const { |
|||
return functionType; |
|||
} |
|||
|
|||
bool UnaryBooleanFunctionExpression::getValueAsBool(std::pair<std::vector<bool>, std::vector<int_fast64_t>> const* variableValues) const { |
|||
bool resultChild = this->getChild()->getValueAsBool(variableValues); |
|||
switch(functionType) { |
|||
case NOT: return !resultChild; break; |
|||
default: throw storm::exceptions::ExpressionEvaluationException() << "Cannot evaluate expression: " |
|||
<< "Unknown boolean unary operator: '" << functionType << "'."; |
|||
} |
|||
} |
|||
|
|||
void UnaryBooleanFunctionExpression::accept(ExpressionVisitor* visitor) { |
|||
visitor->visit(this); |
|||
} |
|||
|
|||
std::string UnaryBooleanFunctionExpression::toString() const { |
|||
std::stringstream result; |
|||
switch (functionType) { |
|||
case NOT: result << "!"; break; |
|||
} |
|||
result << "(" << this->getChild()->toString() << ")"; |
|||
|
|||
return result.str(); |
|||
} |
|||
|
|||
} // namespace expressions
|
|||
} // namespace ir
|
|||
} // namespace storm
|
@ -0,0 +1,24 @@ |
|||
/*
|
|||
* UnaryExpression.cpp |
|||
* |
|||
* Created on: 27.01.2013 |
|||
* Author: Christian Dehnert |
|||
*/ |
|||
|
|||
#include "UnaryExpression.h"
|
|||
|
|||
namespace storm { |
|||
namespace ir { |
|||
namespace expressions { |
|||
|
|||
UnaryExpression::UnaryExpression(ReturnType type, std::shared_ptr<BaseExpression> child) : BaseExpression(type), child(child) { |
|||
// Nothing to do here.
|
|||
} |
|||
|
|||
std::shared_ptr<BaseExpression> const& UnaryExpression::getChild() const { |
|||
return child; |
|||
} |
|||
|
|||
} // namespace expressions
|
|||
} // namespace ir
|
|||
} // namespace storm
|
@ -0,0 +1,69 @@ |
|||
/*
|
|||
* UnaryFunctionExpression.h |
|||
* |
|||
* Created on: 03.01.2013 |
|||
* Author: Christian Dehnert |
|||
*/ |
|||
|
|||
#include "UnaryNumericalFunctionExpression.h"
|
|||
|
|||
namespace storm { |
|||
namespace ir { |
|||
namespace expressions { |
|||
|
|||
UnaryNumericalFunctionExpression::UnaryNumericalFunctionExpression(ReturnType type, std::shared_ptr<BaseExpression> child, FunctionType functionType) : UnaryExpression(type, child), functionType(functionType) { |
|||
// Nothing to do here.
|
|||
} |
|||
|
|||
std::shared_ptr<BaseExpression> UnaryNumericalFunctionExpression::clone(std::map<std::string, std::string> const& renaming, storm::parser::prism::VariableState const& variableState) const { |
|||
return std::shared_ptr<BaseExpression>(new UnaryNumericalFunctionExpression(this->getType(), this->getChild()->clone(renaming, variableState), this->functionType)); |
|||
} |
|||
|
|||
int_fast64_t UnaryNumericalFunctionExpression::getValueAsInt(std::pair<std::vector<bool>, std::vector<int_fast64_t>> const* variableValues) const { |
|||
if (this->getType() != int_) { |
|||
BaseExpression::getValueAsInt(variableValues); |
|||
} |
|||
|
|||
int_fast64_t resultChild = this->getChild()->getValueAsInt(variableValues); |
|||
switch(functionType) { |
|||
case MINUS: return -resultChild; break; |
|||
default: throw storm::exceptions::ExpressionEvaluationException() << "Cannot evaluate expression: " |
|||
<< "Unknown numerical unary operator: '" << functionType << "'."; |
|||
} |
|||
} |
|||
|
|||
double UnaryNumericalFunctionExpression::getValueAsDouble(std::pair<std::vector<bool>, std::vector<int_fast64_t>> const* variableValues) const { |
|||
if (this->getType() != double_) { |
|||
BaseExpression::getValueAsDouble(variableValues); |
|||
} |
|||
|
|||
double resultChild = this->getChild()->getValueAsDouble(variableValues); |
|||
switch(functionType) { |
|||
case MINUS: return -resultChild; break; |
|||
default: throw storm::exceptions::ExpressionEvaluationException() << "Cannot evaluate expression: " |
|||
<< "Unknown numerical unary operator: '" << functionType << "'."; |
|||
} |
|||
} |
|||
|
|||
FunctionType UnaryNumericalFunctionExpression::getFunctionType() const { |
|||
return functionType; |
|||
} |
|||
|
|||
void UnaryNumericalFunctionExpression::accept(ExpressionVisitor* visitor) { |
|||
visitor->visit(this); |
|||
} |
|||
|
|||
std::string UnaryNumericalFunctionExpression::toString() const { |
|||
std::string result = ""; |
|||
switch (functionType) { |
|||
case MINUS: result += "-"; break; |
|||
} |
|||
result += this->getChild()->toString(); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
} // namespace expressions
|
|||
} // namespace ir
|
|||
} // namespace storm
|
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue