1 (* Copyright (C) 2005, 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/
32 let pp_l1_pattern = CicNotationPp.pp_term
33 let pp_l2_pattern = CicNotationPp.pp_term
35 let pp_alias = function
36 | Ident_alias (id, uri) -> sprintf "alias id \"%s\" = \"%s\"" id uri
37 | Symbol_alias (symb, instance, desc) ->
38 sprintf "alias symbol \"%s\" %s= \"%s\""
40 (if instance=0 then "" else "(instance "^ string_of_int instance ^ ") ")
42 | Number_alias (instance,desc) ->
43 sprintf "alias num (instance %d) = \"%s\"" instance desc
45 let pp_associativity = function
46 | Gramext.LeftA -> "left associative"
47 | Gramext.RightA -> "right associative"
48 | Gramext.NonA -> "non associative"
50 let pp_precedence i = sprintf "with precedence %d" i
52 let pp_argument_pattern = function
53 | CicNotationPt.IdentArg (eta_depth, name) ->
54 let eta_buf = Buffer.create 5 in
55 for i = 1 to eta_depth do
56 Buffer.add_string eta_buf "\\eta."
58 sprintf "%s%s" (Buffer.contents eta_buf) name
60 let pp_interpretation dsc symbol arg_patterns cic_appl_pattern =
61 sprintf "interpretation \"%s\" '%s %s = %s"
63 (String.concat " " (List.map pp_argument_pattern arg_patterns))
64 (CicNotationPp.pp_cic_appl_pattern cic_appl_pattern)
66 let pp_dir_opt = function
68 | Some `LeftToRight -> "> "
69 | Some `RightToLeft -> "< "
71 let pp_notation dir_opt l1_pattern assoc prec l2_pattern =
72 sprintf "notation %s\"%s\" %s %s for %s"
74 (pp_l1_pattern l1_pattern)
75 (pp_associativity assoc)
77 (pp_l2_pattern l2_pattern)
79 let pp_command = function
80 | Include (_,_,mode,path) -> (* not precise, since path is absolute *)
81 if mode = WithPreferences then
85 | Alias (_,s) -> pp_alias s
86 | Interpretation (_, dsc, (symbol, arg_patterns), cic_appl_pattern) ->
87 pp_interpretation dsc symbol arg_patterns cic_appl_pattern
88 | Notation (_, dir_opt, l1_pattern, assoc, prec, l2_pattern) ->
89 pp_notation dir_opt l1_pattern assoc prec l2_pattern