~ubuntu-branches/ubuntu/wily/coq-doc/wily

« back to all changes in this revision

Viewing changes to tactics/nbtermdn.ml

  • Committer: Bazaar Package Importer
  • Author(s): Stéphane Glondu, Stéphane Glondu, Samuel Mimram
  • Date: 2010-01-07 22:50:39 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100107225039-n3cq82589u0qt0s2
Tags: 8.2pl1-1
[ Stéphane Glondu ]
* New upstream release (Closes: #563669)
  - remove patches
* Packaging overhaul:
  - use git, advertise it in Vcs-* fields of debian/control
  - use debhelper 7 and dh with override
  - use source format 3.0 (quilt)
* debian/control:
  - set Maintainer to d-o-m, set Uploaders to Sam and myself
  - add Homepage field
  - bump Standards-Version to 3.8.3
* Register PDF documentation into doc-base
* Add debian/watch
* Update debian/copyright

[ Samuel Mimram ]
* Change coq-doc's description to mention that it provides documentation in
  pdf format, not postscript, closes: #543545.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(************************************************************************)
 
2
(*  v      *   The Coq Proof Assistant  /  The Coq Development Team     *)
 
3
(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
 
4
(*   \VV/  **************************************************************)
 
5
(*    //   *      This file is distributed under the terms of the       *)
 
6
(*         *       GNU Lesser General Public License Version 2.1        *)
 
7
(************************************************************************)
 
8
 
 
9
(* $Id: nbtermdn.ml 11282 2008-07-28 11:51:53Z msozeau $ *)
 
10
 
 
11
open Util
 
12
open Names
 
13
open Term
 
14
open Libobject
 
15
open Library
 
16
open Pattern
 
17
open Libnames
 
18
 
 
19
(* Named, bounded-depth, term-discrimination nets.
 
20
   Implementation:
 
21
   Term-patterns are stored in discrimination-nets, which are
 
22
   themselves stored in a hash-table, indexed by the first label.
 
23
   They are also stored by name in a table on-the-side, so that we can
 
24
   override them if needed. *)
 
25
 
 
26
(* The former comments are from Chet.
 
27
   See the module dn.ml for further explanations.
 
28
   Eduardo (5/8/97) *)
 
29
 
 
30
type ('na,'a) t = {
 
31
  mutable table : ('na,constr_pattern * 'a) Gmap.t;
 
32
  mutable patterns : (global_reference option,'a Btermdn.t) Gmap.t }
 
33
 
 
34
type ('na,'a) frozen_t = 
 
35
    ('na,constr_pattern * 'a) Gmap.t
 
36
    * (global_reference option,'a Btermdn.t) Gmap.t
 
37
 
 
38
let create () =
 
39
  { table = Gmap.empty;
 
40
    patterns = Gmap.empty }
 
41
 
 
42
let get_dn dnm hkey =
 
43
  try Gmap.find hkey dnm with Not_found -> Btermdn.create ()
 
44
 
 
45
let add dn (na,(pat,valu)) =
 
46
  let hkey = Option.map fst (Termdn.constr_pat_discr pat) in 
 
47
  dn.table <- Gmap.add na (pat,valu) dn.table;
 
48
  let dnm = dn.patterns in
 
49
  dn.patterns <- Gmap.add hkey (Btermdn.add None (get_dn dnm hkey) (pat,valu)) dnm
 
50
    
 
51
let rmv dn na =
 
52
  let (pat,valu) = Gmap.find na dn.table in
 
53
  let hkey = Option.map fst (Termdn.constr_pat_discr pat) in 
 
54
  dn.table <- Gmap.remove na dn.table;
 
55
  let dnm = dn.patterns in
 
56
  dn.patterns <- Gmap.add hkey (Btermdn.rmv None (get_dn dnm hkey) (pat,valu)) dnm
 
57
 
 
58
let in_dn dn na = Gmap.mem na dn.table
 
59
                          
 
60
let remap ndn na (pat,valu) =
 
61
  rmv ndn na;
 
62
  add ndn (na,(pat,valu))
 
63
 
 
64
let lookup dn valu =
 
65
  let hkey = 
 
66
    match (Termdn.constr_val_discr valu) with 
 
67
    | Dn.Label(l,_) -> Some l
 
68
    | _ -> None
 
69
  in 
 
70
  try Btermdn.lookup None (Gmap.find hkey dn.patterns) valu with Not_found -> []
 
71
 
 
72
let app f dn = Gmap.iter f dn.table
 
73
                       
 
74
let dnet_depth = Btermdn.dnet_depth
 
75
                   
 
76
let freeze dn = (dn.table, dn.patterns)
 
77
 
 
78
let unfreeze (fnm,fdnm) dn =
 
79
  dn.table <- fnm;
 
80
  dn.patterns <- fdnm
 
81
 
 
82
let empty dn = 
 
83
  dn.table <- Gmap.empty;
 
84
  dn.patterns <- Gmap.empty
 
85
 
 
86
let to2lists dn = 
 
87
  (Gmap.to_list dn.table, Gmap.to_list dn.patterns)
 
88