]> matita.cs.unibo.it Git - helm.git/commitdiff
transcript: now we can generate procedural output
authorFerruccio Guidi <ferruccio.guidi@unibo.it>
Tue, 22 Jul 2008 12:43:10 +0000 (12:43 +0000)
committerFerruccio Guidi <ferruccio.guidi@unibo.it>
Tue, 22 Jul 2008 12:43:10 +0000 (12:43 +0000)
CoRN-Procedural: development started:
                 we aim at the procedural reconstruction of CoRN

13 files changed:
helm/software/components/binaries/transcript/CoRN.conf.xml [deleted file]
helm/software/components/binaries/transcript/engine.ml
helm/software/components/binaries/transcript/engine.mli
helm/software/components/binaries/transcript/grafite.ml
helm/software/components/binaries/transcript/grafite.mli
helm/software/components/binaries/transcript/top.ml
helm/software/components/binaries/transcript/transcript.conf.xml
helm/software/components/binaries/transcript/types.ml
helm/software/matita/contribs/CoRN-Procedural/CoRN.conf.xml [new file with mode: 0644]
helm/software/matita/contribs/CoRN-Procedural/Makefile [new file with mode: 0644]
helm/software/matita/contribs/CoRN-Procedural/root [new file with mode: 0644]
helm/software/matita/contribs/CoRN-Procedural/transcript.conf.xml [new file with mode: 0644]
helm/software/matita/contribs/LAMBDA-TYPES/Makefile

diff --git a/helm/software/components/binaries/transcript/CoRN.conf.xml b/helm/software/components/binaries/transcript/CoRN.conf.xml
deleted file mode 100644 (file)
index e904b4d..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<helm_registry>
-  <section name="package">      
-    <key name="input_name">CoRN</key>
-    <key name="output_name">CoRN-Decl</key>
-    <key name="input_base_uri">cic:/CoRN</key>
-    <key name="output_base_uri">cic:/matita/CoRN-Decl</key>
-    <key name="input_path">/projects/helm/exportation/CoRN</key>
-    <key name="output_path">$(transcript.helm_dir)/matita/contribs/CoRN-Decl</key>
-    <key name="script_type">.v</key>
-    <key name="coercion">Z_of_nat cic:/Coq/ZArith/BinInt/Z_of_nat.con</key>
-    <key name="coercion">Zpos cic:/Coq/ZArith/BinInt/Z.ind#xpointer(1/1/2)</key>
-    <key name="coercion">nat_of_P cic:/Coq/NArith/BinPos/nat_of_P.con</key>
-  </section>
-</helm_registry>
index 66c6c33be85a2b53e16352a7c41b57e77ee2a8d0..7e561e9b0468412fa649ee0785aa58f019af00be 100644 (file)
@@ -34,7 +34,6 @@ type script = {
 }
 
 type status = {
-   helm_dir: string;
    heading_path: string;
    heading_lines: int;
    input_package: string;
@@ -43,7 +42,8 @@ type status = {
    output_base_uri: string;
    input_path: string;
    output_path: string;
-   script_ext: string;
+   input_type: string;
+   output_type: T.output_kind;
    coercions: (string * string) list;
    files: string list;
    requires: (string * string) list;
@@ -68,7 +68,7 @@ let load_registry registry =
 let set_files st =
    let eof ich = try Some (input_line ich) with End_of_file -> None in
    let trim l = Filename.chop_extension (Str.string_after l 2) in
-   let cmd = Printf.sprintf "cd %s && find -name *%s" st.input_path st.script_ext in
+   let cmd = Printf.sprintf "cd %s && find -name *%s" st.input_path st.input_type in
    let ich = Unix.open_process_in cmd in
    let rec aux files =
       match eof ich with
@@ -85,15 +85,21 @@ let set_requires st =
    {st with requires = requires}
 
 let init () = 
-   let default_registry = "transcript" in
+   let transcript_dir = Filename.dirname Sys.argv.(0) in
+   let default_registry = Filename.concat transcript_dir "transcript" in
    load_registry default_registry
 
-let make registry =
+let make cwd registry =
    let id x = x in
    let get_coercions = R.get_list (R.pair id id) in 
+   let get_output_type key =
+      match R.get_string key with
+         | "procedural"  -> T.Procedural
+        | "declarative" -> T.Declarative
+        | _             -> failwith "unknown output type"
+   in
    load_registry registry;
    let st = {
-      helm_dir = R.get_string "transcript.helm_dir";
       heading_path = R.get_string "transcript.heading_path";
       heading_lines = R.get_int "transcript.heading_lines";
       input_package = R.get_string "package.input_name";
@@ -102,12 +108,17 @@ let make registry =
       output_base_uri = R.get_string "package.output_base_uri";
       input_path = R.get_string "package.input_path";
       output_path = R.get_string "package.output_path";
-      script_ext = R.get_string "package.script_type";
+      input_type = R.get_string "package.input_type";
+      output_type = get_output_type "package.output_type";
       coercions = get_coercions "package.coercion";
       files = [];
       requires = [];
       scripts = Array.make default_scripts default_script
    } in
+   let st = {st with
+      heading_path = Filename.concat cwd st.heading_path;
+      output_path = Filename.concat cwd st.output_path;
+   } in
    prerr_endline "reading file names ...";
    let st = set_files st in
    let st = set_requires st in
@@ -130,7 +141,7 @@ let set_items st name items =
    st.scripts.(i) <- {name = name; contents = contents}
    
 let set_heading st name =
-   let heading = Filename.concat st.helm_dir st.heading_path, st.heading_lines in
+   let heading = st.heading_path, st.heading_lines in
    set_items st name [T.Heading heading] 
    
 let set_baseuri st name =
@@ -157,7 +168,7 @@ let commit st name =
    let cmd = Printf.sprintf "mkdir -p %s" path in
    let _ = Sys.command cmd in
    let och = open_out name in
-   G.commit och script.contents;
+   G.commit st.output_type och script.contents;
    close_out och;
    st.scripts.(i) <-  default_script
    
@@ -196,7 +207,7 @@ let produce st =
         | item                         -> path, Some item
       in
       Printf.eprintf "processing file name: %s ...\n" name; flush stderr; 
-      let file = Filename.concat st.input_path (name ^ st.script_ext) in
+      let file = Filename.concat st.input_path (name ^ st.input_type) in
       let ich = open_in file in
       let lexbuf = Lexing.from_channel ich in
       try 
index 8016d71cfa3c0f932206c442a9cd32b794d392e2..5de8db2e60002756ce9285076b7637b11cbe69ec 100644 (file)
@@ -27,6 +27,6 @@ type status
 
 val init: unit -> unit
 
-val make: string -> status
+val make: string -> string -> status
 
 val produce: status -> unit
index 1616c18a9a5f5c467ab997a155b14e773792d428..ef2105afb17756217de25c55437f3285d18b458d 100644 (file)
@@ -81,15 +81,19 @@ let require value =
 let coercion value =
    command_of_obj (G.Coercion (floc, UM.uri_of_string value, true, 0, 0))
 
-let inline (uri, prefix) =
-    command_of_macro (G.Inline (floc, G.Declarative, uri, prefix))
+let inline (kind, uri, prefix) =
+    let kind = match kind with
+       | T.Declarative -> G.Declarative
+       | T.Procedural  -> G.Procedural None 
+    in
+    command_of_macro (G.Inline (floc, kind, uri, prefix))
 
 let out_alias och name uri =
    Printf.fprintf och "alias id \"%s\" = \"%s\".\n\n" name uri
 
-let commit och items =
+let commit kind och items =
    let trd (_, _, x) = x in
-   let trd_rth (_, _, x, y) = x, y in
+   let trd_rth kind (_, _, x, y) = kind, x, y in
    let commit = function
       | T.Heading heading   -> out_preamble och heading
       | T.Line line         -> out_line_comment och line
@@ -98,7 +102,7 @@ let commit och items =
       | T.Coercion specs    -> out_unexported och "COERCION" (snd specs)
       | T.Notation specs    -> out_unexported och "NOTATION" (snd specs) (**)
       | T.Inline (_, T.Var, src, _) -> out_alias och (UriManager.name_of_uri (UriManager.uri_of_string src)) src 
-      | T.Inline specs      -> out_command och (inline (trd_rth specs))
+      | T.Inline specs      -> out_command och (inline (trd_rth kind specs))
       | T.Section specs     -> out_unexported och "UNEXPORTED" (trd specs)
       | T.Comment comment   -> out_comment och comment
       | T.Unexport unexport -> out_unexported och "UNEXPORTED" unexport 
index 53aff69900f528e555e7062991533d3a278d3ef7..3bbd35c7bc64b2ef5c21f7dee0ed097acaba9427 100644 (file)
@@ -23,6 +23,6 @@
  * http://cs.unibo.it/helm/.
  *)
 
-val commit: out_channel -> Types.items -> unit
+val commit: Types.output_kind -> out_channel -> Types.items -> unit
 
 val string_of_inline_kind: Types.inline_kind -> string
index 387d47f12cdde686d546d1095b554a85ebefcbb0..5ef75dab70f4be01abf2d47740260e830ef2c448 100644 (file)
  *)
 
 let main =
-   let help = "Usage: transcript [ <package> | <conf_file> ]*" in
-   let process_package package = Engine.produce (Engine.make package) in
+   let cwd = ref Filename.current_dir_name in
+   let help = "Usage: transcript [ -C <dir> ] [ <package> | <conf_file> ]*" in
+   let help_C = " set working directory to <dir>" in
+   let set_cwd dir = cwd := dir in
+   let process_package package = Engine.produce (Engine.make !cwd package) in
    Engine.init ();
    Arg.parse [
+      ("-C", Arg.String set_cwd, help_C)
    ] process_package help
index d79636f3906d76769b3c5b4d8aaee842d16be9af..ba028de363481a9871453454a3703dbcb3474ccd 100644 (file)
@@ -1,8 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <helm_registry>
   <section name="transcript">
-    <key name="helm_dir">/home/fguidi/svn/software</key>
-    <key name="heading_path">matita/matita.ma.templ</key>
+    <key name="heading_path">matita.ma.templ</key>
     <key name="heading_lines">14</key>
   </section>
 </helm_registry>
index de7c1036e8cc26ab20e6316e7c157eb7ed95c3c4..f0c8212bc47c3271c94045d895592f3a785aacbc 100644 (file)
@@ -27,6 +27,8 @@ type local = bool
 
 type inline_kind = Con | Ind | Var
 
+type output_kind = Declarative | Procedural
+
 type source = string
 
 type prefix = string
diff --git a/helm/software/matita/contribs/CoRN-Procedural/CoRN.conf.xml b/helm/software/matita/contribs/CoRN-Procedural/CoRN.conf.xml
new file mode 100644 (file)
index 0000000..03f6ad8
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<helm_registry>
+  <section name="package">      
+    <key name="input_name">CoRN</key>
+    <key name="output_name">CoRN</key>
+    <key name="input_base_uri">cic:/CoRN</key>
+    <key name="output_base_uri">cic:/matita/CoRN-Procedural</key>
+    <key name="input_path">/projects/helm/exportation/CoRN</key>
+    <key name="output_path">contribs/CoRN-Procedural</key>
+    <key name="input_type">.v</key>
+    <key name="output_type">procedural</key>    
+    <key name="coercion">Z_of_nat cic:/Coq/ZArith/BinInt/Z_of_nat.con</key>
+    <key name="coercion">Zpos cic:/Coq/ZArith/BinInt/Z.ind#xpointer(1/1/2)</key>
+    <key name="coercion">nat_of_P cic:/Coq/NArith/BinPos/nat_of_P.con</key>
+  </section>
+</helm_registry>
diff --git a/helm/software/matita/contribs/CoRN-Procedural/Makefile b/helm/software/matita/contribs/CoRN-Procedural/Makefile
new file mode 100644 (file)
index 0000000..fad6ece
--- /dev/null
@@ -0,0 +1,43 @@
+include ../Makefile.defs
+
+DIR=$(shell basename $$PWD)
+
+H=@
+
+MATITAOPTIONS=
+
+TRANSCRIPT = $(BIN)../components/binaries/transcript/transcript.opt
+
+LOG = log.txt
+
+MMAS = $(shell find -name "*.mma")
+MAS = $(MMAS:%.mma=%.ma)
+
+$(DIR) all:
+       $(H)$(RM) $(LOG)
+       $(H)$(BIN)matitac $(MATITAOPTIONS) 2>> $(LOG)
+$(DIR).opt opt all.opt:
+       $(H)$(RM) $(LOG)
+       $(H)$(BIN)matitac.opt $(MATITAOPTIONS) 2>> $(LOG)
+clean:
+       $(H)$(BIN)matitaclean $(MATITAOPTIONS)
+       $(H)$(RM) $(MAS)
+clean.opt:
+       $(H)$(BIN)matitaclean.opt $(MATITAOPTIONS)
+       $(H)$(RM) $(MAS)
+depend:
+       $$(H)(BIN)matitadep $(MATITAOPTIONS)
+depend.opt:
+       $(H)$(BIN)matitadep.opt $(MATITAOPTIONS)
+
+ifneq ($(strip $(MAS)),)
+clean.ma:
+       $(H)$(BIN)matitaclean.opt $(MATITAOPTIONS) $(MAS)
+       $(H)$(RM) $(MAS)
+else
+clean.ma:
+       $(H)echo no files to clean
+endif
+
+mma: transcript.conf.xml CoRN.conf.xml
+       $(H)$(TRANSCRIPT) -C $(BIN) CoRN
diff --git a/helm/software/matita/contribs/CoRN-Procedural/root b/helm/software/matita/contribs/CoRN-Procedural/root
new file mode 100644 (file)
index 0000000..48c1ed6
--- /dev/null
@@ -0,0 +1 @@
+baseuri=cic:/matita/CoRN-Procedural
diff --git a/helm/software/matita/contribs/CoRN-Procedural/transcript.conf.xml b/helm/software/matita/contribs/CoRN-Procedural/transcript.conf.xml
new file mode 100644 (file)
index 0000000..ba028de
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<helm_registry>
+  <section name="transcript">
+    <key name="heading_path">matita.ma.templ</key>
+    <key name="heading_lines">14</key>
+  </section>
+</helm_registry>
index 28fe09079f84806f751a0a68517b5a4aec05b707..fef14b2b888584258cffccf0ee41955d14617cd2 100644 (file)
@@ -8,9 +8,8 @@ MATITAOPTIONS=$(MATITAUSEROPTIONS) -onepass
 
 LOG = log.txt
 
-DEVELS = Legacy-2 Base-2 LambdaDelta-2
-
-MAS = $(shell find $(DEVELS) -mindepth 2 -name "*.ma")
+MMAS = $(shell find -name "*.mma")
+MAS = $(MMAS:%.mma=%.ma)
 
 $(DIR) all:
        $(H)$(RM) $(LOG)