|
diff --git a/plugins/extraction/scheme.ml b/plugins/extraction/scheme.ml |
|
index 7915bc8..ee2b3fb 100644 |
|
--- a/plugins/extraction/scheme.ml |
|
+++ b/plugins/extraction/scheme.ml |
|
@@ -23,14 +23,15 @@ open Common |
|
let keywords = |
|
List.fold_right (fun s -> Idset.add (id_of_string s)) |
|
[ "define"; "let"; "lambda"; "lambdas"; "match"; |
|
- "apply"; "car"; "cdr"; |
|
+ "apply"; "car"; "cdr"; "list"; "letrec"; |
|
"error"; "delay"; "force"; "_"; "__"] |
|
Idset.empty |
|
|
|
let preamble _ _ usf = |
|
+ str ";; -*- lexical-binding: t -*-\n" ++ |
|
str ";; This extracted scheme code relies on some additional macros\n" ++ |
|
str ";; available at http://www.pps.jussieu.fr/~letouzey/scheme\n" ++ |
|
- str "(load \"macros_extr.scm\")\n\n" ++ |
|
+ str ";; (load \"macros_extr.scm\")\n\n" ++ |
|
(if usf.mldummy then str "(define __ (lambda (_) __))\n\n" else mt ()) |
|
|
|
let pr_id id = |
|
@@ -44,13 +45,11 @@ let paren = pp_par true |
|
|
|
let pp_abst st = function |
|
| [] -> assert false |
|
- | [id] -> paren (str "lambda " ++ paren (pr_id id) ++ spc () ++ st) |
|
| l -> paren |
|
(str "lambdas " ++ paren (prlist_with_sep spc pr_id l) ++ spc () ++ st) |
|
|
|
let pp_apply st _ = function |
|
| [] -> st |
|
- | [a] -> hov 2 (paren (st ++ spc () ++ a)) |
|
| args -> hov 2 (paren (str "@ " ++ st ++ |
|
(prlist_strict (fun x -> spc () ++ x) args))) |
|
|
|
@@ -88,8 +87,7 @@ let rec pp_expr env args = |
|
| MLcons (_,r,args') -> |
|
assert (args=[]); |
|
let st = |
|
- str "`" ++ |
|
- paren (pp_global Cons r ++ |
|
+ paren (str "list ':" ++ pp_global Cons r ++ |
|
(if args' = [] then mt () else spc ()) ++ |
|
prlist_with_sep spc (pp_cons_args env) args') |
|
in |
|
@@ -128,10 +126,10 @@ let rec pp_expr env args = |
|
|
|
and pp_cons_args env = function |
|
| MLcons (_,r,args) when is_coinductive r -> |
|
- paren (pp_global Cons r ++ |
|
+ paren (str ":" ++ pp_global Cons r ++ |
|
(if args = [] then mt () else spc ()) ++ |
|
prlist_with_sep spc (pp_cons_args env) args) |
|
- | e -> str "," ++ pp_expr env [] e |
|
+ | e -> pp_expr env [] e |
|
|
|
and pp_one_pat env (ids,p,t) = |
|
let r = match p with |
|
@@ -149,7 +147,7 @@ and pp_one_pat env (ids,p,t) = |
|
and pp_pat env pv = |
|
prvect_with_sep fnl |
|
(fun x -> let s1,s2 = pp_one_pat env x in |
|
- hov 2 (str "((" ++ s1 ++ str ")" ++ spc () ++ s2 ++ str ")")) pv |
|
+ hov 2 (str "((:" ++ s1 ++ str ")" ++ spc () ++ s2 ++ str ")")) pv |
|
|
|
(*s names of the functions ([ids]) are already pushed in [env], |
|
and passed here just for convenience. *) |