@ -133,7 +133,7 @@ namespace storm {
formulaName = qi : : lit ( " \" " ) > > identifier > > qi : : lit ( " \" " ) > > qi : : lit ( " : " ) ;
formulaName . name ( " formula name " ) ;
constantDefinition = ( qi : : lit ( " const " ) > qi : : eps [ qi : : _a = true ] > - ( qi : : lit ( " int " ) | qi : : lit ( " double " ) [ qi : : _a = false ] ) > > identifier ) [ phoenix : : bind ( & FormulaParserGrammar : : addConstant , phoenix : : ref ( * this ) , qi : : _1 , qi : : _a ) ] ;
constantDefinition = ( qi : : lit ( " const " ) > - ( qi : : lit ( " int " ) [ qi : : _a = ConstantDataType : : Integer ] | qi : : lit ( " bool " ) [ qi : : _a = ConstantDataType : : Bool ] | qi : : lit ( " double " ) [ qi : : _a = ConstantDataType : : Rational ] ) > > identifier > > - ( qi : : lit ( " = " ) > expressionParser ) ) [ phoenix : : bind ( & FormulaParserGrammar : : addConstant , phoenix : : ref ( * this ) , qi : : _1 , qi : : _a , qi : : _2 ) ] ;
constantDefinition . name ( " constant definition " ) ;
# pragma clang diagnostic push
@ -208,16 +208,25 @@ namespace storm {
this - > identifiers_ . add ( identifier , expression ) ;
}
void FormulaParserGrammar : : addConstant ( std : : string const & name , bool integer ) {
void FormulaParserGrammar : : addConstant ( std : : string const & name , ConstantDataType type , boost : : optional < storm : : expressions : : Expression > const & expression ) {
STORM_LOG_ASSERT ( manager , " Mutable expression manager required to define new constants. " ) ;
storm : : expressions : : Variable newVariable ;
if ( integer ) {
STORM_LOG_THROW ( ! manager - > hasVariable ( name ) , storm : : exceptions : : WrongFormatException , " Invalid constant definition ' " < < name < < " ' in property: variable already exists. " ) ;
if ( type = = ConstantDataType : : Bool ) {
newVariable = manager - > declareBooleanVariable ( name ) ;
} else if ( type = = ConstantDataType : : Integer ) {
newVariable = manager - > declareIntegerVariable ( name ) ;
} else {
newVariable = manager - > declareRationalVariable ( name ) ;
}
if ( expression ) {
addIdentifierExpression ( name , expression . get ( ) ) ;
} else {
addIdentifierExpression ( name , newVariable ) ;
}
}
bool FormulaParserGrammar : : areConstantDefinitionsAllowed ( ) const {
return static_cast < bool > ( manager ) ;
xxxxxxxxxx