| 1 |
abate |
1 |
type capture = string
|
| 2 |
|
|
type fv = capture SortedList.t
|
| 3 |
|
|
|
| 4 |
abate |
107 |
exception Error of string
|
| 5 |
abate |
1 |
|
| 6 |
|
|
(* Pattern algebra *)
|
| 7 |
|
|
|
| 8 |
|
|
type descr
|
| 9 |
|
|
type node
|
| 10 |
|
|
|
| 11 |
|
|
val make: fv -> node
|
| 12 |
|
|
val define: node -> descr -> unit
|
| 13 |
|
|
|
| 14 |
|
|
val constr : Types.node -> descr
|
| 15 |
|
|
val cup : descr -> descr -> descr
|
| 16 |
abate |
54 |
val cap : descr -> descr -> bool -> descr
|
| 17 |
abate |
1 |
|
| 18 |
|
|
val times : node -> node -> descr
|
| 19 |
abate |
110 |
val xml : node -> node -> descr
|
| 20 |
abate |
1 |
val record : Types.label -> node -> descr
|
| 21 |
|
|
|
| 22 |
|
|
val capture : capture -> descr
|
| 23 |
|
|
val constant: capture -> Types.const -> descr
|
| 24 |
|
|
|
| 25 |
|
|
val id: node -> int
|
| 26 |
|
|
val descr: node -> descr
|
| 27 |
|
|
val fv : node -> fv
|
| 28 |
|
|
|
| 29 |
|
|
(* Pattern matching: static semantics *)
|
| 30 |
|
|
|
| 31 |
|
|
val accept : node -> Types.node
|
| 32 |
|
|
val filter : Types.descr -> node -> (capture,Types.node) SortedMap.t
|
| 33 |
|
|
|
| 34 |
|
|
(* Pattern matching: compilation *)
|
| 35 |
|
|
|
| 36 |
abate |
43 |
module Compile: sig
|
| 37 |
|
|
type normal
|
| 38 |
|
|
val normal : descr -> normal
|
| 39 |
|
|
|
| 40 |
|
|
type dispatcher
|
| 41 |
abate |
45 |
val dispatcher: Types.descr -> normal array -> dispatcher
|
| 42 |
|
|
|
| 43 |
abate |
56 |
type actions =
|
| 44 |
|
|
[ `Ignore of result
|
| 45 |
|
|
| `Kind of actions_kind ]
|
| 46 |
|
|
and actions_kind = {
|
| 47 |
abate |
45 |
basic: (Types.descr * result) list;
|
| 48 |
|
|
prod: result dispatch dispatch;
|
| 49 |
abate |
110 |
xml: result dispatch dispatch;
|
| 50 |
abate |
45 |
record: record option;
|
| 51 |
|
|
}
|
| 52 |
|
|
and record =
|
| 53 |
|
|
[ `Label of Types.label * record dispatch * record option
|
| 54 |
abate |
75 |
| `Result of result
|
| 55 |
|
|
| `Absent ]
|
| 56 |
abate |
45 |
|
| 57 |
|
|
and 'a dispatch =
|
| 58 |
|
|
[ `Dispatch of dispatcher * 'a array
|
| 59 |
|
|
| `TailCall of dispatcher
|
| 60 |
|
|
| `Ignore of 'a
|
| 61 |
|
|
| `None ]
|
| 62 |
|
|
|
| 63 |
|
|
and result = int * source array
|
| 64 |
|
|
and source =
|
| 65 |
|
|
[ `Catch | `Const of Types.const
|
| 66 |
|
|
| `Left of int | `Right of int | `Recompose of int * int
|
| 67 |
|
|
| `Field of Types.label * int
|
| 68 |
|
|
]
|
| 69 |
|
|
|
| 70 |
|
|
val actions: dispatcher -> actions
|
| 71 |
|
|
|
| 72 |
abate |
43 |
val show : Format.formatter -> Types.descr -> normal array -> unit
|
| 73 |
abate |
46 |
|
| 74 |
|
|
val make_branches :
|
| 75 |
|
|
Types.descr -> (descr * 'a) list ->
|
| 76 |
|
|
dispatcher * ((capture, int) SortedMap.t * 'a) array
|
| 77 |
abate |
1 |
end
|