Module type Signatures.GLOB


module type GLOB = sig .. end
A self-contained module implementing extended shell glob patterns who have an expressive power equal to boolean combinations of regular expressions.


A globber is a boolean combination of basic expressions indented to work on pathnames. Known operators are or, and and not, which may also be written |, & and ~. There are also constants true and false (or 1 and 0). Expression can be grouped using parentheses. A basic expression can be a constant string enclosed in double quotes, in which double quotes must be preceded by backslashes, or a glob pattern enclosed between a < and a >, A glob pattern is an anchored regular expression in a shell-like syntax. Most characters stand for themselves. Character ranges are given in usual shell syntax between brackets. The star * stands for any sequence of characters. The joker '?' stands for exactly one, unspecified character. Alternation is achieved using braces {.
type globber 
The type representing globbers. Do not attempt to compare them, as they get on-the-fly optimizations.
val parse : ?dir:string -> string -> globber
parse ~dir pattern will parse the globber pattern pattern, optionally prefixing its patterns with dir.
exception Parse_error of string
A descriptive exception raised when an invalid glob pattern description is given.
val eval : globber -> string -> bool
eval g u returns true if and only if the string u matches the given glob expression. Avoid reparsing the same pattern, since the automaton implementing the pattern is optimized on the fly. The first few evaluations are done using a time-inefficient but memory-efficient algorithm. It then compiles the pattern into an efficient but more memory-hungry data structure.