Browse Source

Output line number for GalileoParser errors

tempestpy_adaptions
Matthias Volk 6 years ago
parent
commit
15bcb8afb6
  1. 38
      src/storm-dft/parser/DFTGalileoParser.cpp
  2. 3
      src/storm-dft/parser/DFTGalileoParser.h

38
src/storm-dft/parser/DFTGalileoParser.cpp

@ -145,7 +145,7 @@ namespace storm {
ValueType probability = valueParser.parseValue(type.substr(5));
success = builder.addDepElement(name, childNames, probability);
} else if (type.find("=") != std::string::npos) {
success = parseBasicElement(name, line, builder, valueParser);
success = parseBasicElement(name, line, lineNo, builder, valueParser);
} else if (type.find("insp") != std::string::npos) {
// Inspection as defined by DFTCalc
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Inspections (defined in line " << lineNo << ") are not supported.");
@ -204,7 +204,7 @@ namespace storm {
}
template<typename ValueType>
bool DFTGalileoParser<ValueType>::parseBasicElement(std::string const& name, std::string const& input, storm::builder::DFTBuilder<ValueType>& builder, ValueParser<ValueType>& valueParser) {
bool DFTGalileoParser<ValueType>::parseBasicElement(std::string const& name, std::string const& input, size_t lineNo, storm::builder::DFTBuilder<ValueType>& builder, ValueParser<ValueType>& valueParser) {
// Default values
Distribution distribution = Distribution::None;
ValueType firstValDistribution = storm::utility::zero<ValueType>();
@ -220,14 +220,14 @@ namespace storm {
// Constant distribution
std::pair<bool, ValueType> result = parseValue("prob", line, valueParser);
if (result.first) {
STORM_LOG_THROW(distribution == Distribution::None, storm::exceptions::WrongFormatException, "A different distribution was already defined for this basic element.");
STORM_LOG_THROW(distribution == Distribution::None, storm::exceptions::WrongFormatException, "A different distribution was already defined for basic element '" << name << "' in line " << lineNo << ".");
firstValDistribution = result.second;
distribution = Distribution::Constant;
}
// Exponential distribution
result = parseValue("lambda", line, valueParser);
if (result.first) {
STORM_LOG_THROW(distribution == Distribution::None || distribution == Distribution::Erlang, storm::exceptions::WrongFormatException, "A different distribution was already defined for this basic element.");
STORM_LOG_THROW(distribution == Distribution::None || distribution == Distribution::Erlang, storm::exceptions::WrongFormatException, "A different distribution was already defined for basic element '" << name << "' in line " << lineNo << ".");
firstValDistribution = result.second;
if (distribution == Distribution::None) {
distribution = Distribution::Exponential;
@ -236,53 +236,53 @@ namespace storm {
// Erlang distribution
std::pair<bool, unsigned> resultNum = parseNumber("phases", line);
if (resultNum.first) {
STORM_LOG_THROW(distribution == Distribution::None || distribution == Distribution::Exponential, storm::exceptions::WrongFormatException, "A different distribution was already defined for this basic element.");
STORM_LOG_THROW(distribution == Distribution::None || distribution == Distribution::Exponential, storm::exceptions::WrongFormatException, "A different distribution was already defined for basic element '" << name << "' in line " << lineNo << ".");
erlangPhases = resultNum.second;
distribution = Distribution::Erlang;
}
// Weibull distribution
result = parseValue("rate", line, valueParser);
if (result.first) {
STORM_LOG_THROW(distribution == Distribution::None || distribution == Distribution::Weibull, storm::exceptions::WrongFormatException, "A different distribution was already defined for this basic element.");
STORM_LOG_THROW(distribution == Distribution::None || distribution == Distribution::Weibull, storm::exceptions::WrongFormatException, "A different distribution was already defined for basic element '" << name << "' in line " << lineNo << ".");
firstValDistribution = result.second;
distribution = Distribution::Weibull;
}
result = parseValue("shape", line, valueParser);
if (result.first) {
STORM_LOG_THROW(distribution == Distribution::None || distribution == Distribution::Weibull, storm::exceptions::WrongFormatException, "A different distribution was already defined for this basic element.");
STORM_LOG_THROW(distribution == Distribution::None || distribution == Distribution::Weibull, storm::exceptions::WrongFormatException, "A different distribution was already defined for basic element '" << name << "' in line " << lineNo << ".");
secondValDistribution = result.second;
distribution = Distribution::Weibull;
}
// Lognormal distribution
result = parseValue("mean", line, valueParser);
if (result.first) {
STORM_LOG_THROW(distribution == Distribution::None || distribution == Distribution::LogNormal, storm::exceptions::WrongFormatException, "A different distribution was already defined for this basic element.");
STORM_LOG_THROW(distribution == Distribution::None || distribution == Distribution::LogNormal, storm::exceptions::WrongFormatException, "A different distribution was already defined for basic element '" << name << "' in line " << lineNo << ".");
firstValDistribution = result.second;
distribution = Distribution::LogNormal;
}
result = parseValue("stddev", line, valueParser);
if (result.first) {
STORM_LOG_THROW(distribution == Distribution::None || distribution == Distribution::LogNormal, storm::exceptions::WrongFormatException, "A different distribution was already defined for this basic element.");
STORM_LOG_THROW(distribution == Distribution::None || distribution == Distribution::LogNormal, storm::exceptions::WrongFormatException, "A different distribution was already defined for basic element '" << name << "' in line " << lineNo << ".");
secondValDistribution = result.second;
distribution = Distribution::LogNormal;
}
// Additional arguments
result = parseValue("cov", line, valueParser);
if (result.first) {
STORM_LOG_WARN("Coverage is not supported and will be ignored.");
STORM_LOG_WARN("Coverage is not supported and will be ignored for basic element '" << name << "' in line " << lineNo << ".");
}
result = parseValue("res", line, valueParser);
if (result.first) {
STORM_LOG_WARN("Restoration is not supported and will be ignored.");
STORM_LOG_WARN("Restoration is not supported and will be ignored for basic element '" << name << "' in line " << lineNo << ".");
}
resultNum = parseNumber("repl", line);
if (resultNum.first) {
replication = resultNum.second;
STORM_LOG_THROW(replication == 1, storm::exceptions::NotSupportedException, "Replication > 1 is not supported.");
STORM_LOG_THROW(replication == 1, storm::exceptions::NotSupportedException, "Replication > 1 is not supported for basic element '" << name << "' in line " << lineNo << ".");
}
result = parseValue("interval", line, valueParser);
if (result.first) {
STORM_LOG_WARN("Interval is not supported and will be ignored.");
STORM_LOG_WARN("Interval is not supported and will be ignored for basic element '" << name << "' in line " << lineNo << ".");
}
result = parseValue("dorm", line, valueParser);
if (result.first) {
@ -290,12 +290,12 @@ namespace storm {
}
boost::trim(line);
if (line != "") {
STORM_LOG_THROW(false, storm::exceptions::WrongFormatException, "Unknown arguments: " << line << ".");
STORM_LOG_THROW(false, storm::exceptions::WrongFormatException, "Unknown arguments for basic element '" << name << "' in line " << lineNo << ": " << line);
}
switch (distribution) {
case Constant:
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Constant distribution is not supported.");
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Constant distribution is not supported for basic element '" << name << "' in line " << lineNo << ".");
break;
case Exponential:
return builder.addBasicElement(parseName(name), firstValDistribution, dormancyFactor, false); // TODO set transient BEs
@ -307,7 +307,7 @@ namespace storm {
} else {
// Model Erlang distribution by using SEQ over BEs instead.
// For each phase a BE is added, then the SEQ ensures the ordered failure.
STORM_LOG_WARN("Erlang distribution is modelled by SEQ gate and BEs.");
STORM_LOG_WARN("Erlang distribution for basic element '" << name << "' in line " << lineNo << " is modelled by SEQ gate and BEs.");
std::string origName = parseName(name);
std::vector<std::string> childNames;
bool success = builder.addBasicElement(origName, firstValDistribution, dormancyFactor, false); // TODO set transient BEs
@ -325,16 +325,16 @@ namespace storm {
// Weibull distribution reduces to exponential distribution
return builder.addBasicElement(parseName(name), firstValDistribution, dormancyFactor, false); // TODO set transient BEs
} else {
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Weibull distribution is not supported.");
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Weibull distribution is not supported for basic element '" << name << "' in line " << lineNo << ".");
}
break;
case LogNormal:
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "LogNormal distribution is not supported.");
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "LogNormal distribution is not supported for basic element '" << name << "' in line " << lineNo << ".");
break;
case None:
// go-through
default:
STORM_LOG_THROW(false, storm::exceptions::WrongFormatException, "No distribution for basic element defined.");
STORM_LOG_THROW(false, storm::exceptions::WrongFormatException, "No distribution defined for basic element '" << name << "' in line " << lineNo << ".");
break;
}
return false;

3
src/storm-dft/parser/DFTGalileoParser.h

@ -47,12 +47,13 @@ namespace storm {
*
* @param name Name of BE.
* @param input Input line.
* @param lineNo Line number.
* @param builder DFTBuilder.
* @param valueParser ValueParser.
*
* @return True iff the parsing and creation was successful.
*/
static bool parseBasicElement(std::string const& name, std::string const& input, storm::builder::DFTBuilder<ValueType>& builder, ValueParser<ValueType>& valueParser);
static bool parseBasicElement(std::string const& name, std::string const& input, size_t lineNo, storm::builder::DFTBuilder<ValueType>& builder, ValueParser<ValueType>& valueParser);
/*!
* Parse argument of basic element of the form "name=value".
Loading…
Cancel
Save