]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/cic_notation/cicNotationPt.ml
* implemented unless
[helm.git] / helm / ocaml / cic_notation / cicNotationPt.ml
1 (* Copyright (C) 2005, HELM Team.
2  * 
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.
6  * 
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.
11  * 
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.
16  *
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,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://helm.cs.unibo.it/
24  *)
25
26 (** CIC Notation Parse Tree *)
27
28 type binder_kind = [ `Lambda | `Pi | `Exists | `Forall ]
29 type induction_kind = [ `Inductive | `CoInductive ]
30 type sort_kind = [ `Prop | `Set | `Type | `CProp ]
31 type fold_kind = [ `Left | `Right ]
32
33 type location = Lexing.position * Lexing.position
34 (* cut and past from CicAst.loc_of_floc *)
35 let loc_of_floc = function
36   | { Lexing.pos_cnum = loc_begin }, { Lexing.pos_cnum = loc_end } ->
37       (loc_begin, loc_end)
38
39 type term_attribute =
40   [ `Loc of location                  (* source file location *)
41   | `IdRef of string                  (* ACic pointer *)
42   | `Href of UriManager.uri list      (* hyperlinks for literals *)
43   | `Level of int * Gramext.g_assoc   (* precedence, associativity *)
44   ]
45
46 type literal =
47   [ `Symbol of string
48   | `Keyword of string
49   | `Number of string
50   ]
51
52 type term =
53   (* CIC AST *)
54
55   | AttributedTerm of term_attribute * term
56
57   | Appl of term list
58   | Binder of binder_kind * capture_variable * term (* kind, name, body *)
59   | Case of term * string option * term option * (case_pattern * term) list
60       (* what to match, inductive type, out type, <pattern,action> list *)
61   | LetIn of capture_variable * term * term  (* name, body, where *)
62   | LetRec of induction_kind * (capture_variable * term * int) list * term
63       (* (name, body, decreasing argument) list, where *)
64   | Ident of string * subst list option
65       (* literal, substitutions.
66       * Some [] -> user has given an empty explicit substitution list 
67       * None -> user has given no explicit substitution list *)
68   | Implicit
69   | Meta of int * meta_subst list
70   | Num of string * int (* literal, instance *)
71   | Sort of sort_kind
72   | Symbol of string * int  (* canonical name, instance *)
73
74   | UserInput (* place holder for user input, used by MatitaConsole, not to be
75               used elsewhere *)
76   | Uri of string * subst list option (* as Ident, for long names *)
77
78   (* Syntax pattern extensions *)
79
80   | Literal of literal
81   | Layout of layout_pattern
82   | Magic of magic_term
83   | Variable of pattern_variable
84
85   (* name, type. First component must be Ident or Variable (FreshVar _) *)
86 and capture_variable = term * term option
87
88 and meta_subst = term option
89 and subst = string * term
90 and case_pattern = string * capture_variable list
91
92 and box_kind = H | V | HV | HOV
93 and box_spec = box_kind * bool * bool (* kind, spacing, indent *)
94
95 and layout_pattern =
96   | Sub of term * term
97   | Sup of term * term
98   | Below of term * term
99   | Above of term * term
100   | Frac of term * term
101   | Over of term * term
102   | Atop of term * term
103 (*   | array of term * literal option * literal option
104       |+ column separator, row separator +| *)
105   | Sqrt of term
106   | Root of term * term (* argument, index *)
107 (*   | Break *)
108   | Box of box_spec * term list
109
110 and magic_term =
111   (* level 1 magics *)
112   | List0 of term * literal option (* pattern, separator *)
113   | List1 of term * literal option (* pattern, separator *)
114   | Opt of term
115
116   (* level 2 magics *)
117   | Fold of fold_kind * term * string list * term
118     (* base case pattern, recursive case bound names, recursive case pattern *)
119   | Default of term * term  (* "some" case pattern, "none" case pattern *)
120   | If of term * term (* guard, body *)
121   | Unless of term * term (* guard, body *)
122
123 and pattern_variable =
124   (* level 1 and 2 variables *)
125   | NumVar of string
126   | IdentVar of string
127   | TermVar of string
128
129   (* level 1 variables *)
130   | Ascription of term * string
131
132   (* level 2 variables *)
133   | FreshVar of string
134
135 type argument_pattern =
136   | IdentArg of int * string (* eta-depth, name *)
137
138 type cic_appl_pattern =
139   | UriPattern of UriManager.uri
140   | VarPattern of string
141   | ApplPattern of cic_appl_pattern list
142
143 type phrase = (* TODO hackish: replace with TacticAst.statement or similar *)
144   | Print of term
145   | Notation of term * Gramext.g_assoc option * int option * term
146       (* level 1 pattern, associativity, precedence, level 2 pattern *)
147   | Interpretation of (string * argument_pattern list) * cic_appl_pattern
148   | Render of UriManager.uri
149