]> matita.cs.unibo.it Git - helm.git/blobdiff - matita/components/grafite_parser/grafiteParser.ml
Propagation of changes to grafiteAst.
[helm.git] / matita / components / grafite_parser / grafiteParser.ml
index 3a0edb7ac59ee3071166848080dfbc002be163db..fe4a8042c0fc4aa8658819c13963e3b275a2e9a7 100644 (file)
@@ -25,7 +25,7 @@
 
 (* $Id$ *)
 
-module N  = CicNotationPt
+module N  = NotationPt
 module G  = GrafiteAst
 module L  = LexiconAst
 module LE = LexiconEngine
@@ -36,8 +36,7 @@ type 'a localized_option =
    LSome of 'a
  | LNone of G.loc
 
-type ast_statement =
-  (N.term, N.term, N.term G.reduction, N.term N.obj, string) G.statement
+type ast_statement = G.statement
 
 type 'status statement =
   ?never_include:bool -> 
@@ -101,10 +100,7 @@ let nmk_rec_corec ind_kind defs loc =
  let loc,t = mk_rec_corec ind_kind defs loc in
   G.NObj (loc,t)
 
-let mk_rec_corec ind_kind defs loc = 
- let loc,t = mk_rec_corec ind_kind defs loc in
-  G.Obj (loc,t)
-
+(*
 let npunct_of_punct = function
   | G.Branch loc -> G.NBranch loc
   | G.Shift loc -> G.NShift loc
@@ -113,21 +109,14 @@ let npunct_of_punct = function
   | G.Merge loc -> G.NMerge loc
   | G.Semicolon loc -> G.NSemicolon loc
   | G.Dot loc -> G.NDot loc
-;;
+;; 
+
 let nnon_punct_of_punct = function
   | G.Skip loc -> G.NSkip loc
   | G.Unfocus loc -> G.NUnfocus loc
   | G.Focus (loc,l) -> G.NFocus (loc,l)
-;;
-let npunct_of_punct = function
-  | G.Branch loc -> G.NBranch loc
-  | G.Shift loc -> G.NShift loc
-  | G.Pos (loc, i) -> G.NPos (loc, i)
-  | G.Wildcard loc -> G.NWildcard loc
-  | G.Merge loc -> G.NMerge loc
-  | G.Semicolon loc -> G.NSemicolon loc
-  | G.Dot loc -> G.NDot loc
-;;
+;; *)
+
 let cons_ntac t p = 
   match t with
   | G.NTactic(loc,[t]) -> G.NTactic(loc,[t;p])
@@ -222,7 +211,7 @@ EXTEND
            | N.Implicit _ -> false
            | N.UserInput -> true
            | _ -> raise (Invalid_argument "malformed target parameter list 1")) l
-      | _ -> raise (Invalid_argument ("malformed target parameter list 2\n" ^ CicNotationPp.pp_term params)) ]
+      | _ -> raise (Invalid_argument ("malformed target parameter list 2\n" ^ NotationPp.pp_term params)) ]
   ];
   direction: [
     [ SYMBOL ">" -> `LeftToRight
@@ -326,6 +315,7 @@ EXTEND
     | SYMBOL "*"; n=IDENT -> G.NTactic(loc,[ G.NCase1 (loc,n)])
     ]
   ];
+(*
   tactic: [
     [ IDENT "absurd"; t = tactic_term ->
         G.Absurd (loc, t)
@@ -448,7 +438,7 @@ EXTEND
     | IDENT "symmetry" ->
         G.Symmetry loc
     | IDENT "transitivity"; t = tactic_term ->
-        G.Transitivity (loc, t)
+        G.Transitivity (loc, t) 
      (* Produzioni Aggiunte *)
     | IDENT "assume" ; id = IDENT ; SYMBOL ":" ; t = tactic_term ->
         G.Assume (loc, id, t)
@@ -516,15 +506,13 @@ EXTEND
        | IDENT "proof" -> `Proof
        | params = auto_params -> `Auto params];
       cont = rewriting_step_continuation ->
-       G.RewritingStep(loc, None, t1, t2, cont)
-  ]
-];
+       G.RewritingStep(loc, None, t1, t2, cont) 
+  ] 
+]; *)
   auto_fixed_param: [
-   [ IDENT "paramodulation"
-   | IDENT "demod"
+   [ IDENT "demod"
    | IDENT "fast_paramod"
    | IDENT "paramod"
-   | IDENT "slir"
    | IDENT "depth"
    | IDENT "width"
    | IDENT "size"
@@ -555,6 +543,7 @@ EXTEND
    ]
 ];
 
+(*
   inline_params:[
    [ params = LIST0 
       [ IDENT "prefix"; SYMBOL "="; prefix = QSTRING -> G.IPPrefix prefix  
@@ -569,7 +558,7 @@ EXTEND
       | IDENT "cr" -> G.IPCR
       ] -> params
    ]
-];
+];*)
   by_continuation: [
     [ WEPROVED; ty = tactic_term ; LPAREN ; id = IDENT ; RPAREN ; t1 = OPT [IDENT "that" ; IDENT "is" ; IDENT "equivalent" ; "to" ; t2 = tactic_term -> t2] -> BYC_weproved (ty,Some id,t1)
     | WEPROVED; ty = tactic_term ; t1 = OPT [IDENT "that" ; IDENT "is" ; IDENT "equivalent" ; "to" ; t2 = tactic_term -> t2] ; 
@@ -587,6 +576,7 @@ EXTEND
     | -> false
     ]
 ];
+(*
   atomic_tactical:
     [ "sequence" LEFTA
       [ t1 = SELF; SYMBOL ";"; t2 = SELF ->
@@ -620,6 +610,7 @@ EXTEND
       | tac = tactic -> tac
         ]
       ];
+*)
   npunctuation_tactical:
     [
       [ SYMBOL "[" -> G.NBranch loc
@@ -632,6 +623,7 @@ EXTEND
       | SYMBOL "." -> G.NDot loc
       ]
     ];
+(*
   punctuation_tactical:
     [
       [ SYMBOL "[" -> G.Branch loc
@@ -650,6 +642,14 @@ EXTEND
       | IDENT "skip" -> G.Skip loc
       ]
       ];
+*)
+  nnon_punctuation_tactical:
+    [ "simple" NONA
+      [ IDENT "focus"; goals = LIST1 int -> G.NFocus (loc, goals)
+      | IDENT "unfocus" -> G.NUnfocus loc
+      | IDENT "skip" -> G.NSkip loc
+      ]
+      ];
   ntheorem_flavour: [
     [ [ IDENT "ndefinition"  ] -> `Definition
     | [ IDENT "nfact"        ] -> `Fact
@@ -719,19 +719,6 @@ EXTEND
         (params,name,typ,fields)
     ] ];
 
-    macro: [
-      [ [ IDENT "check"   ]; t = term ->
-          G.Check (loc, t)
-      | [ IDENT "eval" ]; kind = reduction_kind; "on"; t = tactic_term ->
-          G.Eval (loc, kind, t)
-      | IDENT "inline"; suri = QSTRING; params = inline_params -> 
-           G.Inline (loc, suri, params)
-      | [ IDENT "hint" ]; rew = OPT (IDENT "rewrite")  -> 
-           if rew = None then G.Hint (loc, false) else G.Hint (loc,true)
-      | IDENT "auto"; params = auto_params ->
-          G.AutoInteractive (loc,params)
-      ]
-    ];
     alias_spec: [
       [ IDENT "id"; id = QSTRING; SYMBOL "="; uri = QSTRING ->
         let alpha = "[a-zA-Z]" in
@@ -870,7 +857,7 @@ EXTEND
     | IDENT "universe"; IDENT "constraint"; u1 = tactic_term; 
         SYMBOL <:unicode<lt>> ; u2 = tactic_term ->
         let urify = function 
-          | CicNotationPt.AttributedTerm (_, CicNotationPt.Sort (`NType i)) ->
+          | NotationPt.AttributedTerm (_, NotationPt.Sort (`NType i)) ->
               NUri.uri_of_string ("cic:/matita/pts/Type"^i^".univ")
           | _ -> raise (Failure "only a Type[…] sort can be constrained")
         in
@@ -892,72 +879,6 @@ EXTEND
           List.map (fun a,b -> NUri.uri_of_string a, NUri.uri_of_string b) m)
   ]];
 
-  grafite_command: [ [
-      IDENT "set"; n = QSTRING; v = QSTRING ->
-        G.Set (loc, n, v)
-    | IDENT "drop" -> G.Drop loc
-    | IDENT "print"; s = IDENT -> G.Print (loc,s)
-    | IDENT "qed" -> G.Qed loc
-    | IDENT "variant" ; name = IDENT; SYMBOL ":"; 
-      typ = term; SYMBOL <:unicode<def>> ; newname = IDENT ->
-        G.Obj (loc, 
-          N.Theorem 
-            (`Variant,name,typ,Some (N.Ident (newname, None)), `Regular))
-    | flavour = theorem_flavour; name = IDENT; SYMBOL ":"; typ = term;
-      body = OPT [ SYMBOL <:unicode<def>> (* ≝ *); body = term -> body ] ->
-        G.Obj (loc, N.Theorem (flavour, name, typ, body,`Regular))
-    | flavour = theorem_flavour; name = IDENT; SYMBOL <:unicode<def>> (* ≝ *);
-      body = term ->
-        G.Obj (loc,
-          N.Theorem (flavour, name, N.Implicit `JustOne, Some body,`Regular))
-    | IDENT "axiom"; name = IDENT; SYMBOL ":"; typ = term ->
-        G.Obj (loc, N.Theorem (`Axiom, name, typ, None, `Regular))
-    | LETCOREC ; defs = let_defs -> 
-        mk_rec_corec `CoInductive defs loc
-    | LETREC ; defs = let_defs -> 
-        mk_rec_corec `Inductive defs loc
-    | IDENT "inductive"; spec = inductive_spec ->
-        let (params, ind_types) = spec in
-        G.Obj (loc, N.Inductive (params, ind_types))
-    | IDENT "coinductive"; spec = inductive_spec ->
-        let (params, ind_types) = spec in
-        let ind_types = (* set inductive flags to false (coinductive) *)
-          List.map (fun (name, _, term, ctors) -> (name, false, term, ctors))
-            ind_types
-        in
-        G.Obj (loc, N.Inductive (params, ind_types))
-    | IDENT "coercion" ; 
-      t = [ u = URI -> N.Uri (u,None) | t = tactic_term ; OPT "with" -> t ] ;
-      arity = OPT int ; saturations = OPT int; 
-      composites = OPT (IDENT "nocomposites") ->
-        let arity = match arity with None -> 0 | Some x -> x in
-        let saturations = match saturations with None -> 0 | Some x -> x in
-        let composites = match composites with None -> true | Some _ -> false in
-        G.Coercion
-         (loc, t, composites, arity, saturations)
-    | IDENT "prefer" ; IDENT "coercion"; t = tactic_term ->
-        G.PreferCoercion (loc, t)
-    | IDENT "pump" ; steps = int ->
-        G.Pump(loc,steps)
-    | IDENT "inverter"; name = IDENT; IDENT "for";
-        indty = tactic_term; paramspec = inverter_param_list ->
-          G.Inverter
-            (loc, name, indty, paramspec)
-    | IDENT "record" ; (params,name,ty,fields) = record_spec ->
-        G.Obj (loc, N.Record (params,name,ty,fields))
-    | IDENT "default" ; what = QSTRING ; uris = LIST1 URI ->
-       let uris = List.map UriManager.uri_of_string uris in
-        G.Default (loc,what,uris)
-    | IDENT "relation" ; aeq = tactic_term ; "on" ; a = tactic_term ;
-      refl = OPT [ IDENT "reflexivity" ; IDENT "proved" ; IDENT "by" ;
-                   refl = tactic_term -> refl ] ;
-      sym = OPT [ IDENT "symmetry" ; IDENT "proved" ; IDENT "by" ;
-                   sym = tactic_term -> sym ] ;
-      trans = OPT [ IDENT "transitivity" ; IDENT "proved" ; IDENT "by" ;
-                   trans = tactic_term -> trans ] ;
-      "as" ; id = IDENT ->
-       G.Relation (loc,id,a,aeq,refl,sym,trans)
-  ]];
   lexicon_command: [ [
       IDENT "alias" ; spec = alias_spec ->
         L.Alias (loc, spec)
@@ -968,29 +889,24 @@ EXTEND
         L.Interpretation (loc, id, (symbol, args), l3)
   ]];
   executable: [
-    [ cmd = grafite_command; SYMBOL "." -> G.Command (loc, cmd)
-    | ncmd = grafite_ncommand; SYMBOL "." -> G.NCommand (loc, ncmd)
-    | tac = atomic_tactical LEVEL "loops"; punct = punctuation_tactical ->
-        G.Tactic (loc, Some tac, punct)
-    | punct = punctuation_tactical -> G.Tactic (loc, None, punct)
+    [ ncmd = grafite_ncommand; SYMBOL "." -> G.NCommand (loc, ncmd)
+(*    | tac = atomic_tactical LEVEL "loops"; punct = punctuation_tactical ->
+        G.Tactic (loc, Some tac, punct) *)
+(*    | punct = punctuation_tactical -> G.Tactic (loc, None, punct) *)
     | tac = ntactic; OPT [ SYMBOL "#" ; SYMBOL "#" ] ; 
-      punct = punctuation_tactical ->
-        cons_ntac tac (npunct_of_punct punct)
+      punct = npunctuation_tactical -> cons_ntac tac punct
 (*
     | tac = ntactic; punct = punctuation_tactical ->
         cons_ntac tac (npunct_of_punct punct)
 *)
     | SYMBOL "#" ; SYMBOL "#" ; punct = npunctuation_tactical ->
         G.NTactic (loc, [punct])
-    | tac = non_punctuation_tactical; punct = punctuation_tactical ->
-        G.NonPunctuationTactical (loc, tac, punct)
-    | SYMBOL "#" ; SYMBOL "#" ; tac = non_punctuation_tactical; 
-        SYMBOL "#" ; SYMBOL "#" ; punct = punctuation_tactical ->
-          G.NTactic (loc, [nnon_punct_of_punct tac; npunct_of_punct punct])
-    | SYMBOL "#" ; SYMBOL "#" ; tac = non_punctuation_tactical; 
-        punct = punctuation_tactical ->
-          G.NTactic (loc, [nnon_punct_of_punct tac; npunct_of_punct punct])
-    | mac = macro; SYMBOL "." -> G.Macro (loc, mac)
+    | SYMBOL "#" ; SYMBOL "#" ; tac = nnon_punctuation_tactical; 
+        SYMBOL "#" ; SYMBOL "#" ; punct = npunctuation_tactical ->
+          G.NTactic (loc, [tac; punct])
+    | SYMBOL "#" ; SYMBOL "#" ; tac = nnon_punctuation_tactical; 
+        punct = npunctuation_tactical ->
+          G.NTactic (loc, [tac; punct])
     ]
   ];
   comment: [
@@ -1020,13 +936,13 @@ EXTEND
          begin
          let stm =
           G.Executable
-            (loc, G.Command (loc, G.Include (iloc,normal,`OldAndNew,fname))) in
+            (loc, G.Command (loc, G.Include (iloc,fname))) in
           !grafite_callback stm;
          let status =
            LE.eval_command status (L.Include (iloc,buri,mode,fullpath)) in
           let stm =
           G.Executable
-            (loc,G.Command (loc,G.Include (iloc,normal,`OldAndNew,buri)))
+            (loc,G.Command (loc,G.Include (iloc,buri)))
          in
           status, LSome stm
          end