From f1ce23b1b4df16d478bfb65d7830fced9d26f0d7 Mon Sep 17 00:00:00 2001 From: Dave Parker Date: Tue, 7 Jul 2015 00:30:41 +0000 Subject: [PATCH] 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 --- prism/src/parser/ast/Property.java | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/prism/src/parser/ast/Property.java b/prism/src/parser/ast/Property.java index f6f6a154..77e3bc3f 100644 --- a/prism/src/parser/ast/Property.java +++ b/prism/src/parser/ast/Property.java @@ -366,19 +366,9 @@ public class Property extends ASTElement if (!rationalRes.isNaN()) 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 { - throw new PrismException("Invalid RESULT specification \"" + strExpected + "\" for rational-valued property"); + rationalExp = new BigRational(strExpected); } } catch (NumberFormatException e) { throw new PrismException("Invalid RESULT specification \"" + strExpected + "\" for rational-valued property");