Skip to content

Commit

Permalink
Getting used to ppxlib.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mbodin committed Nov 30, 2023
1 parent 74d4b52 commit 925474c
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions syntax/attribute_value.ml
Original file line number Diff line number Diff line change
Expand Up @@ -494,19 +494,20 @@ let fill_opacity =
if not @@ does_match regexp s then bad_form name loc;

begin
let n =
match float_exp loc (Re_str.matched_group 1 s) with
| Some n -> n
| None -> bad_form name loc
in

let v =
if group_matched 2 s then (n /. 100.)
else n in
try
let n = float_of_string (Re_str.matched_group 1 s) in

let v =
if group_matched 2 s then (n /. 100.)
else n in

if v >= 0. && v <= 1. then Some [%expr [%e v]]
else
Common.error loc "Value of %s must be between 0 and 1." name

with Failure _ -> bad_form name loc

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

let fill_rule ?separated_by:_ ?default:_ loc _name s =
Expand Down

0 comments on commit 925474c

Please sign in to comment.