From: Ferruccio Guidi Date: Thu, 13 Jun 2002 17:04:53 +0000 (+0000) Subject: MQueryUtil updated X-Git-Tag: V_0_3_0_debian_8~45 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=9c08b9567c9aa22b9066abde48b72b441c2a95e5;p=helm.git MQueryUtil updated --- diff --git a/helm/ocaml/mathql/mQueryTParser.mly b/helm/ocaml/mathql/mQueryTParser.mly index dea5f4883..7c715b29d 100644 --- a/helm/ocaml/mathql/mQueryTParser.mly +++ b/helm/ocaml/mathql/mQueryTParser.mly @@ -92,8 +92,8 @@ | MCONCL { MQMConclusion } | CONCL { MQConclusion } | STR { MQCons $1 } - | rvar { MQRVar $1 } - | svar { MQSVar $1 } + | rvar { MQSRVar $1 } + | svar { MQSSVar $1 } | func rvar { MQFunc ($1, $2) } ; boole: diff --git a/helm/ocaml/mathql/mQueryUtil.ml b/helm/ocaml/mathql/mQueryUtil.ml index c5a8382fe..2169564e4 100644 --- a/helm/ocaml/mathql/mQueryUtil.ml +++ b/helm/ocaml/mathql/mQueryUtil.ml @@ -78,15 +78,19 @@ let str_uref (u, i) = let key s = "" ^ s ^ " " -let sym s = s ^ " " +let sub s = " " ^ s ^ " " + +let sub2 s = "" ^ s ^ "" + +let sym s = s let sep s = s -let str s = "'" ^ s ^ "' " +let str s = "'" ^ s ^ "'" -let pat s = "\"" ^ s ^ "\" " +let pat s = "\"" ^ s ^ "\"" -let res s = "\"" ^ s ^ "\" " +let res s = "\"" ^ s ^ "\"" let nl () = "
" @@ -102,33 +106,62 @@ let out_tref r = pat (str_tref r) let out_pat p = out_tref p +let out_order = function + | MQAsc -> sub2 "asc" + | MQDesc -> sub2 "desc" + let out_func = function - | MQName -> key "name" + | MQName -> key "name" + | MQTheory -> key "theory" + | MQTitle -> key "title" + | MQContributor -> key "contributor" + | MQCreator -> key "creator" + | MQPublisher -> key "publisher" + | MQSubject -> key "subject" + | MQDescription -> key "description" + | MQDate -> key "date" + | MQType -> key "type" + | MQFormat -> key "format" + | MQIdentifier -> key "identifier" + | MQLanguage -> key "language" + | MQRelation -> key "relation" + | MQSource -> key "source" + | MQCoverage -> key "coverage" + | MQRights -> key "rights" + | MQInstitution -> key "institution" + | MQContact -> key "contact" + | MQFirstVersion -> key "firstversion" + | MQModified -> key "modified" let out_str = function | MQCons s -> str s - | MQRVar s -> out_rvar s - | MQSVar s -> out_svar s + | MQSRVar s -> out_rvar s + | MQSSVar s -> out_svar s | MQFunc (f, r) -> out_func f ^ out_rvar r | MQMConclusion -> key "mainconclusion" - | MQConclusion -> key "conclusion" + | MQConclusion -> key "inconclusion" let rec out_bool = function | MQTrue -> key "true" | MQFalse -> key "false" - | MQIs (s, t) -> out_str s ^ key "is" ^ out_str t + | MQIs (s, t) -> out_str s ^ sub "is" ^ out_str t | MQNot b -> key "not" ^ out_bool b - | MQAnd (b1, b2) -> sep "(" ^ out_bool b1 ^ key "and" ^ out_bool b2 ^ sep ")" - | MQOr (b1, b2) -> sep "(" ^ out_bool b1 ^ key "or" ^ out_bool b2 ^ sep ")" - -let rec out_list = function + | MQAnd (b1, b2) -> sep "(" ^ out_bool b1 ^ sub "and" ^ out_bool b2 ^ sep ")" + | MQOr (b1, b2) -> sep "(" ^ out_bool b1 ^ sub "or" ^ out_bool b2 ^ sep ")" + | MQSubset (l1, l2) -> sep "(" ^ out_list l1 ^ sub "subset" ^ out_list l2 ^ sep ")" + | MQSetEqual (l1, l2) -> sep "(" ^ out_list l1 ^ sub "setequal" ^ out_list l2 ^ sep ")" + +and out_list = function | MQSelect (r, l, b) -> - key "select" ^ out_rvar r ^ key "in" ^ out_list l ^ key "where" ^ out_bool b - | MQUse (l, v) -> key "use" ^ out_list l ^ key "position" ^ out_svar v - | MQUsedBy (l, v) -> key "usedby" ^ out_list l ^ key "position" ^ out_svar v + key "select" ^ out_rvar r ^ sub "in" ^ out_list l ^ sub "where" ^ out_bool b + | MQUse (l, v) -> key "use" ^ out_list l ^ sub "position" ^ out_svar v + | MQUsedBy (l, v) -> key "usedby" ^ out_list l ^ sub "position" ^ out_svar v | MQPattern p -> key "pattern" ^ out_pat p - | MQUnion (l1, l2) -> sep "(" ^ out_list l1 ^ key "union" ^ out_list l2 ^ sep ")" - | MQIntersect (l1, l2) -> sep "(" ^ out_list l1 ^ key "intersect" ^ out_list l2 ^ sep ")" + | MQUnion (l1, l2) -> sep "(" ^ out_list l1 ^ sub "union" ^ out_list l2 ^ sep ")" + | MQIntersect (l1, l2) -> sep "(" ^ out_list l1 ^ sub "intersect" ^ out_list l2 ^ sep ")" + | MQDiff (l1, l2) -> sep "(" ^ out_list l1 ^ sub "diff" ^ out_list l2 ^ sep ")" + | MQLRVar s -> out_rvar s + | MQSortedBy (l, o, f) -> sep "(" ^ out_list l ^ sub "sortedby" ^ out_func f ^ out_order o ^ sep ")" let out_query = function | MQList l -> out_list l diff --git a/helm/ocaml/mathql/mathQL.ml b/helm/ocaml/mathql/mathQL.ml index 088d598a4..d102e7301 100644 --- a/helm/ocaml/mathql/mathQL.ml +++ b/helm/ocaml/mathql/mathQL.ml @@ -91,8 +91,8 @@ type mqfunc = type mqstring = | MQCons of string (* constant *) | MQFunc of mqfunc * mqrvar (* function, rvar *) - | MQRVar of mqrvar (* rvar *) - | MQSVar of mqsvar (* svar *) + | MQSRVar of mqrvar (* rvar *) + | MQSSVar of mqsvar (* svar *) | MQMConclusion (* main conclusion *) | MQConclusion (* inner conclusion *) @@ -121,7 +121,7 @@ and mqlist = | MQUnion of mqlist * mqlist (* operands *) | MQIntersect of mqlist * mqlist (* operands *) | MQSortedBy of mqlist * mqorder * mqfunc (* *) - | MQRVarOccur of mqrvar + | MQLRVar of mqrvar | MQDiff of mqlist * mqlist (* *) type mquery = diff --git a/helm/ocaml/mathql_interpreter/mqint.ml b/helm/ocaml/mathql_interpreter/mqint.ml index ee56718c5..bb89c1d19 100644 --- a/helm/ocaml/mathql_interpreter/mqint.ml +++ b/helm/ocaml/mathql_interpreter/mqint.ml @@ -83,7 +83,7 @@ let rec execute_ex env = sortedby_ex (execute_ex env l) o f | MQIntersect (l1, l2) -> intersect_ex (execute_ex env l1) (execute_ex env l2) - | MQRVarOccur rvar -> [List.assoc rvar env] + | MQLRVar rvar -> [List.assoc rvar env] ;; (* Let's initialize the execute in Select, creating a cyclical recursion *) diff --git a/helm/ocaml/mathql_interpreter/select.ml b/helm/ocaml/mathql_interpreter/select.ml index 1e53a4ba4..7c7d7f2a7 100644 --- a/helm/ocaml/mathql_interpreter/select.ml +++ b/helm/ocaml/mathql_interpreter/select.ml @@ -48,10 +48,10 @@ let stringeval env = | MQFunc (f, rvar) -> let {S.uri = uri} = List.assoc rvar env in apply_func f uri - | MQRVar rvar -> + | MQSRVar rvar -> let {S.uri = uri} = List.assoc rvar env in uri - | MQSVar svar -> + | MQSSVar svar -> let (_,{S.attributes = attributes}) = List.hd env in List.assoc svar attributes | MQMConclusion ->