]> matita.cs.unibo.it Git - helm.git/blob - matita/components/grafite/grafiteAst.ml
- LexiconAst merged into GrafiteAst
[helm.git] / matita / components / grafite / grafiteAst.ml
1 (* Copyright (C) 2004, 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 (* $Id$ *)
27
28 type direction = [ `LeftToRight | `RightToLeft ]
29
30 type loc = Stdpp.location
31
32 type npattern = 
33  NotationPt.term option * (string * NotationPt.term) list * NotationPt.term option
34
35 type auto_params = NotationPt.term list option * (string*string) list
36
37 type ntactic =
38    | NApply of loc * NotationPt.term
39    | NSmartApply of loc * NotationPt.term
40    | NAssert of loc * ((string * [`Decl of NotationPt.term | `Def of NotationPt.term * NotationPt.term]) list * NotationPt.term) list
41    | NCases of loc * NotationPt.term * npattern  
42    | NCase1 of loc * string
43    | NChange of loc * npattern * NotationPt.term
44    | NConstructor of loc * int option * NotationPt.term list
45    | NCut of loc * NotationPt.term
46 (* | NDiscriminate of loc * NotationPt.term
47    | NSubst of loc * NotationPt.term *)
48    | NDestruct of loc * string list option * string list
49    | NElim of loc * NotationPt.term * npattern  
50    | NGeneralize of loc * npattern
51    | NId of loc
52    | NIntro of loc * string
53    | NIntros of loc * string list
54    | NInversion of loc * NotationPt.term * npattern  
55    | NLApply of loc * NotationPt.term
56    | NLetIn of loc * npattern * NotationPt.term * string
57    | NReduce of loc * [ `Normalize of bool | `Whd of bool ] * npattern
58    | NRewrite of loc * direction * NotationPt.term * npattern
59    | NAuto of loc * auto_params
60    | NDot of loc
61    | NSemicolon of loc
62    | NBranch of loc
63    | NShift of loc
64    | NPos of loc * int list
65    | NPosbyname of loc * string
66    | NWildcard of loc
67    | NMerge of loc
68    | NSkip of loc
69    | NFocus of loc * int list
70    | NUnfocus of loc
71    | NTry of loc * ntactic
72    | NAssumption of loc
73    | NRepeat of loc * ntactic
74    | NBlock of loc * ntactic list
75
76 type nmacro =
77   | NCheck of loc * NotationPt.term
78   | Screenshot of loc * string
79   | NAutoInteractive of loc * auto_params
80   | NIntroGuess of loc
81
82 (** To be increased each time the command type below changes, used for "safe"
83  * marshalling *)
84 let magic = 35
85
86 (* composed magic: term + command magics. No need to change this value *)
87 let magic = magic + 10000 * NotationPt.magic
88
89 type command =
90   | Set of loc * string * string
91   | Print of loc * string
92
93 type alias_spec =
94   | Ident_alias of string * string        (* identifier, uri *)
95   | Symbol_alias of string * int * string (* name, instance no, description *)
96   | Number_alias of int * string          (* instance no, description *)
97
98 type inclusion_mode = WithPreferences | WithoutPreferences (* aka aliases *)
99
100 type ncommand =
101   | Include of loc * inclusion_mode * string (* _,buri,_,path *)
102   | UnificationHint of loc * NotationPt.term * int (* term, precedence *)
103   | NObj of loc * NotationPt.term NotationPt.obj
104   | NDiscriminator of loc * NotationPt.term
105   | NInverter of loc * string * NotationPt.term * bool list option * NotationPt.term option
106   | NUnivConstraint of loc * NUri.uri * NUri.uri
107   | NCopy of loc * string * NUri.uri * (NUri.uri * NUri.uri) list
108   | NCoercion of loc * string *
109       NotationPt.term * NotationPt.term *
110       (string * NotationPt.term) * NotationPt.term
111   | NQed of loc
112   (* ex lexicon commands *)
113   | Alias of loc * alias_spec
114       (** parameters, name, type, fields *) 
115   | Notation of loc * direction option * NotationPt.term * Gramext.g_assoc *
116       int * NotationPt.term
117       (* direction, l1 pattern, associativity, precedence, l2 pattern *)
118   | Interpretation of loc *
119       string * (string * NotationPt.argument_pattern list) *
120         NotationPt.cic_appl_pattern
121       (* description (i.e. id), symbol, arg pattern, appl pattern *)
122
123 type code =
124   | Command of loc * command
125   | NCommand of loc * ncommand
126   | NMacro of loc * nmacro 
127   | NTactic of loc * ntactic list
128              
129 type comment =
130   | Note of loc * string
131   | Code of loc * code
132              
133 type statement =
134   | Executable of loc * code
135   | Comment of loc * comment
136
137 let description_of_alias =
138  function
139     Ident_alias (_,desc)
140   | Symbol_alias (_,_,desc)
141   | Number_alias (_,desc) -> desc