-eval.cmi: mathql.cmo
-func.cmi: mathql.cmo
-sortedby.cmi: mathql.cmo
-select.cmi: mathql.cmo mathql_semantics.cmo
+select.cmi: mathql_semantics.cmo
intersect.cmi: mathql_semantics.cmo
union.cmi: mathql_semantics.cmo
-pattern.cmi: mathql.cmo mathql_semantics.cmo
-use.cmi: mathql.cmo mathql_semantics.cmo
-mqint.cmi: mathql.cmo
-mathql_semantics.cmo: mathql.cmo
-mathql_semantics.cmx: mathql.cmx
-dbconn.cmo: mathql.cmo dbconn.cmi
-dbconn.cmx: mathql.cmx dbconn.cmi
-eval.cmo: mathql.cmo eval.cmi
-eval.cmx: mathql.cmx eval.cmi
+pattern.cmi: mathql_semantics.cmo
+use.cmi: mathql_semantics.cmo
+dbconn.cmo: dbconn.cmi
+dbconn.cmx: dbconn.cmi
+eval.cmo: eval.cmi
+eval.cmx: eval.cmi
utility.cmo: dbconn.cmi utility.cmi
utility.cmx: dbconn.cmx utility.cmi
-func.cmo: dbconn.cmi mathql.cmo utility.cmi func.cmi
-func.cmx: dbconn.cmx mathql.cmx utility.cmx func.cmi
+func.cmo: dbconn.cmi utility.cmi func.cmi
+func.cmx: dbconn.cmx utility.cmx func.cmi
diff.cmo: diff.cmi
diff.cmx: diff.cmi
-sortedby.cmo: func.cmi mathql.cmo utility.cmi sortedby.cmi
-sortedby.cmx: func.cmx mathql.cmx utility.cmx sortedby.cmi
-select.cmo: func.cmi mathql.cmo mathql_semantics.cmo utility.cmi select.cmi
-select.cmx: func.cmx mathql.cmx mathql_semantics.cmx utility.cmx select.cmi
+sortedby.cmo: func.cmi utility.cmi sortedby.cmi
+sortedby.cmx: func.cmx utility.cmx sortedby.cmi
+select.cmo: func.cmi mathql_semantics.cmo utility.cmi select.cmi
+select.cmx: func.cmx mathql_semantics.cmx utility.cmx select.cmi
intersect.cmo: mathql_semantics.cmo intersect.cmi
intersect.cmx: mathql_semantics.cmx intersect.cmi
union.cmo: mathql_semantics.cmo union.cmi
pattern.cmx: dbconn.cmx eval.cmx mathql_semantics.cmx utility.cmx pattern.cmi
use.cmo: dbconn.cmi mathql_semantics.cmo utility.cmi use.cmi
use.cmx: dbconn.cmx mathql_semantics.cmx utility.cmx use.cmi
-mqint.cmo: dbconn.cmi diff.cmi eval.cmi intersect.cmi mathql.cmo \
- mathql_semantics.cmo pattern.cmi select.cmi sortedby.cmi union.cmi \
- use.cmi utility.cmi mqint.cmi
-mqint.cmx: dbconn.cmx diff.cmx eval.cmx intersect.cmx mathql.cmx \
- mathql_semantics.cmx pattern.cmx select.cmx sortedby.cmx union.cmx \
- use.cmx utility.cmx mqint.cmi
+mqint.cmo: dbconn.cmi diff.cmi eval.cmi intersect.cmi mathql_semantics.cmo \
+ pattern.cmi select.cmi sortedby.cmi union.cmi use.cmi utility.cmi \
+ mqint.cmi
+mqint.cmx: dbconn.cmx diff.cmx eval.cmx intersect.cmx mathql_semantics.cmx \
+ pattern.cmx select.cmx sortedby.cmx union.cmx use.cmx utility.cmx \
+ mqint.cmi
PACKAGE = mathql_interpreter
-REQUIRES = helm-urimanager pgocaml unix
+REQUIRES = helm-urimanager pgocaml unix helm-mathql
PREDICATES =
INTERFACE_FILES = dbconn.mli eval.mli utility.mli func.mli diff.mli \
sortedby.mli select.mli intersect.mli union.mli \
pattern.mli use.mli mqint.mli
-IMPLEMENTATION_FILES = mathql.ml mathql_semantics.ml \
+IMPLEMENTATION_FILES = mathql_semantics.ml \
$(INTERFACE_FILES:%.mli=%.ml)
-EXTRA_OBJECTS_TO_INSTALL = mathql.ml mathql.cmi mathql_semantics.ml \
- mathql_semantics.cmi
+EXTRA_OBJECTS_TO_INSTALL = mathql_semantics.ml mathql_semantics.cmi
+
EXTRA_OBJECTS_TO_CLEAN =
* le eccezioni lanciate dalle funzioni init e pgc sono
* definite nel modulo Mathql
*)
-open Mathql;;
+open MathQL;;
(*
* paramentri della connessione
*
*)
-open Mathql;;
+open MathQL;;
(*
* conversione di un pattern
[] -> ""
| head::tail ->
let h = match head with
- MQString (s) -> Str.global_replace (Str.regexp "\.") "\\\\\." s
- | MQSlash -> "/"
- | MQAnyChr -> "[^/#]?"
- | MQAst -> "[^/#]*"
- | MQAstAst -> "[^#]*"
+ MQBC (s) -> Str.global_replace (Str.regexp "\.") "\\\\\." s
+ | MQBD -> "/"
+ | MQBQ -> "[^/#]?"
+ | MQBS -> "[^/#]*"
+ | MQBSS -> "[^#]*"
in
h ^ (patterneval tail)
;;
* conversione di un fragment identifier
*)
let fieval fi =
- match fst fi with
- None -> ""
- | Some i ->
+match fi with
+ [] -> ""
+ | MQFC i :: tail ->
let s = "#xpointer\\\\(1/" ^ string_of_int (i) in
- match snd fi with
- None ->
- s ^ "\\\\)"
- | Some j ->
+ match tail with
+ [] -> s ^ "\\\\)"
+ | MQFC j :: tail2 ->
s ^ "/" ^ string_of_int j ^ "\\\\)"
;;
* valuta il preambolo
*)
let preeval p =
- p
+ match p with
+ Some s -> s
;;
(*
* SQL standard LIKE perche' MathQL prevede esperssioni con "*"
* e con "**".
*)
-let pattern_match preamble pattern fragid =
+let pattern_match (preamble, pattern, fragid) =
" ~ '" ^ (preeval preamble) ^ ":/" ^ (patterneval pattern) ^ (fieval fragid) ^ "'"
;;
*)
val pattern_match :
- string ->
- Mathql.mquptoken list -> int option * int option -> string
+ MathQL.mqtref -> string
open Dbconn;;
open Utility;;
-open Mathql;;
+open MathQL;;
(*
* implementazione della funzione NAME
* http://cs.unibo.it/helm/.
*)
-val apply_func: Mathql.mqfunc -> string -> string
+val apply_func: MathQL.mqfunc -> string -> string
+++ /dev/null
-(* Copyright (C) 2000, HELM Team.
- *
- * This file is part of HELM, an Hypertextual, Electronic
- * Library of Mathematics, developed at the Computer Science
- * Department, University of Bologna, Italy.
- *
- * HELM is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * HELM is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HELM; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- *
- * For details, see the HELM World-Wide-Web page,
- * http://cs.unibo.it/helm/.
- *)
-
-(******************************************************************************)
-(* *)
-(* PROJECT HELM *)
-(* *)
-(* Ferruccio Guidi <fguidi@cs.unibo.it> *)
-(* Domenico Lordi <lordi@cs.unibo.it> *)
-(* 30/04/2002 *)
-(* *)
-(* *)
-(******************************************************************************)
-
-exception MQInvalidURI of string
-exception MQConnectionFailed of string
-exception MQInvalidConnection of string
-
-(* Input types **************************************************************)
-(* main type is mquery *)
-
-type mqrvar = string (* name *)
-
-type mqsvar = string (* name *)
-
-type mquptoken =
- | MQString of string (* a constant string *)
- | MQSlash (* a slash: '/' *)
- | MQAnyChr (* Any single character: '?' *)
- | MQAst (* single asterisk: '*' *)
- | MQAstAst (* double asterisk: '**' *)
-
-type mqup = mquptoken list (* uri pattern (helper) *)
-
-type mqfi = int option * int option
-
-type mqtref = string * mqup * mqfi (* HELM preamble,
- uri pattern,
- fragment identifier *)
-
-type mqpattern = mqtref (* constant pattern *)
-
-type mqfunc =
- | MQName (* NAME *)
- | MQTheory
- | MQTitle
- | MQContributor
- | MQCreator
- | MQPublisher
- | MQSubject
- | MQDescription
- | MQDate
- | MQType
- | MQFormat
- | MQIdentifier
- | MQLanguage
- | MQRelation
- | MQSource
- | MQCoverage
- | MQRights
- | MQInstitution
- | MQContact
- | MQFirstVersion
- | MQModified
-
-type mqstring =
- | MQCons of string (* constant *)
- | MQFunc of mqfunc * mqrvar (* function, rvar *)
- | MQRVar of mqrvar (* rvar *)
- | MQSVar of mqsvar (* svar *)
- | MQMConclusion (* main conclusion *)
- | MQConclusion (* inner conclusion *)
-
-type mqorder =
- | MQAsc
- | MQDesc
-
-type mqbool =
- | MQTrue
- | MQFalse
- | MQAnd of mqbool * mqbool
- | MQOr of mqbool * mqbool
- | MQNot of mqbool
- | MQIs of mqstring * mqstring (* operands *)
- | MQSetEqual of mqlist * mqlist (* the two lists denote the *)
- (* same set *)
- | MQSubset of mqlist * mqlist (* the two lists denote two *)
- (* sets, the first one *)
- (* subsect of the second one. *)
-
-and mqlist =
- | MQSelect of mqrvar * mqlist * mqbool (* rvar, list, boolean *)
- | MQUse of mqlist * mqsvar (* list, Position attribute *)
- | MQUsedBy of mqlist * mqsvar (* list, Position attribute *)
- | MQPattern of mqpattern (* pattern *)
- | MQUnion of mqlist * mqlist (* *)
- | MQDiff of mqlist * mqlist (* *)
- | MQIntersect of mqlist * mqlist (* *)
- | MQSortedBy of mqlist * mqorder * mqfunc (* *)
- | MQRVarOccur of mqrvar
-
-type mquery =
- | MQList of mqlist
-
-(* Output types *************************************************************)
-(* main type is mqresult *)
-
-type mquref = UriManager.uri * mqfi (* uri, fragment identifier *)
-
-type mqrefs = mqtref list (* list of references (helper) *)
-
-type mqresult =
- | MQRefs of mqrefs
(* attributes are sorted w.r.t. their name in increasing order *)
type attributed_uri =
- { uri: string ; attributes : (Mathql.mqsvar * string) list }
+ { uri: string ; attributes : (MathQL.mqsvar * string) list }
type attributed_uri_env =
- (Mathql.mqrvar * attributed_uri) list
+ (MathQL.mqrvar * attributed_uri) list
type result = attributed_uri list
(*
* implementazione del'interprete MathQL
*)
-open Mathql;;
+open MathQL;;
open Eval;;
open Utility;;
open Dbconn;;
| MQUse (alist, asvar) ->
use_ex (execute_ex env alist) asvar "B" (*"backPointer"*)
| MQPattern (apreamble, apattern, afragid) ->
- pattern_ex apreamble apattern afragid
+ pattern_ex (apreamble, apattern, afragid)
| MQUnion (l1, l2) ->
union_ex (execute_ex env l1) (execute_ex env l2)
(*
* la uri puo' far parte del risultato.
*)
let xres_to_res l =
+ MQRefs (List.map (function {Mathql_semantics.uri = uri} -> uri) l)
+(*
let tmp = List.map (function {Mathql_semantics.uri = uri} -> uri) l in
MQRefs
(List.map
match List.rev tl with
")"::n::"xpointer(1"::tail ->
(
- hd,
+ Some hd,
List.fold_left
(fun par t ->
match par with
- [] -> [MQString t]
- | _ -> (MQString t) :: MQSlash :: par
+ [] -> [MQBC t]
+ | _ -> (MQBC t) :: MQBD :: par
)
[]
tail,
- (Some (int_of_string n), None)
+ [MQFC (int_of_string n)]
)
| ")"::n::m::"xpointer(1"::tail ->
(
- hd,
+ Some hd,
List.fold_left
(fun par t ->
match par with
- [] -> [MQString t]
- | _ -> (MQString t) :: MQSlash :: par
+ [] -> [MQBC t]
+ | _ -> (MQBC t) :: MQBD :: par
)
[]
tail,
- (Some (int_of_string m), Some (int_of_string n))
+ [MQFC (int_of_string m); MQFC (int_of_string n)]
)
| tail ->
(
- hd,
+ Some hd,
List.fold_left
(fun par t ->
match par with
- [] -> [MQString t]
- | _ -> (MQString t) :: MQSlash :: par
+ [] -> [MQBC t]
+ | _ -> (MQBC t) :: MQBD :: par
)
[]
tail,
- (None, None)
+ []
)
)
| [] -> assert false
)
tmp
)
+*)
;;
* interfaccia dell'interprete MathQL
*)
-open Mathql;;
+open MathQL;;
(*
* inizializzazione del database
open Eval;;
open Mathql_semantics;;
-let pattern_ex apreamble apattern afragid =
+let pattern_ex (apreamble, apattern, afragid) =
let c = pgc () in
(*let r1 = helm_class_id "MathResource" in*)
(*let qq = "select att0 from t" ^ r1 ^ " where att0 " ^ (pattern_match apreamble apattern afragid) ^ " order by t" ^ r1 ^ ".att0 asc" in*)
- let qq = "select uri from registry where uri " ^ (pattern_match apreamble apattern afragid) ^ " order by registry.uri asc" in
+ let qq = "select uri from registry where uri " ^ (pattern_match (apreamble, apattern, afragid)) ^ " order by registry.uri asc" in
(*let _ = print_endline qq in*)
let res =
c#exec (qq)
*)
val pattern_ex :
- string -> Mathql.mquptoken list -> int option * int option ->
+ MathQL.mqtref ->
Mathql_semantics.result
* implementazione del comando SELECT
*)
-open Mathql;;
+open MathQL;;
open Func;;
open Utility;;
exception ExecuteFunctionNotInitialized;;
val execute:
(Mathql_semantics.attributed_uri_env ->
- Mathql.mqlist -> Mathql_semantics.result) ref
+ MathQL.mqlist -> Mathql_semantics.result) ref
val select_ex :
Mathql_semantics.attributed_uri_env ->
- Mathql.mqrvar -> Mathql_semantics.result -> Mathql.mqbool ->
+ MathQL.mqrvar -> Mathql_semantics.result -> MathQL.mqbool ->
Mathql_semantics.result
* implementazione del comando SORTEDBY
*)
-open Mathql;;
+open MathQL;;
open Func;;
open Utility;;
*)
val sortedby_ex :
- string list list -> Mathql.mqorder -> Mathql.mqfunc -> string list list
+ string list list -> MathQL.mqorder -> MathQL.mqfunc -> string list list
*)
val use_ex :
- Mathql_semantics.result -> Mathql.mqsvar -> string -> Mathql_semantics.result
+ Mathql_semantics.result -> MathQL.mqsvar -> string -> Mathql_semantics.result