diff options
author | aspiwack <aspiwack@85f007b7-540e-0410-9357-904b9bb8a0f7> | 2012-08-24 17:36:36 +0000 |
---|---|---|
committer | aspiwack <aspiwack@85f007b7-540e-0410-9357-904b9bb8a0f7> | 2012-08-24 17:36:36 +0000 |
commit | 7993d50d0d1dd029b34745e1ee089d9cf7c5ffbd (patch) | |
tree | c63659baaa5fbb525c6fc1cb4ad882e8e6b55e1c /plugins/extraction/ocaml.ml | |
parent | 6a2f9c59ea44d754050b4a2ccb624adcc846924d (diff) |
Experimental support for a comment in the files' preamble in extraction.
Scheme comments are output on a single line because Ocaml's Format
module which serves as a backend to Pp has an integer, rather than a string
as identation value, so we cannot make it so that each new line in the
comment starts with ";; ".
I've tried something with Pp.ifb but it was hackish at best and had somewhat
strange results.
Known bug: as Pp.std_ppcmds is non-persistent, the comment is actually printed
only once per Extraction command, even if it outputs several files.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@15763 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'plugins/extraction/ocaml.ml')
-rw-r--r-- | plugins/extraction/ocaml.ml | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/plugins/extraction/ocaml.ml b/plugins/extraction/ocaml.ml index be2ad57bf..3d21fc2d8 100644 --- a/plugins/extraction/ocaml.ml +++ b/plugins/extraction/ocaml.ml @@ -62,7 +62,10 @@ let keywords = let pp_open mp = str ("open "^ string_of_modfile mp ^"\n") -let preamble _ used_modules usf = +let pp_comment s = str "(* " ++ hov 0 s ++ str " *)" + +let preamble _ comment used_modules usf = + pp_comment comment ++ fnl () ++ fnl () ++ prlist pp_open used_modules ++ (if used_modules = [] then mt () else fnl ()) ++ (if usf.tdummy || usf.tunknown then str "type __ = Obj.t\n" else mt()) ++ @@ -71,7 +74,8 @@ let preamble _ used_modules usf = else mt ()) ++ (if usf.tdummy || usf.tunknown || usf.mldummy then fnl () else mt ()) -let sig_preamble _ used_modules usf = +let sig_preamble _ comment used_modules usf = + pp_comment comment ++ fnl () ++ fnl () ++ prlist pp_open used_modules ++ (if used_modules = [] then mt () else fnl ()) ++ (if usf.tdummy || usf.tunknown then str "type __ = Obj.t\n\n" else mt()) @@ -413,7 +417,6 @@ let pp_equiv param_list name = function | RenEquiv ren, _ -> str " = " ++ pp_parameters param_list ++ str (ren^".") ++ name -let pp_comment s = str "(* " ++ s ++ str " *)" let pp_one_ind prefix ip_equiv pl name cnames ctyps = let pl = rename_tvars keywords pl in |