1 (***********************************************************************)
3 (* MLTk, Tcl/Tk interface of Objective Caml *)
5 (* Francois Rouaix, Francois Pessaux, Jun Furuse and Pierre Weis *)
6 (* projet Cristal, INRIA Rocquencourt *)
7 (* Jacques Garrigue, Kyoto University RIMS *)
9 (* Copyright 2002 Institut National de Recherche en Informatique et *)
10 (* en Automatique and Kyoto University. All rights reserved. *)
11 (* This file is distributed under the terms of the GNU Library *)
12 (* General Public License, with the special exception on linking *)
13 (* described in file LICENSE found in the Objective Caml source tree. *)
15 (***********************************************************************)
23 let rec nop = function
24 | Line _ -> incr linenum
25 | Ifdef (_, _, c1, c2o) ->
28 | Some c2 -> List.iter nop c2
34 let rec exec lp f = function
37 prerr_endline (Printf.sprintf "%03d: %s" !linenum
38 (String.sub line 0 ((String.length line) - 1)));
40 | Ifdef (sw, k, c1, c2o) ->
41 if List.mem k !defined = sw then begin
42 List.iter (exec lp f) c1;
44 | Some c2 -> List.iter nop c2
53 List.iter (exec lp f) c2
56 | Define k -> defined := k :: !defined
58 defined := List.fold_right (fun k' s ->
59 if k = k' then s else k' :: s) [] !defined