Browse Source

Simplify/iimprove checking of rational results: can convert doubles.

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@10213 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 11 years ago
parent
commit
f1ce23b1b4
  1. 14
      prism/src/parser/ast/Property.java

14
prism/src/parser/ast/Property.java

@ -366,19 +366,9 @@ public class Property extends ASTElement
if (!rationalRes.isNaN()) if (!rationalRes.isNaN())
throw new PrismException("Wrong result (expected NaN, got " + rationalRes + ")"); throw new PrismException("Wrong result (expected NaN, got " + rationalRes + ")");
} }
// See if it's an integer
else if (strExpected.matches("[0-9]+")) {
int val = Integer.parseInt(strExpected);
rationalExp = new BigRational(val, 1);
}
// See if it's a fraction
else if (strExpected.matches("[0-9]+/[0-9]+")) {
int numer = Integer.parseInt(strExpected.substring(0, strExpected.indexOf('/')));
int denom = Integer.parseInt(strExpected.substring(strExpected.indexOf('/') + 1));
rationalExp = new BigRational(numer, denom);
}
// For integers/rationals/doubles, parse with BigRational if it's an integer
else { else {
throw new PrismException("Invalid RESULT specification \"" + strExpected + "\" for rational-valued property");
rationalExp = new BigRational(strExpected);
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw new PrismException("Invalid RESULT specification \"" + strExpected + "\" for rational-valued property"); throw new PrismException("Invalid RESULT specification \"" + strExpected + "\" for rational-valued property");

Loading…
Cancel
Save