lambda.mli 2.25 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
open Ident

type var_loc =
  | Stack of int
  | Env of int
  | Ext of Types.CompUnit.t * int (* If pos < 0, the first arg is the value *)
  | External of Types.CompUnit.t * int 
      (* If pos < 0, the first arg is the value *)
  | Global of int (* Only for the toplevel *)
  | Dummy

type schema_component_kind =
  [ `Type | `Element | `Attribute | `Attribute_group | `Model_group ] option

type expr = 
  | Var of var_loc
  | Apply of bool * expr * expr
  | Abstraction of var_loc array * (Types.t * Types.t) list * branches

  | Const of Types.Const.t
  | Pair of expr * expr
  | Xml of expr * expr * expr
  | Record of expr label_map
  | String of U.uindex * U.uindex * U.t * expr

  | Match of expr * branches
  | Map of expr * branches
  | Transform of expr * branches
  | Xtrans of expr * branches
  | Try of expr * branches
  | Validate of expr * schema_component_kind * string * U.t
  | RemoveField of expr * label
  | Dot of expr * label
  | UnaryOp of int * expr
  | BinaryOp of int * expr * expr
  | Ref of expr * Types.Node.t

and branches = {
  brs: (Patterns.node * expr) list;
  brs_tail: bool;
  brs_input: Types.t;
  brs_accept_chars: bool;
  mutable brs_compiled: 
    (Patterns.Compile.dispatcher * expr Patterns.Compile.rhs array) option
}

type code_item =
  | Push of expr
  | Pop
  | Split of Patterns.node
  | SetGlobal of Types.CompUnit.t * int

type code = code_item list

module Put :
  sig
    val unary_op : (Serialize.Put.t -> int -> unit) ref
    val binary_op : (Serialize.Put.t -> int -> unit) ref
    val var_loc : Serialize.Put.t -> var_loc -> unit
    val expr : expr Serialize.Put.f
    val branches : Serialize.Put.t -> branches -> unit
    val code_item : Serialize.Put.t -> code_item -> unit
    val codes : code_item list Serialize.Put.f
    val compunit : Serialize.Put.t -> code_item list -> unit
  end
module Get :
  sig
    val unary_op : (Serialize.Get.t -> int) ref
    val binary_op : (Serialize.Get.t -> int) ref
    val var_loc : Serialize.Get.t -> var_loc
    val expr : expr Serialize.Get.f
    val branches : Serialize.Get.t -> branches
    val code_item : Serialize.Get.t -> code_item
    val codes : code_item list Serialize.Get.f
    val compunit : Serialize.Get.t -> code_item list
  end

val print_var_loc : Format.formatter -> var_loc -> unit