package dune-private-libs
Private libraries of Dune
Install
Dune Dependency
Authors
Maintainers
Sources
dune-3.19.1.tbz
sha256=a10386f980cda9417d1465466bed50dd2aef9c93b9d06a0f7feeedb0a1541158
sha512=d1622939713133a1f28617229896298d6ef194c48a47d011e4b752490fc83893cc920a8395d7ac60bc384a6c9b233ebf0665f38f74f2774a983e9d3b241a7746
doc/src/dune-private-libs.dune_re/group.ml.html
Source file group.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
(* Result of a successful match. *) type t = { s : string ; marks : Automata.mark_infos ; pmarks : Pmark.Set.t ; gpos : int array ; gcount : int } let offset t i = if 2 * i + 1 >= Array.length t.marks then raise Not_found; let m1 = t.marks.(2 * i) in if m1 = -1 then raise Not_found; let p1 = t.gpos.(m1) in let p2 = t.gpos.(t.marks.(2 * i + 1)) in (p1, p2) let get t i = let (p1, p2) = offset t i in String.sub t.s p1 (p2 - p1) let start subs i = fst (offset subs i) let stop subs i = snd (offset subs i) let test t i = if 2 * i >= Array.length t.marks then false else let idx = t.marks.(2 * i) in idx <> -1 let get_opt t i = if test t i then Some (get t i) else None let dummy_offset = (-1, -1) let all_offset t = let res = Array.make t.gcount dummy_offset in for i = 0 to Array.length t.marks / 2 - 1 do let m1 = t.marks.(2 * i) in if m1 <> -1 then begin let p1 = t.gpos.(m1) in let p2 = t.gpos.(t.marks.(2 * i + 1)) in res.(i) <- (p1, p2) end done; res let dummy_string = "" let all t = let res = Array.make t.gcount dummy_string in for i = 0 to Array.length t.marks / 2 - 1 do let m1 = t.marks.(2 * i) in if m1 <> -1 then begin let p1 = t.gpos.(m1) in let p2 = t.gpos.(t.marks.(2 * i + 1)) in res.(i) <- String.sub t.s p1 (p2 - p1) end done; res let pp fmt t = let matches = let offsets = all_offset t in let strs = all t in Array.to_list ( Array.init (Array.length strs) (fun i -> strs.(i), offsets.(i)) ) in let open Fmt in let pp_match fmt (str, (start, stop)) = fprintf fmt "@[(%s (%d %d))@]" str start stop in sexp fmt "Group" (list pp_match) matches let nb_groups t = t.gcount
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>