Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 76 lines (63 sloc) 1.981 kb
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 (* cf mli *)
19
20 (* shorthands *)
21 module Q = QmlAst
22
23 (* -- *)
24 type t =
25 {
26 database : Q.code_elt list;
27 new_type : Q.code_elt list;
28 new_db_value : Q.code_elt list;
29 new_val : Q.code_elt list;
30 }
31
d132a77 @fpessaux [cleanup] Unused code: Annotmaps et QmlpAst stuff.
fpessaux authored
32 let empty =
fccc685 Initial open-source release
MLstate authored
33 {
34 database = [];
35 new_type = [];
36 new_db_value = [];
37 new_val = [];
38 }
39
40 let add_elt env elt = match elt with
41 | Q.Database _ -> { env with database = elt::env.database }
42 | Q.NewDbValue _ -> { env with new_db_value = elt::env.new_db_value }
43 | Q.NewType _ -> { env with new_type = elt::env.new_type }
d132a77 @fpessaux [cleanup] Unused code: Annotmaps et QmlpAst stuff.
fpessaux authored
44 | Q.NewVal _
fccc685 Initial open-source release
MLstate authored
45 | Q.NewValRec _ -> { env with new_val = elt::env.new_val }
46
47 let add = List.fold_left add_elt
48
49 let get t = (* tail without @ *)
50 let rec rev acc = function
51 | [] -> acc
52 | t::q -> rev (t::acc) q in
53 let acc = [] in
54 let acc = rev acc t.new_val in
55 let acc = rev acc t.new_db_value in
56 let acc = rev acc t.new_type in
57 rev acc t.database
58
d132a77 @fpessaux [cleanup] Unused code: Annotmaps et QmlpAst stuff.
fpessaux authored
59 module Get =
fccc685 Initial open-source release
MLstate authored
60 struct
61 let all = get
62 let database t = List.rev t.database
63 let new_type t = List.rev t.new_type
64 let new_db_value t = List.rev t.new_db_value
65 let new_val t = List.rev t.new_val
d132a77 @fpessaux [cleanup] Unused code: Annotmaps et QmlpAst stuff.
fpessaux authored
66 end
fccc685 Initial open-source release
MLstate authored
67
68 (** need a Rev-Get for custom concat (e.g. in a filter Ast) *)
d132a77 @fpessaux [cleanup] Unused code: Annotmaps et QmlpAst stuff.
fpessaux authored
69 module RevGet =
fccc685 Initial open-source release
MLstate authored
70 struct
71 let database t = t.database
72 let new_type t = t.new_type
73 let new_db_value t = t.new_db_value
74 let new_val t = t.new_val
d132a77 @fpessaux [cleanup] Unused code: Annotmaps et QmlpAst stuff.
fpessaux authored
75 end
Something went wrong with that request. Please try again.