]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/mathql_interpreter/mqint.ml
mathQL and mqint updated
[helm.git] / helm / ocaml / mathql_interpreter / mqint.ml
index 3a0a5fb310b277a4729a36d5da17e30b144c9209..0de53503ec72edc48f11c0190b9a5ab80a8ac635 100644 (file)
@@ -38,6 +38,7 @@ open Sortedby;;
 open Use;;
 open Select;;
 open Letin;;
+open Mathql_semantics;;
 
 let prop_pool = ref None;;
 
@@ -91,6 +92,13 @@ let get_prop_id prop =
  else List.assoc prop (match !prop_pool with Some l -> l | _ -> assert false)
 ;;
 
+(* automatically performes the union of a given list of patterns *)
+let rec pattern_list_ex = function
+   | [] -> []
+   | [(apreamble, apattern, afragid)] -> pattern_ex (apreamble, apattern, afragid)
+   | (apreamble, apattern, afragid) :: tail -> 
+      union_ex (pattern_ex (apreamble, apattern, afragid)) (pattern_list_ex tail)
+
 (* execute_ex env q                                                   *)
 (*  [env] is the attributed uri environment in which the query [q]    *)
 (*        must be evaluated                                           *)
@@ -104,8 +112,8 @@ let rec execute_ex env =
      use_ex (execute_ex env alist) asvar (get_prop_id "refObj")      (* "F" (*"refObj"*) *)
  |  MQUse (alist, asvar) ->
      use_ex (execute_ex env alist) asvar (get_prop_id "backPointer") (* "B" (*"backPointer"*) *)
- |  MQPattern (apreamble, apattern, afragid) ->
-     pattern_ex (apreamble, apattern, afragid)
+ |  MQPattern l ->
+     pattern_list_ex l
  |  MQUnion (l1, l2) ->
      union_ex (execute_ex env l1) (execute_ex env l2)
  |  MQDiff (l1, l2) ->
@@ -130,6 +138,14 @@ let rec execute_ex env =
        res
  |  MQListLVar lvar ->
      letref_ex lvar
+ |  MQReference l -> (* FG: *)
+     let rec build_result = function
+       | [] -> []
+       | s :: tail -> 
+        {uri = s ; attributes = [] ; extra = ""} :: build_result tail
+     in build_result l
+ | MQMinimize l ->     (* FG: sostituire con l'implementazione vera *)
+     execute_ex env l 
 ;;
 
 (* Let's initialize the execute in Select, creating a cyclical recursion *)