program extraction to OCaml (WIP)

parent ad8aba1a
......@@ -357,7 +357,7 @@ install_local: bin/why3
########
PGM_FILES = pgm_ttree pgm_types pgm_pretty \
pgm_module pgm_wp pgm_env pgm_typing pgm_main
pgm_module pgm_wp pgm_env pgm_typing pgm_ocaml pgm_main
PGMMODULES = $(addprefix src/programs/, $(PGM_FILES))
......
......@@ -28,6 +28,8 @@ open Typing
open Ptree
open Pgm_module
let debug_extraction = Debug.register_flag "extraction"
exception ClashModule of string
let () = Exn_printer.register (fun fmt e -> match e with
......@@ -62,6 +64,7 @@ let add_module ?(type_only=false) env penv path (ltm, lmod) m =
List.fold_left (Pgm_typing.decl ~wp env penv ltm lmod) uc m.mod_decl
in
let md = close_module uc in
if Debug.test_flag debug_extraction then Pgm_ocaml.extract_module path md;
Mstr.add ("WP " ^ id.id) md.m_pure ltm, (* avoids a theory/module clash *)
Mstr.add id.id md lmod
......
This diff is collapsed.
(* OCaml program extraction *)
val extract_module: string list -> Pgm_module.t -> unit
(*
module Test
use import module ref.Ref
......@@ -21,14 +22,37 @@ module Test
end
*)
module M
use import int.Int
use import module ref.Ref
type t 'a 'b = (int, 'a, ('b, int))
use import list.List
type tree 'a = E | N (forest 'a)
with forest 'b = list (tree 'b)
inductive even int int int =
| even0: even 0 1 2
with odd int int =
| odd0: odd 1 2
function c : int = 0b010101010
function f (x:int) : int = g (x+1)
with g (x:int) : int
predicate p (x:int) = forall y: int. q x y
with q (x:int) (y:int) = x >= y
predicate is_zero (a:int) = a=0
let test1 () =
let x = ref 0 in
while !x = 0 do variant { !x } () done
while is_zero !x do variant { !x } () done
(*
use import option.Option
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment