]> matita.cs.unibo.it Git - helm.git/commitdiff
Updated to use the new parser that creates (stacks of) existential variables
authorClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Mon, 29 Jul 2002 15:55:31 +0000 (15:55 +0000)
committerClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Mon, 29 Jul 2002 15:55:31 +0000 (15:55 +0000)
when an implicit arguments is found.

helm/ocaml/cic_textual_parser/cicTextualParser.mly
helm/ocaml/cic_textual_parser/cicTextualParser0.ml
helm/ocaml/cic_textual_parser/cicTextualParserContext.ml
helm/ocaml/cic_textual_parser/cicTextualParserContext.mli

index 3f6afc79a4685838fd9bb90a3f3990fe98119c5b..b85be0754e7194cd9efc140d365d4295339915c6 100644 (file)
  let get_cookingno uri =
   UriManager.relative_depth !CicTextualParser0.current_uri uri 0
  ;;
-  
+
+ (* Returns the first meta whose number is above the *)
+ (* number of the higher meta.                       *)
+ (*CSC: cut&pasted from proofEngine.ml *)
+ let new_meta () =
+  let rec aux =
+   function
+      None,[] -> 1
+    | Some n,[] -> n
+    | None,(n,_,_)::tl -> aux (Some n,tl)
+    | Some m,(n,_,_)::tl -> if n > m then aux (Some n,tl) else aux (Some m,tl)
+  in
+   1 + aux (None,!CicTextualParser0.metasenv)
+ ;;
+
+ (* identity_relocation_list_for_metavariable i canonical_context         *)
+ (* returns the identity relocation list, which is the list [1 ; ... ; n] *)
+ (* where n = List.length [canonical_context]                             *)
+ (*CSC: ma mi basta la lunghezza del contesto canonico!!!*)
+ (*CSC: cut&pasted from proofEngine.ml *)
+ let identity_relocation_list_for_metavariable canonical_context =
+  let canonical_context_length = List.length canonical_context in
+   let rec aux =
+    function
+       (_,[]) -> []
+     | (n,None::tl) -> None::(aux ((n+1),tl))
+     | (n,_::tl) -> (Some (Cic.Rel n))::(aux ((n+1),tl))
+   in
+    aux (1,canonical_context)
+ ;;
+
 %}
 %token <string> ID
 %token <int> META
@@ -151,7 +181,19 @@ expr2:
          done ;
          CoFix (idx,cofixfuns)
     }
- | IMPLICIT { Implicit }
+ | IMPLICIT
+    { let newmeta = new_meta () in
+       let new_canonical_context = [] in
+        let irl =
+         identity_relocation_list_for_metavariable new_canonical_context
+        in
+         CicTextualParser0.metasenv :=
+          [newmeta, new_canonical_context, Sort Type ;
+           newmeta+1, new_canonical_context, Meta (newmeta,irl);
+           newmeta+2, new_canonical_context, Meta (newmeta+1,irl)
+          ] @ !CicTextualParser0.metasenv ;
+         Meta (newmeta+2,irl)
+    }
  | SET { Sort Set }
  | PROP { Sort Prop }
  | TYPE { Sort Type }
index 7a338c249b0467a0cbc038d31d5b554d6dc285a9..0a841473474275adee71d1b89f11a3f8b47eeaf5 100644 (file)
@@ -27,3 +27,4 @@ exception Eof;;
 
 let current_uri = ref (UriManager.uri_of_string "cic:/dummy.con");;
 let binders = ref ([] : (Cic.name option) list);;
+let metasenv = ref ([] : Cic.metasenv);;
index ae21e5d2e0e8193bcd78da63708634e8609cf955..bdf701d8087d5c9640679054edc18fe00ab12422 100644 (file)
  * http://cs.unibo.it/helm/.
  *)
 
-let main ~current_uri ~context lexer lexbuf =
+let main ~current_uri ~context ~metasenv lexer lexbuf =
  (* Warning: higly non-reentrant code!!! *)
  CicTextualParser0.current_uri := current_uri ;
  CicTextualParser0.binders := context ;
- let res = CicTextualParser.main lexer lexbuf in
-  CicTextualParser0.binders := [] ;
-  res
+ CicTextualParser0.metasenv := metasenv ;
+ match CicTextualParser.main lexer lexbuf with
+    None -> None
+  | Some res ->
+     CicTextualParser0.binders := [] ;
+     Some (!CicTextualParser0.metasenv,res)
 ;;
index 0ab69cdd55bbc85918e4ee90833fa1470ab0bc2e..837628b21c6848bfe481e36143b2f99019fd59c3 100644 (file)
@@ -25,5 +25,5 @@
 
 val main :
   current_uri:(UriManager.uri) -> context:((Cic.name option) list) ->
-   (Lexing.lexbuf  -> CicTextualParser.token) -> Lexing.lexbuf ->
-     Cic.term option
+   metasenv:Cic.metasenv -> (Lexing.lexbuf  -> CicTextualParser.token) ->
+   Lexing.lexbuf -> (Cic.metasenv * Cic.term) option