1 (* Copyright (C) 2004, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://helm.cs.unibo.it/
28 type location = Lexing.position * Lexing.position
30 let pp_location (loc_begin, loc_end) =
31 let c_begin = loc_begin.Lexing.pos_cnum - loc_begin.Lexing.pos_bol in
32 let c_end = loc_end.Lexing.pos_cnum - loc_end.Lexing.pos_bol in
33 if loc_begin.Lexing.pos_lnum = -1 || loc_end.Lexing.pos_lnum = -1 then
34 sprintf "%d-%d" c_begin c_end
36 sprintf "(%d,%d)-(%d,%d)" loc_begin.Lexing.pos_lnum c_begin
37 loc_end.Lexing.pos_lnum c_end
39 let floc_of_loc (loc_begin, loc_end) =
41 { Lexing.pos_fname = ""; Lexing.pos_lnum = -1; Lexing.pos_bol = -1;
42 Lexing.pos_cnum = loc_begin }
44 let floc_end = { floc_begin with Lexing.pos_cnum = loc_end } in
45 (floc_begin, floc_end)
47 let loc_of_floc = function
48 | { Lexing.pos_cnum = loc_begin }, { Lexing.pos_cnum = loc_end } ->
51 let dummy_floc = floc_of_loc (-1, -1)
53 type binder_kind = [ `Lambda | `Pi | `Exists | `Forall ]
54 type induction_kind = [ `Inductive | `CoInductive ]
55 type sort_kind = [ `Prop | `Set | `Type | `CProp ]
63 | AttributedTerm of term_attribute * term
66 | Binder of binder_kind * capture_variable * term
67 | Case of term * string option * term option * (case_pattern * term) list
68 | LetIn of capture_variable * term * term
69 | LetRec of induction_kind * (capture_variable * term * int) list * term
70 | Ident of string * subst list option
72 | Meta of int * meta_subst list
75 | Symbol of string * int
78 | Uri of string * subst list option
80 and capture_variable = Cic.name * term option
81 and meta_subst = term option
82 and subst = string * term
83 and case_pattern = string * capture_variable list
88 (fun ast acc -> Binder (`Forall, (Cic.Anonymous, Some ast), acc))
91 let rec unpack = function
92 | Binder (`Forall, (Cic.Anonymous, Some ast), Sort `Type) -> [ast]
93 | Binder (`Forall, (Cic.Anonymous, Some ast), tgt) -> ast :: unpack tgt