aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Herbelin2020-03-05 23:12:28 +0100
committerPierre-Marie Pédrot2020-03-10 09:15:37 +0100
commitec2f7507daaa5d3fa7ba365e542351457a237f43 (patch)
tree8dd9ec49614abc93d14a894532b4491cef79f387
parentfea01ea28b9fdfd9fb5be91aba982710f55c3aba (diff)
Fixing little bug in parsing decimal numbers in R.
-rw-r--r--plugins/syntax/r_syntax.ml2
-rw-r--r--test-suite/output/RealSyntax.out2
-rw-r--r--test-suite/output/RealSyntax.v2
3 files changed, 5 insertions, 1 deletions
diff --git a/plugins/syntax/r_syntax.ml b/plugins/syntax/r_syntax.ml
index f6fbdaa958..fa824a88ee 100644
--- a/plugins/syntax/r_syntax.ml
+++ b/plugins/syntax/r_syntax.ml
@@ -134,7 +134,7 @@ let r_of_rawnum ?loc (sign,n) =
| '+' -> Bigint.of_string (String.sub e 2 (String.length e - 2))
| '-' -> Bigint.(neg (of_string (String.sub e 2 (String.length e - 2))))
| _ -> Bigint.of_string (String.sub e 1 (String.length e - 1)) in
- Bigint.(sub e (of_int (String.length f))) in
+ Bigint.(sub e (of_int (String.length (String.concat "" (String.split_on_char '_' f))))) in
if Bigint.is_strictly_pos e then rmult n (izr (pow10 e))
else if Bigint.is_strictly_neg e then rdiv n (izr (pow10 (neg e)))
else n (* e = 0 *)
diff --git a/test-suite/output/RealSyntax.out b/test-suite/output/RealSyntax.out
index 2d877bd813..2b14ca7069 100644
--- a/test-suite/output/RealSyntax.out
+++ b/test-suite/output/RealSyntax.out
@@ -2,6 +2,8 @@
: R
(-31)%R
: R
+15e-1%R
+ : R
eq_refl : 102e-2 = 102e-2
: 102e-2 = 102e-2
eq_refl : 102e-1 = 102e-1
diff --git a/test-suite/output/RealSyntax.v b/test-suite/output/RealSyntax.v
index cb3bce70d4..7be8b18ac8 100644
--- a/test-suite/output/RealSyntax.v
+++ b/test-suite/output/RealSyntax.v
@@ -2,6 +2,8 @@ Require Import Reals.Rdefinitions.
Check 32%R.
Check (-31)%R.
+Check 1.5_%R.
+
Open Scope R_scope.
Check (eq_refl : 1.02 = IZR 102 / IZR (Z.pow_pos 10 2)).