fwtool: allow udp/tcp for all user rules
[hcoop/domtool2.git] / src / env.sig
1 (* HCoop Domtool (http://hcoop.sourceforge.net/)
2 * Copyright (c) 2006, Adam Chlipala
3 * Copyright (c) 2014 Clinton Ebadi <clinton@unknownlamer.org>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *)
19
20 (* Domtool type-checking and reduction environments *)
21
22 signature ENV = sig
23
24 type typeRule = Ast.exp -> bool
25 val registerType : string * typeRule -> unit
26 val typeRule : string -> typeRule option
27
28 type env_vars = Ast.exp Ast.StringMap.map
29 type action = env_vars * Ast.exp list -> env_vars
30 val registerAction : string * action -> unit
31 val action : string -> action option
32
33 val registerContainer : string * action * (unit -> unit) -> unit
34 val container : string -> (action * (unit -> unit)) option
35
36 (* Actions to take before and after evaluating a file *)
37 val registerPre : (unit -> unit) -> unit
38 val pre : unit -> unit
39 val registerPost : (unit -> unit) -> unit
40 val post : unit -> unit
41
42 (* ...and before type-checking *)
43 val registerPreTycheck : (unit -> unit) -> unit
44 val preTycheck : unit -> unit
45
46 val badArgs : string * Ast.exp list -> 'a
47 val badArg : string * string * Ast.exp -> 'a
48
49 type 'a arg = Ast.exp -> 'a option
50
51 val int : int arg
52 val string : string arg
53 val bool : bool arg
54 val list : 'a arg -> 'a list arg
55
56 val none : string -> (unit -> unit) -> action
57 val one : string -> string * 'a arg -> ('a -> unit) -> action
58 val two : string -> string * 'a arg * string * 'b arg -> ('a * 'b -> unit) -> action
59 val three : string
60 -> string * 'a arg * string * 'b arg * string * 'c arg
61 -> ('a * 'b * 'c -> unit) -> action
62
63 val noneV : string -> (env_vars -> unit) -> action
64 val oneV : string -> string * 'a arg -> (env_vars * 'a -> unit) -> action
65 val twoV : string -> string * 'a arg * string * 'b arg -> (env_vars * 'a * 'b -> unit) -> action
66
67 val env : 'a arg -> env_vars * string -> 'a
68
69 val type_one : string -> 'a arg -> ('a -> bool) -> unit
70
71 val action_none : string -> (unit -> unit) -> unit
72 val action_one : string -> string * 'a arg -> ('a -> unit) -> unit
73 val action_two : string -> string * 'a arg * string * 'b arg -> ('a * 'b -> unit) -> unit
74 val action_three : string
75 -> string * 'a arg * string * 'b arg * string * 'c arg
76 -> ('a * 'b * 'c -> unit) -> unit
77 val action_four : string
78 -> string * 'a arg * string * 'b arg * string * 'c arg * string * 'd arg
79 -> ('a * 'b * 'c * 'd -> unit) -> unit
80
81 val actionV_none : string -> (env_vars -> unit) -> unit
82 val actionV_one : string -> string * 'a arg -> (env_vars * 'a -> unit) -> unit
83 val actionV_two : string -> string * 'a arg * string * 'b arg -> (env_vars * 'a * 'b -> unit) -> unit
84
85 val container_none : string -> (unit -> unit) * (unit -> unit) -> unit
86 val container_one : string -> string * 'a arg -> ('a -> unit) * (unit -> unit) -> unit
87
88 val containerV_none : string -> (env_vars -> unit) * (unit -> unit) -> unit
89 val containerV_one : string -> string * 'a arg -> (env_vars * 'a -> unit) * (unit -> unit) -> unit
90
91 val registerFunction : string * (Ast.exp list -> Ast.exp option) -> unit
92 val function : string -> (Ast.exp list -> Ast.exp option) option
93
94 type env
95 val empty : env
96
97 val initialDynEnvTypes : env -> Ast.typ Ast.StringMap.map
98 val initialDynEnvVals : (env -> Ast.exp -> Ast.exp) -> env -> env_vars
99
100 val bindType : env -> string -> env
101 val bindVal : env -> string * Ast.typ * Ast.exp option -> env
102 val bindContext : env -> string -> env
103 val bindInitialDynEnvVal : env -> string * Ast.typ * Ast.exp -> env
104
105 val lookupType : env -> string -> bool
106 val lookupVal : env -> string -> Ast.typ option
107 val lookupEquation : env -> string -> (Ast.exp * env) option
108 val lookupContext : env -> string -> bool
109 val lookupInitialDynEnvVal : env -> string -> Ast.typ option
110
111 val types : env -> Ast.StringSet.set
112 val vals : env -> Ast.StringSet.set
113 val contexts : env -> Ast.StringSet.set
114 val dynamics : env -> Ast.StringSet.set
115 end