]> matita.cs.unibo.it Git - helm.git/blob - components/extlib/patternMatcher.mli
tagged 0.5.0-rc1
[helm.git] / components / extlib / patternMatcher.mli
1
2 (* Copyright (C) 2005, HELM Team.
3  * 
4  * This file is part of HELM, an Hypertextual, Electronic
5  * Library of Mathematics, developed at the Computer Science
6  * Department, University of Bologna, Italy.
7  * 
8  * HELM is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  * 
13  * HELM is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with HELM; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21  * MA  02111-1307, USA.
22  * 
23  * For details, see the HELM World-Wide-Web page,
24  * http://helm.cs.unibo.it/
25  *)
26
27 type pattern_kind = Variable | Constructor
28 type tag_t = int
29
30 module type PATTERN =
31 sig
32   type pattern_t
33   type term_t
34
35   val classify : pattern_t -> pattern_kind
36   val tag_of_pattern : pattern_t -> tag_t * pattern_t list
37   val tag_of_term : term_t -> tag_t * term_t list
38
39   (** {3 Debugging} *)
40   val string_of_term: term_t -> string
41   val string_of_pattern: pattern_t -> string
42 end
43
44 module Matcher (P: PATTERN) :
45 sig
46   (** @param patterns pattern matrix (pairs <pattern, pattern_id>)
47    * @param success_cb callback invoked in case of matching.
48    *  Its argument are the list of pattern who matches the input term, the list
49    *  of terms bound in them, the list of terms which matched constructors.
50    *  Its return value is Some _ if the matching is valid, None otherwise; the
51    *  latter kind of return value will trigger backtracking in the pattern
52    *  matching algorithm
53    * @param failure_cb callback invoked in case of matching failure
54    * @param term term on which pattern match on *)
55   val compiler:
56     (P.pattern_t * int) list ->
57     ((P.pattern_t list * int) list -> P.term_t list -> P.term_t list ->
58       'a option) ->                   (* terms *)    (* constructors *)
59     (unit -> 'a option) ->
60       (P.term_t -> 'a option)
61 end
62