dehnert
12 years ago
13 changed files with 646 additions and 29 deletions
-
33src/ir/expressions/BaseExpression.h
-
63src/ir/expressions/BinaryBooleanFunctionExpression.h
-
63src/ir/expressions/BinaryNumericalFunctionExpression.h
-
64src/ir/expressions/BinaryRelationExpression.h
-
51src/ir/expressions/BooleanLiteral.h
-
47src/ir/expressions/ConstantExpression.h
-
47src/ir/expressions/DoubleLiteral.h
-
21src/ir/expressions/Expressions.h
-
47src/ir/expressions/IntegerLiteral.h
-
56src/ir/expressions/UnaryBooleanFunctionExpression.h
-
56src/ir/expressions/UnaryNumericalFunctionExpression.h
-
47src/ir/expressions/VariableExpression.h
-
80src/parser/PrismParser.h
@ -0,0 +1,33 @@ |
|||
/* |
|||
* Expression.h |
|||
* |
|||
* Created on: 03.01.2013 |
|||
* Author: chris |
|||
*/ |
|||
|
|||
#ifndef EXPRESSION_H_ |
|||
#define EXPRESSION_H_ |
|||
|
|||
namespace storm { |
|||
|
|||
namespace ir { |
|||
|
|||
namespace expressions { |
|||
|
|||
class BaseExpression { |
|||
|
|||
public: |
|||
virtual ~BaseExpression() { |
|||
|
|||
} |
|||
|
|||
virtual std::string toString() const = 0; |
|||
}; |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
#endif /* EXPRESSION_H_ */ |
@ -0,0 +1,63 @@ |
|||
/* |
|||
* BinaryBooleanFunctionExpression.h |
|||
* |
|||
* Created on: 03.01.2013 |
|||
* Author: chris |
|||
*/ |
|||
|
|||
#ifndef BINARYBOOLEANFUNCTIONEXPRESSION_H_ |
|||
#define BINARYBOOLEANFUNCTIONEXPRESSION_H_ |
|||
|
|||
#include "src/ir/expressions/BaseExpression.h" |
|||
#include <boost/fusion/include/adapt_struct.hpp> |
|||
|
|||
namespace storm { |
|||
|
|||
namespace ir { |
|||
|
|||
namespace expressions { |
|||
|
|||
class BinaryBooleanFunctionExpression : public BaseExpression { |
|||
public: |
|||
enum FunctorType {AND, OR, XOR, IMPLIES} functor; |
|||
BaseExpression* left; |
|||
BaseExpression* right; |
|||
|
|||
BinaryBooleanFunctionExpression(BaseExpression* left, BaseExpression* right, FunctorType functor) { |
|||
this->left = left; |
|||
this->right = right; |
|||
this->functor = functor; |
|||
} |
|||
|
|||
virtual ~BinaryBooleanFunctionExpression() { |
|||
|
|||
} |
|||
|
|||
virtual std::string toString() const { |
|||
std::string result = left->toString(); |
|||
switch (functor) { |
|||
case AND: result += " & "; break; |
|||
case OR: result += " | "; break; |
|||
case XOR: result += " ^ "; break; |
|||
case IMPLIES: result += " => "; break; |
|||
} |
|||
result += right->toString(); |
|||
|
|||
return result; |
|||
} |
|||
}; |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
BOOST_FUSION_ADAPT_STRUCT( |
|||
storm::ir::expressions::BinaryBooleanFunctionExpression, |
|||
(storm::ir::expressions::BaseExpression*, left) |
|||
(storm::ir::expressions::BaseExpression*, right) |
|||
(storm::ir::expressions::BinaryBooleanFunctionExpression::FunctorType, functor) |
|||
) |
|||
|
|||
#endif /* BINARYBOOLEANFUNCTIONEXPRESSION_H_ */ |
@ -0,0 +1,63 @@ |
|||
/* |
|||
* BinaryFunctionExpression.h |
|||
* |
|||
* Created on: 03.01.2013 |
|||
* Author: chris |
|||
*/ |
|||
|
|||
#ifndef BINARYFUNCTIONEXPRESSION_H_ |
|||
#define BINARYFUNCTIONEXPRESSION_H_ |
|||
|
|||
#include "src/ir/expressions/BaseExpression.h" |
|||
|
|||
namespace storm { |
|||
|
|||
namespace ir { |
|||
|
|||
namespace expressions { |
|||
|
|||
class BinaryNumericalFunctionExpression : public BaseExpression { |
|||
public: |
|||
BaseExpression* left; |
|||
BaseExpression* right; |
|||
enum FunctorType {PLUS, MINUS, TIMES, DIVIDE} functor; |
|||
|
|||
BinaryNumericalFunctionExpression(BaseExpression* left, BaseExpression* right, FunctorType functor) { |
|||
this->left = left; |
|||
this->right = right; |
|||
this->functor = functor; |
|||
} |
|||
|
|||
virtual ~BinaryNumericalFunctionExpression() { |
|||
|
|||
} |
|||
|
|||
virtual std::string toString() const { |
|||
std::string result = left->toString(); |
|||
switch (functor) { |
|||
case PLUS: result += " + "; break; |
|||
case MINUS: result += " - "; break; |
|||
case TIMES: result += " * "; break; |
|||
case DIVIDE: result += " / "; break; |
|||
} |
|||
result += right->toString(); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
}; |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
BOOST_FUSION_ADAPT_STRUCT( |
|||
storm::ir::expressions::BinaryNumericalFunctionExpression, |
|||
(storm::ir::expressions::BaseExpression*, left) |
|||
(storm::ir::expressions::BaseExpression*, right) |
|||
(storm::ir::expressions::BinaryNumericalFunctionExpression::FunctorType, functor) |
|||
) |
|||
|
|||
#endif /* BINARYFUNCTIONEXPRESSION_H_ */ |
@ -0,0 +1,64 @@ |
|||
/* |
|||
* BinaryRelationExpression.h |
|||
* |
|||
* Created on: 03.01.2013 |
|||
* Author: chris |
|||
*/ |
|||
|
|||
#ifndef BINARYRELATIONEXPRESSION_H_ |
|||
#define BINARYRELATIONEXPRESSION_H_ |
|||
|
|||
#include "src/ir/expressions/BaseExpression.h" |
|||
|
|||
namespace storm { |
|||
|
|||
namespace ir { |
|||
|
|||
namespace expressions { |
|||
|
|||
class BinaryRelationExpression : public BaseExpression { |
|||
public: |
|||
BaseExpression* left; |
|||
BaseExpression* right; |
|||
enum RelationType {EQUAL, LESS, LESS_OR_EQUAL, GREATER, GREATER_OR_EQUAL} relation; |
|||
|
|||
BinaryRelationExpression(BaseExpression* left, BaseExpression* right, RelationType relation) { |
|||
this->left = left; |
|||
this->right = right; |
|||
this->relation = relation; |
|||
} |
|||
|
|||
virtual ~BinaryRelationExpression() { |
|||
|
|||
} |
|||
|
|||
virtual std::string toString() const { |
|||
std::string result = left->toString(); |
|||
switch (relation) { |
|||
case EQUAL: result += " == "; break; |
|||
case LESS: result += " < "; break; |
|||
case LESS_OR_EQUAL: result += " <= "; break; |
|||
case GREATER: result += " > "; break; |
|||
case GREATER_OR_EQUAL: result += " >= "; break; |
|||
} |
|||
result += right->toString(); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
}; |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
BOOST_FUSION_ADAPT_STRUCT( |
|||
storm::ir::expressions::BinaryRelationExpression, |
|||
(storm::ir::expressions::BaseExpression*, left) |
|||
(storm::ir::expressions::BaseExpression*, right) |
|||
(storm::ir::expressions::BinaryRelationExpression::RelationType, relation) |
|||
) |
|||
|
|||
#endif /* BINARYRELATIONEXPRESSION_H_ */ |
@ -0,0 +1,51 @@ |
|||
/* |
|||
* BooleanLiteral.h |
|||
* |
|||
* Created on: 03.01.2013 |
|||
* Author: chris |
|||
*/ |
|||
|
|||
#ifndef BOOLEANLITERAL_H_ |
|||
#define BOOLEANLITERAL_H_ |
|||
|
|||
#include "src/ir/expressions/BaseExpression.h" |
|||
|
|||
namespace storm { |
|||
|
|||
namespace ir { |
|||
|
|||
namespace expressions { |
|||
|
|||
class BooleanLiteral : public BaseExpression { |
|||
public: |
|||
bool value; |
|||
|
|||
BooleanLiteral(bool value) { |
|||
this->value = value; |
|||
} |
|||
|
|||
virtual ~BooleanLiteral() { |
|||
|
|||
} |
|||
|
|||
virtual std::string toString() const { |
|||
if (value) { |
|||
return std::string("true"); |
|||
} else { |
|||
return std::string("false"); |
|||
} |
|||
} |
|||
}; |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
BOOST_FUSION_ADAPT_STRUCT( |
|||
storm::ir::expressions::BooleanLiteral, |
|||
(bool, value) |
|||
) |
|||
|
|||
#endif /* BOOLEANLITERAL_H_ */ |
@ -0,0 +1,47 @@ |
|||
/* |
|||
* ConstantExpression.h |
|||
* |
|||
* Created on: 03.01.2013 |
|||
* Author: chris |
|||
*/ |
|||
|
|||
#ifndef CONSTANTEXPRESSION_H_ |
|||
#define CONSTANTEXPRESSION_H_ |
|||
|
|||
#include "src/ir/expressions/BaseExpression.h" |
|||
|
|||
namespace storm { |
|||
|
|||
namespace ir { |
|||
|
|||
namespace expressions { |
|||
|
|||
class ConstantExpression : public BaseExpression { |
|||
public: |
|||
std::string constantName; |
|||
|
|||
ConstantExpression(std::string constantName) { |
|||
this->constantName = constantName; |
|||
} |
|||
|
|||
virtual ~ConstantExpression() { |
|||
|
|||
} |
|||
|
|||
virtual std::string toString() const { |
|||
return constantName; |
|||
} |
|||
}; |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
BOOST_FUSION_ADAPT_STRUCT( |
|||
storm::ir::expressions::ConstantExpression, |
|||
(std::string, constantName) |
|||
) |
|||
|
|||
#endif /* CONSTANTEXPRESSION_H_ */ |
@ -0,0 +1,47 @@ |
|||
/* |
|||
* DoubleLiteral.h |
|||
* |
|||
* Created on: 03.01.2013 |
|||
* Author: chris |
|||
*/ |
|||
|
|||
#ifndef DOUBLELITERAL_H_ |
|||
#define DOUBLELITERAL_H_ |
|||
|
|||
#include "src/ir/expressions/BaseExpression.h" |
|||
|
|||
namespace storm { |
|||
|
|||
namespace ir { |
|||
|
|||
namespace expressions { |
|||
|
|||
class DoubleLiteral : public BaseExpression { |
|||
public: |
|||
double value; |
|||
|
|||
DoubleLiteral(double value) { |
|||
this->value = value; |
|||
} |
|||
|
|||
virtual ~DoubleLiteral() { |
|||
|
|||
} |
|||
|
|||
virtual std::string toString() const { |
|||
return boost::lexical_cast<std::string>(value); |
|||
} |
|||
}; |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
BOOST_FUSION_ADAPT_STRUCT( |
|||
storm::ir::expressions::DoubleLiteral, |
|||
(double, value) |
|||
) |
|||
|
|||
#endif /* DOUBLELITERAL_H_ */ |
@ -0,0 +1,21 @@ |
|||
/* |
|||
* Expressions.h |
|||
* |
|||
* Created on: 03.01.2013 |
|||
* Author: chris |
|||
*/ |
|||
|
|||
#ifndef EXPRESSIONS_H_ |
|||
#define EXPRESSIONS_H_ |
|||
|
|||
#include "BinaryBooleanFunctionExpression.h" |
|||
#include "BinaryNumericalFunctionExpression.h" |
|||
#include "BinaryRelationExpression.h" |
|||
#include "BooleanLiteral.h" |
|||
#include "DoubleLiteral.h" |
|||
#include "IntegerLiteral.h" |
|||
#include "UnaryBooleanFunctionExpression.h" |
|||
#include "UnaryNumericalFunctionExpression.h" |
|||
#include "VariableExpression.h" |
|||
|
|||
#endif /* EXPRESSIONS_H_ */ |
@ -0,0 +1,47 @@ |
|||
/* |
|||
* 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 value; |
|||
|
|||
IntegerLiteral(int value) { |
|||
this->value = value; |
|||
} |
|||
|
|||
virtual ~IntegerLiteral() { |
|||
|
|||
} |
|||
|
|||
virtual std::string toString() const { |
|||
return boost::lexical_cast<std::string>(value); |
|||
} |
|||
}; |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
BOOST_FUSION_ADAPT_STRUCT( |
|||
storm::ir::expressions::IntegerLiteral, |
|||
(int, value) |
|||
) |
|||
|
|||
#endif /* INTEGERLITERAL_H_ */ |
@ -0,0 +1,56 @@ |
|||
/* |
|||
* UnaryBooleanFunctionExpression.h |
|||
* |
|||
* Created on: 03.01.2013 |
|||
* Author: chris |
|||
*/ |
|||
|
|||
#ifndef UNARYBOOLEANFUNCTIONEXPRESSION_H_ |
|||
#define UNARYBOOLEANFUNCTIONEXPRESSION_H_ |
|||
|
|||
#include "src/ir/expressions/BaseExpression.h" |
|||
|
|||
namespace storm { |
|||
|
|||
namespace ir { |
|||
|
|||
namespace expressions { |
|||
|
|||
class UnaryBooleanFunctionExpression : public BaseExpression { |
|||
public: |
|||
BaseExpression* child; |
|||
enum FunctorType {NOT} functor; |
|||
|
|||
UnaryBooleanFunctionExpression(BaseExpression* child, FunctorType functor) { |
|||
this->child = child; |
|||
this->functor = functor; |
|||
} |
|||
|
|||
virtual ~UnaryBooleanFunctionExpression() { |
|||
|
|||
} |
|||
|
|||
virtual std::string toString() const { |
|||
std::string result = ""; |
|||
switch (functor) { |
|||
case NOT: result += "!"; break; |
|||
} |
|||
result += child->toString(); |
|||
|
|||
return result; |
|||
} |
|||
}; |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
BOOST_FUSION_ADAPT_STRUCT( |
|||
storm::ir::expressions::UnaryBooleanFunctionExpression, |
|||
(storm::ir::expressions::BaseExpression*, child) |
|||
(storm::ir::expressions::UnaryBooleanFunctionExpression::FunctorType, functor) |
|||
) |
|||
|
|||
#endif /* UNARYBOOLEANFUNCTIONEXPRESSION_H_ */ |
@ -0,0 +1,56 @@ |
|||
/* |
|||
* UnaryFunctionExpression.h |
|||
* |
|||
* Created on: 03.01.2013 |
|||
* Author: chris |
|||
*/ |
|||
|
|||
#ifndef UNARYFUNCTIONEXPRESSION_H_ |
|||
#define UNARYFUNCTIONEXPRESSION_H_ |
|||
|
|||
#include "src/ir/expressions/BaseExpression.h" |
|||
|
|||
namespace storm { |
|||
|
|||
namespace ir { |
|||
|
|||
namespace expressions { |
|||
|
|||
class UnaryNumericalFunctionExpression : public BaseExpression { |
|||
public: |
|||
BaseExpression* child; |
|||
enum FunctorType {MINUS} functor; |
|||
|
|||
UnaryNumericalFunctionExpression(BaseExpression* child, FunctorType functor) { |
|||
this->child = child; |
|||
this->functor = functor; |
|||
} |
|||
|
|||
virtual ~UnaryNumericalFunctionExpression() { |
|||
|
|||
} |
|||
|
|||
virtual std::string toString() const { |
|||
std::string result = ""; |
|||
switch (functor) { |
|||
case MINUS: result += "-"; break; |
|||
} |
|||
result += child->toString(); |
|||
|
|||
return result; |
|||
} |
|||
}; |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
BOOST_FUSION_ADAPT_STRUCT( |
|||
storm::ir::expressions::UnaryNumericalFunctionExpression, |
|||
(storm::ir::expressions::BaseExpression*, child) |
|||
(storm::ir::expressions::UnaryNumericalFunctionExpression::FunctorType, functor) |
|||
) |
|||
|
|||
#endif /* UNARYFUNCTIONEXPRESSION_H_ */ |
@ -0,0 +1,47 @@ |
|||
/* |
|||
* VariableExpression.h |
|||
* |
|||
* Created on: 03.01.2013 |
|||
* Author: chris |
|||
*/ |
|||
|
|||
#ifndef VARIABLEEXPRESSION_H_ |
|||
#define VARIABLEEXPRESSION_H_ |
|||
|
|||
#include "src/ir/expressions/BaseExpression.h" |
|||
|
|||
namespace storm { |
|||
|
|||
namespace ir { |
|||
|
|||
namespace expressions { |
|||
|
|||
class VariableExpression : public BaseExpression { |
|||
public: |
|||
std::string variableName; |
|||
|
|||
VariableExpression(std::string variableName) { |
|||
this->variableName = variableName; |
|||
} |
|||
|
|||
virtual ~VariableExpression() { |
|||
|
|||
} |
|||
|
|||
virtual std::string toString() const { |
|||
return variableName; |
|||
} |
|||
}; |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
BOOST_FUSION_ADAPT_STRUCT( |
|||
storm::ir::expressions::VariableExpression, |
|||
(std::string, variableName) |
|||
) |
|||
|
|||
#endif /* VARIABLEEXPRESSION_H_ */ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue