summaryrefslogtreecommitdiffstats
path: root/src/ubase/rx.mli
blob: 7018fd2c8a5f1162ea1621a417f1b5b5b68ab48f (plain)
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
(* Unison file synchronizer: src/ubase/rx.mli *)
(* Copyright 1999-2018, Benjamin C. Pierce (see COPYING for details) *)

type t

(* Posix regular expression *)
val rx : string -> t

(* File globbing *)
val glob : string -> t
val glob' : bool -> string -> t
   (* Same, but allows to choose whether dots at the beginning of a
      file name need to be explicitly matched (true) or not (false) *)
val globx : string -> t
val globx' : bool -> string -> t
    (* These two functions also recognize the pattern {...} *)

(* String expression (literal match) *)
val str : string -> t

(* Operations on regular expressions *)
val alt : t list -> t                  (* Alternative *)
val seq : t list -> t                  (* Sequence *)
val empty : t                          (* Match nothing *)
val epsilon : t                        (* Empty word *)
val rep : t -> int -> int option -> t  (* Repeated matches *)
val rep0 : t -> t                      (* 0 or more matches *)
val rep1 : t -> t                      (* 1 or more matches *)
val opt : t -> t                       (* 0 or 1 matches *)
val bol : t                            (* Beginning of line *)
val eol : t                            (* End of line *)
val any : t                            (* Any character *)
val notnl : t                          (* Any character but a newline *)
val set : string -> t                  (* Any character of the string *)
val inter : t list -> t                (* All subexpressions must match *)
val diff : t -> t -> t                 (* The first expression matches
                                          but not the second *)
val case_insensitive : t -> t          (* Case insensitive matching *)

(* Test whether a regular expression matches a string  *)
val match_string : t -> string -> bool

(* Test whether a regular expression matches a substring of the given
   string *)
val match_substring : t -> string -> bool

(* Test whether a regular expression matches some characters of a
   string starting at a given position.  Return the length of
   the matched prefix. *)
val match_prefix : t -> string -> int -> int option

(* Errors that can be raised during the parsing of Posix regular
   expressions *)
exception Parse_error
exception Not_supported