Skip to content

Commit 925474c

Browse files
committed
Getting used to ppxlib.
1 parent 74d4b52 commit 925474c

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

syntax/attribute_value.ml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -494,19 +494,20 @@ let fill_opacity =
494494
if not @@ does_match regexp s then bad_form name loc;
495495

496496
begin
497-
let n =
498-
match float_exp loc (Re_str.matched_group 1 s) with
499-
| Some n -> n
500-
| None -> bad_form name loc
501-
in
502497

503-
let v =
504-
if group_matched 2 s then (n /. 100.)
505-
else n in
498+
try
499+
let n = float_of_string (Re_str.matched_group 1 s) in
500+
501+
let v =
502+
if group_matched 2 s then (n /. 100.)
503+
else n in
504+
505+
if v >= 0. && v <= 1. then Some [%expr [%e v]]
506+
else
507+
Common.error loc "Value of %s must be between 0 and 1." name
508+
509+
with Failure _ -> bad_form name loc
506510

507-
if v >= 0. && v <= 1. then Some [%expr [%e v]]
508-
else
509-
Common.error loc "Value of %s must be between 0 and 1." name
510511
end [@metaloc loc]
511512

512513
let fill_rule ?separated_by:_ ?default:_ loc _name s =

0 commit comments

Comments
 (0)