2 (****************************************************************************)
6 (* INRIA Rocquencourt *)
8 (* Copyright 2006 Institut National de Recherche en Informatique et *)
9 (* en Automatique. All rights reserved. This file is distributed under *)
10 (* the terms of the GNU Library General Public License, with the special *)
11 (* exception on linking described in LICENSE at the top of the Objective *)
12 (* Caml source tree. *)
14 (****************************************************************************)
19 * - Daniel de Rauglaudre: initial version
20 * - Nicolas Pouillard: refactoring
22 module Make (Structure : Structure.S) = struct
25 module Parse = Parser.Make Structure;
26 module Fail = Failed.Make Structure;
29 module Stream = struct
31 value junk strm = Context.junk strm;
32 value count strm = Context.bp strm;
35 value sfold0 f e _entry _symbl psymb =
38 [ [: a = psymb; s :] -> fold (f a accu) s
41 parser [: a = fold e :] -> a
44 value sfold1 f e _entry _symbl psymb =
47 [ [: a = psymb; s :] -> fold (f a accu) s
50 parser [: a = psymb; a = fold (f a e) :] -> a
53 value sfold0sep f e entry symbl psymb psep =
56 [ [symb; sep] -> Fail.symb_failed_txt entry sep symb
61 [ [: () = psep; a = psymb ?? failed symbl; s :] -> kont (f a accu) s
65 [ [: a = psymb; s :] -> kont (f a e) s
69 value sfold1sep f e entry symbl psymb psep =
72 [ [symb; sep] -> Fail.symb_failed_txt entry sep symb
77 [ [symb; _] -> Parse.parse_top_symb entry symb (* FIXME context *)
78 | _ -> raise Stream.Failure ]
85 [ [: a = psymb :] -> a
86 | [: a = parse_top symbl :] -> Obj.magic a
87 | [: :] -> raise (Stream.Error (failed symbl)) ];
92 parser [: a = psymb; s :] -> kont (f a e) s