2001-09-07 01:00:42 -07:00
|
|
|
(* camlp4r *)
|
|
|
|
(* $Id$ *)
|
|
|
|
|
2002-07-19 07:53:56 -07:00
|
|
|
(** Extensible functions.
|
2001-09-07 01:00:42 -07:00
|
|
|
|
2002-07-19 07:53:56 -07:00
|
|
|
This module implements pattern matching extensible functions.
|
2001-09-07 01:00:42 -07:00
|
|
|
To extend, use syntax [pa_extfun.cmo]:
|
2002-07-19 07:53:56 -07:00
|
|
|
|
|
|
|
[extfun e with [ pattern_matching ]] *)
|
2001-09-07 01:00:42 -07:00
|
|
|
|
|
|
|
type t 'a 'b = 'x;
|
2002-07-19 07:53:56 -07:00
|
|
|
(** The type of the extensible functions of type ['a -> 'b] *)
|
2001-09-07 01:00:42 -07:00
|
|
|
value empty : t 'a 'b;
|
2002-07-19 07:53:56 -07:00
|
|
|
(** Empty extensible function *)
|
2001-09-07 01:00:42 -07:00
|
|
|
value apply : t 'a 'b -> 'a -> 'b;
|
2002-07-19 07:53:56 -07:00
|
|
|
(** Apply an extensible function *)
|
2001-09-07 01:00:42 -07:00
|
|
|
exception Failure;
|
2002-07-19 07:53:56 -07:00
|
|
|
(** Match failure while applying an extensible function *)
|
2001-09-07 01:00:42 -07:00
|
|
|
value print : t 'a 'b -> unit;
|
2002-07-19 07:53:56 -07:00
|
|
|
(** Print patterns in the order they are recorded *)
|
2001-09-07 01:00:42 -07:00
|
|
|
|
2002-07-19 07:53:56 -07:00
|
|
|
(**/**)
|
2001-09-07 01:00:42 -07:00
|
|
|
|
|
|
|
type matching 'a 'b = { patt : patt; has_when : bool; expr : expr 'a 'b }
|
|
|
|
and patt =
|
|
|
|
[ Eapp of list patt
|
|
|
|
| Eacc of list patt
|
|
|
|
| Econ of string
|
|
|
|
| Estr of string
|
|
|
|
| Eint of string
|
|
|
|
| Etup of list patt
|
|
|
|
| Evar of unit ]
|
|
|
|
and expr 'a 'b = 'a -> option 'b
|
|
|
|
;
|
|
|
|
|
|
|
|
value extend : t 'a 'b -> list (patt * bool * expr 'a 'b) -> t 'a 'b;
|