]> matita.cs.unibo.it Git - helm.git/commitdiff
let-in on vvars added to mathql
authorFerruccio Guidi <ferruccio.guidi@unibo.it>
Sun, 15 Sep 2002 18:34:32 +0000 (18:34 +0000)
committerFerruccio Guidi <ferruccio.guidi@unibo.it>
Sun, 15 Sep 2002 18:34:32 +0000 (18:34 +0000)
helm/ocaml/mathql/Makefile
helm/ocaml/mathql/mQueryTParser.mly
helm/ocaml/mathql/mQueryUtil.ml
helm/ocaml/mathql/mQueryUtil.mli
helm/ocaml/mathql/mathQL.ml

index 8eb819bd30dc808182e640d2edc8ceec2e7bb27f..c381b8dc863ba854cd99ebb1d6c389d2e8d03aa4 100644 (file)
@@ -1,5 +1,5 @@
 PACKAGE = mathql
-REQUIRES = helm-urimanager
+REQUIRES = helm-urimanager
 PREDICATES =
 
 INTERFACE_FILES = mQueryTParser.mli mQueryUtil.mli
index be861dc82f8aff4eca1719b6fbe673acf9cd14c8..7bb6be3c43484cfebf34e7a020178fa1d3680b19 100644 (file)
@@ -79,6 +79,7 @@
       | FUN STR val_exp           { MathQL.Fun ($2, $3)           }
       | ATTRIB ref_op STR val_exp { MathQL.Attribute ($2, $3, $4) }
       | rvar FS vvar              { MathQL.Record ($1, $3)        }
+      | vvar                      { MathQL.VVar $1                }
       | LC qstr_list RC           { MathQL.Const $2               }
       | LC RC                     { MathQL.Const []               }
       | REFOF set_exp             { MathQL.RefOf $2               }
       | set_exp UNION set_exp                  { MathQL.Union ($1, $3)            }
       | set_exp INTER set_exp                  { MathQL.Intersect ($1, $3)        }
       | set_exp DIFF set_exp                   { MathQL.Diff ($1, $3)             }
-      | LET svar BE set_exp IN set_exp         { MathQL.Let ($2, $4, $6)          }      
+      | LET svar BE set_exp IN set_exp         { MathQL.LetSVar ($2, $4, $6)      }      
+      | LET vvar BE val_exp IN set_exp         { MathQL.LetVVar ($2, $4, $6)      }      
    ;
    query:
       | set_exp EOF { $1 }
index 75eb86d442c02cf5e59afb731c5c6df235c9b7cf..dc6b6997f36c82260f5597cb3a58887ff0a65436 100644 (file)
@@ -59,7 +59,8 @@ let text_of_query x =
    let rec txt_val = function
       | M.Const [s]           -> txt_qstr s
       | M.Const l             -> "{" ^ txt_list txt_qstr "," l ^ "}"
-      | M.Record (rv, vv)     -> txt_rvar rv ^ "." ^ txt_rvar vv
+      | M.VVar vv             -> txt_vvar vv
+      | M.Record (rv, vv)     -> txt_rvar rv ^ "." ^ txt_vvar vv
       | M.Fun (s, x)          -> "fun " ^ txt_qstr s ^ " " ^ txt_val x
       | M.Attribute (r, s, x) -> "attribute " ^ txt_ref r ^ txt_qstr s ^ " " ^ txt_val x
       | M.RefOf x             -> "refof " ^ txt_set x
@@ -81,14 +82,15 @@ let text_of_query x =
       | M.Union (x, y)           -> "(" ^ txt_set x ^ " union " ^ txt_set y ^ ")"
       | M.Intersect (x, y)       -> "(" ^ txt_set x ^ " intersect " ^ txt_set y ^ ")"
       | M.Diff (x, y)            -> "(" ^ txt_set x ^ " diff " ^ txt_set y ^ ")"
-      | M.Let (sv, x, y)         -> "let " ^ txt_svar sv ^ " be " ^ txt_set x ^ " in " ^ txt_set y
+      | M.LetSVar (sv, x, y)     -> "let " ^ txt_svar sv ^ " be " ^ txt_set x ^ " in " ^ txt_set y
+      | M.LetVVar (vv, x, y)     -> "let " ^ txt_vvar vv ^ " be " ^ txt_val x ^ " in " ^ txt_set y
       | M.Select (rv, x, y)      -> "select " ^ txt_rvar rv ^ " in " ^ txt_set x ^ " where " ^ txt_boole y
       | M.Pattern x              -> "pattern " ^ txt_val x
       | M.Ref x                  -> "ref " ^ txt_val x
    in
    txt_set x
 
-let text_of_result x =
+let text_of_result x sep =
    let txt_attr = function
       | (s, []) -> txt_qstr s
       | (s, l)  -> txt_qstr s ^ "=" ^ txt_list txt_qstr "," l
@@ -98,7 +100,7 @@ let text_of_result x =
       | (s, []) -> txt_qstr s 
       | (s, l)  -> txt_qstr s ^ " attr " ^ txt_list txt_group "," l
    in   
-   let txt_set l = txt_list txt_res ";" l in
+   let txt_set l = txt_list txt_res (";" ^ sep) l in
    txt_set x
 
 let query_of_text lexbuf =
@@ -107,41 +109,15 @@ let query_of_text lexbuf =
 let result_of_text lexbuf =
    MQueryTParser.result MQueryTLexer.result_token lexbuf 
 
-(*
+(* conversion functions *****************************************************)
 
-(* Converting functions *****************************************************)
+type uriref = UriManager.uri * (int list)
 
-let tref_uref u =
-   let s = str_uref u in
-   MQueryTParser.ref MQueryTLexer.rtoken (Lexing.from_string s) 
-
-(* implementazione manuale di tref_uref da controllare 
-
-let split s =
-   try 
-      let i = Str.search_forward (Str.regexp_string ":/") s 0 in
-      let p = Str.string_before s i in
-      let q = Str.string_after s (i + 2) in
-         (p, q)
-   with 
-      Not_found -> (s, "")
-
-let encode = function
-   | Str.Text s  -> MQBC s
-   | Str.Delim s ->  
-      if s = "?"  then MQBQ else
-      if s = "*"  then MQBS else
-      if s = "**" then MQBSS else
-      if s = "/"  then MQBD  else MQBC s
-
-let tref_uref (u, i) =
-   let s = UriManager.string_of_uri u in
-   match split s with
-      | (p, q) -> 
-         let rx = Str.regexp "\?\|\*\*\|\*\|/" in
-         let l = Str.full_split rx q in
-         (Some p, List.map encode l, i) 
-
-*)
-
-*)
+let string_of_uriref (uri, fi) =
+   let module UM = UriManager in
+   let str = UM.string_of_uri uri in
+   let xp t = "#xpointer(1/" ^ string_of_int (t + 1) in
+   match fi with
+      | []          -> str 
+      | [t]         -> str ^ xp t ^ ")" 
+      | t :: c :: _ -> str ^ xp t ^ "/" ^ string_of_int c ^ ")" 
index e7ee98395695edf21d308cd9fe391064742327ff..9881b3b545b0b8d762cf657dd43f481f43d7e70c 100644 (file)
 (*                                                                            *)
 (******************************************************************************)
 
+
 val text_of_query  : MathQL.query -> string
 
-val text_of_result : MathQL.result -> string
+val text_of_result : MathQL.result -> string -> string
 
 val query_of_text  : Lexing.lexbuf -> MathQL.query
 
 val result_of_text : Lexing.lexbuf -> MathQL.result
 
-(*
-
-val str_uref    : MathQL.mquref -> string        (* string linearization of a UriMan. reference *)
-
-val str_tref    : MathQL.mqtref -> string        (* string linearization of a tokenized reference *)
-
-val xp_str_uref : MathQL.mquref -> string        (* string linearization of a UriMan. reference *)
-
-val xp_str_tref : MathQL.mqtref -> string        (* string linearization of a tokenized reference *)
-
-val out_query   : MathQL.mquery -> string        (* HTML representation of a query *)
-
-val out_result  : MathQL.mqresult -> string      (* HTML representation of a query result *)
 
-val tref_uref   : MathQL.mquref -> MathQL.mqtref (* "tref of uref" conversion *)
+type uriref = UriManager.uri * (int list)
 
-val parse_text  : in_channel -> MathQL.mquery    (* textual parsing of a query *) 
+val string_of_uriref : uriref -> string
 
-*)
index ed6abf54f454c0b6b6c32afd5d9b6858a5fe5059..5ccdf79d77440f0e30f91c3c239f8903bf53b462 100644 (file)
@@ -58,7 +58,8 @@ type set_exp = SVar of svar
             | Union of set_exp * set_exp
             | Intersect of set_exp * set_exp
             | Diff of set_exp * set_exp
-            | Let of svar * set_exp * set_exp
+            | LetSVar of svar * set_exp * set_exp
+            | LetVVar of vvar * val_exp * set_exp
             
 and boole_exp = False
               | True
@@ -73,6 +74,7 @@ and boole_exp = False
 and val_exp = Const of string list 
             | RefOf of set_exp 
            | Record of rvar * vvar
+           | VVar of string
            | Fun of string * val_exp
            | Attribute of refine_op * string * val_exp