auto_pat.ml 926 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
(* The automata for pattern matching *)
open Ident

type source =
  | Catch | Const of Types.const 
  | Stack of int | Left | Right | Nil | Recompose of int * int

type result = int * source array * int
    (* Return code, result values, number of values to pop *)

type actions =
  | AIgnore of result
  | AKind of actions_kind
and actions_kind = {
  basic: (Types.t * result) list;
  atoms: result Atoms.map;
  chars: result Chars.map;
  prod: result dispatch dispatch;
  xml: result dispatch dispatch;
  record: record option;
}
and record =
  | RecLabel of label * result dispatch dispatch
  | RecNolabel of result option * result option
and 'a dispatch =
  | Dispatch of state * 'a array
  | TailCall of state
  | Ignore of 'a
  | Impossible

and state = {
  uid : int;
33
  arity : int array;
34 35
  mutable actions: actions;
  mutable fail_code: int;
36
  mutable expected_type: string;
37 38 39 40
}


type 'a rhs = Match of int * 'a | Fail