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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
(****************************************************************************)
(* the diy toolsuite *)
(* *)
(* Jade Alglave, University College London, UK. *)
(* Luc Maranget, INRIA Paris-Rocquencourt, France. *)
(* *)
(* Copyright 2011-present Institut National de Recherche en Informatique et *)
(* en Automatique and the authors. All rights reserved. *)
(* *)
(* This software is governed by the CeCILL-B license under French law and *)
(* abiding by the rules of distribution of free software. You can use, *)
(* modify and/ or redistribute the software under the terms of the CeCILL-B *)
(* license as circulated by CEA, CNRS and INRIA at the following URL *)
(* "http://www.cecill.info". We also give a copy in LICENSE.txt. *)
(****************************************************************************)
(*******************************************)
(* Passing hints from generators to litmus *)
(*******************************************)
type t = (string * string) list
(*****************)
(* Dumping hints *)
(*****************)
open Printf
type out = out_channel option
let none = None
let open_out fname =
try
let chan = open_out fname in
Some chan
with Sys_error msg ->
Warn.warn_always "Cannot open info file: %s" msg ;
None
let close_out = function
| None -> ()
| Some chan -> close_out chan
let dump out name h = match out with
| None -> ()
| Some chan ->
List.iter
(fun (k,v) -> fprintf chan "%s %s %s\n" name k v)
h
(*****************)
(* Reading hints *)
(*****************)
module M = Map.Make(String)
let get_infos m name =
try M.find name m
with Not_found -> []
type table = t M.t
let empty = M.empty
let do_read m fname =
LexHint.read fname
(fun m name k v ->
let xs = get_infos m name in
M.add name ((k,v)::xs) m)
m
let read fname = do_read empty fname
let get m name =
let xs = M.find name m in
xs
|