X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fmathql_interpreter%2Fmqint.ml;h=a0c56e3848835e0cc8a65212d8227ae87e28008c;hb=fb4f3bb1bafb5d5541a777758b4074ee8e2de4ae;hp=cf453c6f61b7d82b0424160ba119d226cbd8d52f;hpb=dec50888f98015c937283acc14e2ffceccc04a11;p=helm.git diff --git a/helm/ocaml/mathql_interpreter/mqint.ml b/helm/ocaml/mathql_interpreter/mqint.ml index cf453c6f6..a0c56e384 100644 --- a/helm/ocaml/mathql_interpreter/mqint.ml +++ b/helm/ocaml/mathql_interpreter/mqint.ml @@ -26,20 +26,26 @@ (* * implementazione del'interprete MathQL *) + +(* +(* FG: ROBA VECCHIA DA BUTTARE (tranne apertura e chiusura database *) + open MathQL;; open Eval;; open Utility;; open Dbconn;; open Pattern;; -open Union;; +open Union;;*) open Intersect;; -open Diff;; +(*open Diff;; open Sortedby;; open Use;; open Select;; open Letin;; open Mathql_semantics;; + + let prop_pool = ref None;; let fi_to_string fi = @@ -244,3 +250,58 @@ let execute q = *) let close () = Dbconn.close ();; +*****************************************************************************) + +let init () = () (* FG: implementare l'apertura del database *) + +let close () = () (* FG: implementare la chiusura del database *) + + +(* contexts *****************************************************************) + +type svar_context = (MathQL.svar * MathQL.resource_set) list + +type rvar_context = (MathQL.rvar * MathQL.resource) list + +type group_context = (MathQL.rvar * MathQL.attribute_group) list + +type vvar_context = (MathQL.vvar * MathQL.value) list + + +let svars = ref [] (* contesto delle svar *) + +let rvars = ref [] (* contesto delle rvar *) + +let groups = ref [] (* contesto dei gruppi *) + +let vvars = ref [] (* contesto delle vvar introdotte con let-in *) + + +let rec exec_set_exp = function + | MathQL.Ref vexp -> List.map (fun s -> (s,[])) (exec_val_exp vexp) + | MathQL.Intersect sexp1 sexp2 -> intersect_ex (exec_set_exp sexp1) (exec_set_exp sexp2) + | _ -> assert false + +(* valuta una MathQL.boole_exp e ritorna un boole *) + +and exec_boole_exp = function + | MathQL.False -> false + | MathQL.True -> true + | MathQL.Not x -> not (exec_boole_exp x) + | MathQL.And (x, y) -> (exec_boole_exp x) && (exec_boole_exp y) + | MathQL.Or (x, y) -> (exec_boole_exp x) || (exec_boole_exp y) + | _ -> assert false + +(* valuta una MathQL.val_exp e ritorna un MathQL.value *) + +and exec_val_exp = function + | MathQL.Const x -> x + | _ -> assert false + +(* valuta una MathQL.set_exp nel contesto vuoto e ritorna un MathQL.resource_set *) + +(* valuta una MathQL.set_exp e ritorna un MathQL.resource_set *) +let execute x = + svars := []; rvars := []; groups := []; vvars := []; + exec_set_exp x +