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/
28 (** CIC Notation Parse Tree *)
30 type binder_kind = [ `Lambda | `Pi | `Exists | `Forall ]
31 type induction_kind = [ `Inductive | `CoInductive ]
32 type sort_kind = [ `Prop | `Set | `Type of CicUniv.universe | `CProp ]
33 type fold_kind = [ `Left | `Right ]
35 type location = Token.flocation
37 let (x, y) = HExtlib.loc_of_floc floc in
38 failwith (Printf.sprintf "Error at characters %d - %d: %s" x y msg)
40 type href = UriManager.uri
42 type child_pos = [ `Left | `Right | `Inner ]
45 [ `Loc of location (* source file location *)
46 | `IdRef of string (* ACic pointer *)
47 | `Level of int * Gramext.g_assoc (* precedence, associativity *)
48 | `ChildPos of child_pos (* position of l1 pattern variables *)
49 | `XmlAttrs of (string option * string * string) list
50 (* list of XML attributes: namespace, name, value *)
51 | `Raw of string (* unparsed version *)
60 type case_indtype = string * href option
62 (** To be increased each time the term type below changes, used for "safe"
69 | AttributedTerm of term_attribute * term
72 | Binder of binder_kind * capture_variable * term (* kind, name, body *)
73 | Case of term * case_indtype option * term option *
74 (case_pattern * term) list
75 (* what to match, inductive type, out type, <pattern,action> list *)
77 | LetIn of capture_variable * term * term (* name, body, where *)
78 | LetRec of induction_kind * (capture_variable * term * int) list * term
79 (* (name, body, decreasing argument) list, where *)
80 | Ident of string * subst list option
81 (* literal, substitutions.
82 * Some [] -> user has given an empty explicit substitution list
83 * None -> user has given no explicit substitution list *)
85 | Meta of int * meta_subst list
86 | Num of string * int (* literal, instance *)
88 | Symbol of string * int (* canonical name, instance *)
90 | UserInput (* place holder for user input, used by MatitaConsole, not to be
92 | Uri of string * subst list option (* as Ident, for long names *)
94 (* Syntax pattern extensions *)
97 | Layout of layout_pattern
100 | Variable of pattern_variable
102 (* name, type. First component must be Ident or Variable (FreshVar _) *)
103 and capture_variable = term * term option
105 and meta_subst = term option
106 and subst = string * term
107 and case_pattern = string * href option * capture_variable list
109 and box_kind = H | V | HV | HOV
110 and box_spec = box_kind * bool * bool (* kind, spacing, indent *)
115 | Below of term * term
116 | Above of term * term
117 | Frac of term * term
118 | Over of term * term
119 | Atop of term * term
120 (* | array of term * literal option * literal option
121 |+ column separator, row separator +| *)
123 | Root of term * term (* argument, index *)
125 | Box of box_spec * term list
130 | List0 of term * literal option (* pattern, separator *)
131 | List1 of term * literal option (* pattern, separator *)
135 | Fold of fold_kind * term * string list * term
136 (* base case pattern, recursive case bound names, recursive case pattern *)
137 | Default of term * term (* "some" case pattern, "none" case pattern *)
139 | If of term * term * term (* test, pattern if true, pattern if false *)
141 and pattern_variable =
142 (* level 1 and 2 variables *)
147 (* level 1 variables *)
148 | Ascription of term * string
150 (* level 2 variables *)
153 type argument_pattern =
154 | IdentArg of int * string (* eta-depth, name *)
156 type cic_appl_pattern =
157 | UriPattern of UriManager.uri
158 | VarPattern of string
160 | ApplPattern of cic_appl_pattern list
162 (** <name, inductive/coinductive, type, constructor list>
163 * true means inductive, false coinductive *)
164 type 'term inductive_type = string * bool * 'term * (string * 'term) list
167 | Inductive of (string * term) list * term inductive_type list
168 (** parameters, list of loc * mutual inductive types *)
169 | Theorem of Cic.object_flavour * string * term * term option
170 (** flavour, name, type, body
171 * - name is absent when an unnamed theorem is being proved, tipically in
173 * - body is present when its given along with the command, otherwise it
174 * will be given in proof editing mode using the tactical language
176 | Record of (string * term) list * string * term * (string * term * bool) list
177 (** left parameters, name, type, fields *)
179 (** {2 Standard precedences} *)
186 let let_in_assoc = Gramext.NonA
187 let binder_assoc = Gramext.RightA
188 let apply_assoc = Gramext.LeftA
189 let simple_assoc = Gramext.NonA