(*
   RE - A regular expression library

   Copyright (C) 2001 Jerome Vouillon
   email: Jerome.Vouillon@pps.jussieu.fr

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*)

(*
   References:
     http://www.opengroup.org/onlinepubs/007908799/xbd/re.html
     http://www.opengroup.org/onlinepubs/007908799/xsh/regcomp.html
*)

(* XXX Character classes *)

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

type opt = [`ICase | `NoSub | `Newline]

(* Parsing of a Posix extended regular expression *)
val re : ?opts:(opt list) -> string -> Re.t

(* Regular expression compilation *)
val compile : Re.t -> Re.re
   (* [compile r] is defined as [Re.compile (Re.longest r)] *)
val compile_pat : ?opts:(opt list) -> string -> Re.re

(*
Deviation from the standard / ambiguities in the standard
---------------------------------------------------------
We tested the behavior of the Linux library (glibc) and the Solaris
library.

(1) An expression [efg] should be parsed as [(ef)g].
    All implementations parse it as [e(fg)].
(2) When matching the pattern "((a)|b)*" against the string "ab",
    the sub-expression "((a)|b)" should match "b", and the
    sub-expression "(a)" should not match anything.
    In both implementation, the sub-expression "(a)" matches "a".
(3) When matching the pattern "(aa?)*" against the string "aaa", it is
    not clear whether the final match of the sub-expression "(aa?)"  is
    the last "a" (all matches of the sub-expression are successively
    maximized), or "aa" (the final match is maximized).
    Both implementations implements the first case.
(4) When matching the pattern "((a?)|b)*" against the string "ab",
    the sub-expression "((a?)|b)" should match the empty string at the
    end of the string (it is better to match the empty string than to
    match nothing).
    In both implementations, this sub-expression matches "b".
    (Strangely, in the Linux implementation, the sub-expression "(a?)"
     correctly matches the empty string at the end of the string)

This library behaves the same way as the other libraries for all
points, except for (2) and (4) where it follows the standard.

The behavior of this library in theses four cases may change in future
releases.
*)
