| 1 |
exception Error of string
|
| 2 |
open Ident
|
| 3 |
|
| 4 |
(* Pattern algebra *)
|
| 5 |
|
| 6 |
type descr
|
| 7 |
type node
|
| 8 |
|
| 9 |
val make: fv -> node
|
| 10 |
val define: node -> descr -> unit
|
| 11 |
|
| 12 |
val constr : Types.descr -> descr
|
| 13 |
val cup : descr -> descr -> descr
|
| 14 |
val cap : descr -> descr -> descr
|
| 15 |
|
| 16 |
val times : node -> node -> descr
|
| 17 |
val xml : node -> node -> descr
|
| 18 |
val record : label -> node -> descr
|
| 19 |
|
| 20 |
val capture : id -> descr
|
| 21 |
val constant: id -> Types.const -> descr
|
| 22 |
|
| 23 |
val id: node -> int
|
| 24 |
val descr: node -> descr
|
| 25 |
val fv : node -> fv
|
| 26 |
|
| 27 |
(* Pattern matching: static semantics *)
|
| 28 |
|
| 29 |
val accept : node -> Types.node
|
| 30 |
val filter : Types.descr -> node -> (id * Types.node) list
|
| 31 |
|
| 32 |
|
| 33 |
(* Pattern matching: compilation *)
|
| 34 |
|
| 35 |
module Compile: sig
|
| 36 |
type dispatcher
|
| 37 |
|
| 38 |
type actions =
|
| 39 |
| AIgnore of result
|
| 40 |
| AKind of actions_kind
|
| 41 |
and actions_kind = {
|
| 42 |
basic: (Types.descr * result) list;
|
| 43 |
atoms: result Atoms.map;
|
| 44 |
chars: result Chars.map;
|
| 45 |
prod: result dispatch dispatch;
|
| 46 |
xml: result dispatch dispatch;
|
| 47 |
record: record option;
|
| 48 |
}
|
| 49 |
and record =
|
| 50 |
| RecLabel of label * result dispatch dispatch
|
| 51 |
| RecNolabel of result option * result option
|
| 52 |
and 'a dispatch =
|
| 53 |
| Dispatch of dispatcher * 'a array
|
| 54 |
| TailCall of dispatcher
|
| 55 |
| Ignore of 'a
|
| 56 |
| Impossible
|
| 57 |
|
| 58 |
and result = int * source array
|
| 59 |
and source =
|
| 60 |
| Catch | Const of Types.const
|
| 61 |
| Left of int | Right of int | Recompose of int * int
|
| 62 |
|
| 63 |
val actions: dispatcher -> actions
|
| 64 |
|
| 65 |
val make_branches :
|
| 66 |
Types.descr -> (node * 'a) list ->
|
| 67 |
dispatcher * (int id_map * 'a) array
|
| 68 |
|
| 69 |
val print_dispatcher: Format.formatter -> dispatcher -> unit
|
| 70 |
|
| 71 |
val debug_compile : Format.formatter -> Types.node -> node list -> unit
|
| 72 |
end
|