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