1 (* Copyright (C) 2000, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://cs.unibo.it/helm/.
27 * implementazione del comando SELECT
35 * valutazione di una stringa
42 apply_func f (List.assoc rvar l)
56 let rec is_good l abool =
59 (is_good l b1) && (is_good l b2)
61 (is_good l b1) || (is_good l b2)
69 (stringeval s1 l) = (stringeval s2 l)
75 let rec replace avar newval l =
77 MQAnd (b1, b2) -> MQAnd (replace avar newval b1, replace avar newval b2)
78 | MQOr (b1, b2) -> MQOr (replace avar newval b1, replace avar newval b2)
79 | MQNot b1 -> MQNot (replace avar newval b1)
83 MQRVar v when v = avar -> MQRVar newval
84 | MQFunc (f, v) when v = avar -> MQFunc (f, newval)
89 MQRVar v when v = avar -> MQRVar newval
90 | MQFunc (f, v) when v = avar -> MQFunc (f, newval)
95 | _ -> l (* i casi non compresi sono MQTrue e MQFalse *)
98 (*let rec print_booltree b =
101 let i = print_booltree b1 in
102 let j = print_string " AND " in
105 let i = print_booltree b1 in
106 let j = print_string " OR " in
109 let j = print_string " NOT " in
112 print_string " TRUE "
114 print_string " FALSE "
116 let s1v = match s1 with
119 | MQFunc (f, rvar) ->
122 MQName -> "NAME " ^ rvar
123 | MQTheory -> "THEORY" ^ rvar
124 | MQTitle -> "TITLE" ^ rvar
125 | MQContributor -> "contributor" ^ rvar
126 | MQCreator -> "creator" ^ rvar
127 | MQPublisher -> "publisher" ^ rvar
128 | MQSubject -> "subject" ^ rvar
129 | MQDescription -> "description" ^ rvar
130 | MQDate -> "date" ^ rvar
131 | MQType -> "type" ^ rvar
132 | MQFormat -> "format" ^ rvar
133 | MQIdentifier -> "identifier" ^ rvar
134 | MQLanguage -> "language" ^ rvar
135 | MQRelation -> "relation" ^ rvar
136 | MQSource -> "source" ^ rvar
137 | MQCoverage -> "coverage" ^ rvar
138 | MQRights -> "rights" ^ rvar
139 | MQInstitution -> "institution" ^ rvar
140 | MQContact -> "contact" ^ rvar
141 | MQFirstVersion -> "firstversion" ^ rvar
142 | MQModified -> "modified" ^ rvar
152 and s2v = match s2 with
155 | MQFunc (f, rvar) ->
158 MQName -> "NAME " ^ rvar
159 | MQTheory -> "THEORY" ^ rvar
160 | MQTitle -> "TITLE" ^ rvar
161 | MQContributor -> "contributor" ^ rvar
162 | MQCreator -> "creator" ^ rvar
163 | MQPublisher -> "publisher" ^ rvar
164 | MQSubject -> "subject" ^ rvar
165 | MQDescription -> "description" ^ rvar
166 | MQDate -> "date" ^ rvar
167 | MQType -> "type" ^ rvar
168 | MQFormat -> "format" ^ rvar
169 | MQIdentifier -> "identifier" ^ rvar
170 | MQLanguage -> "language" ^ rvar
171 | MQRelation -> "relation" ^ rvar
172 | MQSource -> "source" ^ rvar
173 | MQCoverage -> "coverage" ^ rvar
174 | MQRights -> "rights" ^ rvar
175 | MQInstitution -> "institution" ^ rvar
176 | MQContact -> "contact" ^ rvar
177 | MQFirstVersion -> "firstversion" ^ rvar
178 | MQModified -> "modified" ^ rvar
189 print_string (s1v ^ " = " ^ s2v)
193 * implementazione del comando SELECT
195 let select_ex avar alist abool =
196 let _ = print_string ("SELECT ")
197 and t = Unix.time () in
199 let wrt = replace avar "retVal" abool in
200 (*let j = print_booltree wrt in*)
204 (fun l -> is_good (List.combine (List.hd alist) l) wrt)
207 let _ = print_endline (string_of_float (Unix.time () -. t)); flush stdout in