1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
(***********************************************************************)
(* *)
(* Ledit *)
(* *)
(* Daniel de Rauglaudre, INRIA Rocquencourt *)
(* *)
(* Copyright 2001-2007 Institut National de Recherche en Informatique *)
(* et Automatique. Distributed only by permission. *)
(* *)
(***********************************************************************)
(* $Id: pa_local.ml,v 1.4 2007/01/03 09:42:46 deraugla Exp $ *)
#load "pa_extend.cmo";
#load "q_MLast.cmo";
open Pcaml;
value expr_of_patt p =
let loc = MLast.loc_of_patt p in
match p with
[ <:patt< $lid:x$ >> -> <:expr< $lid:x$ >>
| _ -> Stdpp.raise_with_loc loc (Stream.Error "identifier expected") ]
;
EXTEND
str_item:
[ [ "local"; rf = [ "rec" -> True | -> False ];
lb = LIST1 let_binding SEP "and"; "in"; "value";
rf1 = [ "rec" -> True | -> False ];
lb1 = LIST1 let_binding SEP "and" ->
let pl = List.map (fun (a, _, _) -> a) lb1 in
let el = List.map expr_of_patt pl in
<:str_item<
value ($list:pl$) =
let $opt:rf$ $list:lb$ in
let $opt:rf1$ $list:lb1$ in
($list:el$) >> ] ]
;
END;
|