author | wenzelm |
Wed, 29 Dec 2010 20:41:33 +0100 | |
changeset 41415 | 23533273220a |
parent 39288 | f1ae2493d93f |
child 42048 | afd11ca8e018 |
permissions | -rw-r--r-- |
18 | 1 |
(* Title: Pure/Syntax/type_ext.ML |
0 | 2 |
Author: Tobias Nipkow and Markus Wenzel, TU Muenchen |
3 |
||
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
4 |
Utilities for input and output of types. The concrete syntax of types. |
0 | 5 |
*) |
6 |
||
7 |
signature TYPE_EXT0 = |
|
2584 | 8 |
sig |
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
9 |
val sort_of_term: term -> sort |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
10 |
val term_sorts: term -> (indexname * sort) list |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
11 |
val typ_of_term: (indexname -> sort) -> term -> typ |
22764 | 12 |
val decode_term: (((string * int) * sort) list -> string * int -> sort) -> |
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
13 |
(string -> bool * string) -> (string -> string option) -> term -> term |
6901 | 14 |
val term_of_typ: bool -> typ -> term |
10572 | 15 |
val no_brackets: unit -> bool |
16614 | 16 |
val no_type_brackets: unit -> bool |
35668 | 17 |
val type_ast_trs: |
18 |
{read_class: Proof.context -> string -> string, |
|
19 |
read_type: Proof.context -> string -> string} -> |
|
20 |
(string * (Proof.context -> Ast.ast list -> Ast.ast)) list |
|
2584 | 21 |
end; |
0 | 22 |
|
23 |
signature TYPE_EXT = |
|
2584 | 24 |
sig |
0 | 25 |
include TYPE_EXT0 |
2584 | 26 |
val term_of_sort: sort -> term |
1511 | 27 |
val tappl_ast_tr': Ast.ast * Ast.ast list -> Ast.ast |
8895 | 28 |
val sortT: typ |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
36502
diff
changeset
|
29 |
val type_ext: Syn_Ext.syn_ext |
2584 | 30 |
end; |
0 | 31 |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
36502
diff
changeset
|
32 |
structure Type_Ext: TYPE_EXT = |
0 | 33 |
struct |
2584 | 34 |
|
35 |
(** input utils **) |
|
0 | 36 |
|
8895 | 37 |
(* sort_of_term *) |
2584 | 38 |
|
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
39 |
fun sort_of_term tm = |
557
9d386e6c02b7
added raw_term_sorts and changed typ_of_term accordingly (part of fix
wenzelm
parents:
347
diff
changeset
|
40 |
let |
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
41 |
fun err () = raise TERM ("sort_of_term: bad encoding of classes", [tm]); |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
42 |
|
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
43 |
fun class s = Lexicon.unmark_class s handle Fail _ => err (); |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
44 |
|
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
45 |
fun classes (Const (s, _)) = [class s] |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
46 |
| classes (Const ("_classes", _) $ Const (s, _) $ cs) = class s :: classes cs |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
47 |
| classes _ = err (); |
0 | 48 |
|
2584 | 49 |
fun sort (Const ("_topsort", _)) = [] |
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
50 |
| sort (Const (s, _)) = [class s] |
3778 | 51 |
| sort (Const ("_sort", _) $ cs) = classes cs |
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
52 |
| sort _ = err (); |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
53 |
in sort tm end; |
8895 | 54 |
|
2584 | 55 |
|
22704 | 56 |
(* term_sorts *) |
8895 | 57 |
|
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
58 |
fun term_sorts tm = |
8895 | 59 |
let |
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
60 |
val sort_of = sort_of_term; |
22704 | 61 |
|
62 |
fun add_env (Const ("_ofsort", _) $ Free (x, _) $ cs) = |
|
63 |
insert (op =) ((x, ~1), sort_of cs) |
|
64 |
| add_env (Const ("_ofsort", _) $ (Const ("_tfree", _) $ Free (x, _)) $ cs) = |
|
65 |
insert (op =) ((x, ~1), sort_of cs) |
|
66 |
| add_env (Const ("_ofsort", _) $ Var (xi, _) $ cs) = |
|
67 |
insert (op =) (xi, sort_of cs) |
|
68 |
| add_env (Const ("_ofsort", _) $ (Const ("_tvar", _) $ Var (xi, _)) $ cs) = |
|
69 |
insert (op =) (xi, sort_of cs) |
|
70 |
| add_env (Abs (_, _, t)) = add_env t |
|
71 |
| add_env (t1 $ t2) = add_env t1 #> add_env t2 |
|
72 |
| add_env _ = I; |
|
8895 | 73 |
in add_env tm [] end; |
557
9d386e6c02b7
added raw_term_sorts and changed typ_of_term accordingly (part of fix
wenzelm
parents:
347
diff
changeset
|
74 |
|
9d386e6c02b7
added raw_term_sorts and changed typ_of_term accordingly (part of fix
wenzelm
parents:
347
diff
changeset
|
75 |
|
2584 | 76 |
(* typ_of_term *) |
0 | 77 |
|
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
78 |
fun typ_of_term get_sort tm = |
557
9d386e6c02b7
added raw_term_sorts and changed typ_of_term accordingly (part of fix
wenzelm
parents:
347
diff
changeset
|
79 |
let |
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
80 |
fun err () = raise TERM ("typ_of_term: bad encoding of type", [tm]); |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
81 |
|
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
82 |
fun typ_of (Free (x, _)) = TFree (x, get_sort (x, ~1)) |
557
9d386e6c02b7
added raw_term_sorts and changed typ_of_term accordingly (part of fix
wenzelm
parents:
347
diff
changeset
|
83 |
| typ_of (Var (xi, _)) = TVar (xi, get_sort xi) |
32784 | 84 |
| typ_of (Const ("_tfree",_) $ (t as Free _)) = typ_of t |
85 |
| typ_of (Const ("_tvar",_) $ (t as Var _)) = typ_of t |
|
12317 | 86 |
| typ_of (Const ("_ofsort", _) $ Free (x, _) $ _) = TFree (x, get_sort (x, ~1)) |
16614 | 87 |
| typ_of (Const ("_ofsort", _) $ (Const ("_tfree",_) $ Free (x, _)) $ _) = |
88 |
TFree (x, get_sort (x, ~1)) |
|
12317 | 89 |
| typ_of (Const ("_ofsort", _) $ Var (xi, _) $ _) = TVar (xi, get_sort xi) |
16614 | 90 |
| typ_of (Const ("_ofsort", _) $ (Const ("_tvar",_) $ Var (xi, _)) $ _) = |
91 |
TVar (xi, get_sort xi) |
|
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
92 |
| typ_of (Const ("_dummy_ofsort", _) $ t) = TFree ("'_dummy_", sort_of_term t) |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
93 |
| typ_of t = |
0 | 94 |
let |
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
95 |
val (head, args) = Term.strip_comb t; |
0 | 96 |
val a = |
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
97 |
(case head of |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
98 |
Const (c, _) => (Lexicon.unmark_type c handle Fail _ => err ()) |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
99 |
| _ => err ()); |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
100 |
in Type (a, map typ_of args) end; |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
101 |
in typ_of tm end; |
0 | 102 |
|
103 |
||
22764 | 104 |
(* decode_term -- transform parse tree into raw term *) |
22704 | 105 |
|
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
106 |
fun decode_term get_sort map_const map_free tm = |
22704 | 107 |
let |
36448
edb757388592
get_sort: minimize sorts given in the text, while keeping those from the context unchanged (the latter are preferred);
wenzelm
parents:
35668
diff
changeset
|
108 |
val decodeT = typ_of_term (get_sort (term_sorts tm)); |
22704 | 109 |
|
110 |
fun decode (Const ("_constrain", _) $ t $ typ) = |
|
39288 | 111 |
Type.constraint (decodeT typ) (decode t) |
22704 | 112 |
| decode (Const ("_constrainAbs", _) $ (Abs (x, T, t)) $ typ) = |
113 |
if T = dummyT then Abs (x, decodeT typ, decode t) |
|
39288 | 114 |
else Type.constraint (decodeT typ --> dummyT) (Abs (x, T, decode t)) |
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
115 |
| decode (Abs (x, T, t)) = Abs (x, T, decode t) |
22704 | 116 |
| decode (t $ u) = decode t $ decode u |
117 |
| decode (Const (a, T)) = |
|
36502
586af36cf3cc
uniform decoding of fixed/const syntax entities, allows to pass "\<^fixed>foo__" through the syntax layer (supersedes 1b7109c10b7b);
wenzelm
parents:
36448
diff
changeset
|
118 |
(case try Lexicon.unmark_fixed a of |
586af36cf3cc
uniform decoding of fixed/const syntax entities, allows to pass "\<^fixed>foo__" through the syntax layer (supersedes 1b7109c10b7b);
wenzelm
parents:
36448
diff
changeset
|
119 |
SOME x => Free (x, T) |
586af36cf3cc
uniform decoding of fixed/const syntax entities, allows to pass "\<^fixed>foo__" through the syntax layer (supersedes 1b7109c10b7b);
wenzelm
parents:
36448
diff
changeset
|
120 |
| NONE => |
586af36cf3cc
uniform decoding of fixed/const syntax entities, allows to pass "\<^fixed>foo__" through the syntax layer (supersedes 1b7109c10b7b);
wenzelm
parents:
36448
diff
changeset
|
121 |
let val c = |
586af36cf3cc
uniform decoding of fixed/const syntax entities, allows to pass "\<^fixed>foo__" through the syntax layer (supersedes 1b7109c10b7b);
wenzelm
parents:
36448
diff
changeset
|
122 |
(case try Lexicon.unmark_const a of |
586af36cf3cc
uniform decoding of fixed/const syntax entities, allows to pass "\<^fixed>foo__" through the syntax layer (supersedes 1b7109c10b7b);
wenzelm
parents:
36448
diff
changeset
|
123 |
SOME c => c |
586af36cf3cc
uniform decoding of fixed/const syntax entities, allows to pass "\<^fixed>foo__" through the syntax layer (supersedes 1b7109c10b7b);
wenzelm
parents:
36448
diff
changeset
|
124 |
| NONE => snd (map_const a)) |
586af36cf3cc
uniform decoding of fixed/const syntax entities, allows to pass "\<^fixed>foo__" through the syntax layer (supersedes 1b7109c10b7b);
wenzelm
parents:
36448
diff
changeset
|
125 |
in Const (c, T) end) |
22704 | 126 |
| decode (Free (a, T)) = |
127 |
(case (map_free a, map_const a) of |
|
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
128 |
(SOME x, _) => Free (x, T) |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
129 |
| (_, (true, c)) => Const (c, T) |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
130 |
| (_, (false, c)) => (if Long_Name.is_qualified c then Const else Free) (c, T)) |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
131 |
| decode (Var (xi, T)) = Var (xi, T) |
22704 | 132 |
| decode (t as Bound _) = t; |
133 |
in decode tm end; |
|
134 |
||
135 |
||
0 | 136 |
|
2584 | 137 |
(** output utils **) |
138 |
||
2699 | 139 |
(* term_of_sort *) |
2584 | 140 |
|
141 |
fun term_of_sort S = |
|
142 |
let |
|
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
143 |
val class = Lexicon.const o Lexicon.mark_class; |
2584 | 144 |
|
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
145 |
fun classes [c] = class c |
5690 | 146 |
| classes (c :: cs) = Lexicon.const "_classes" $ class c $ classes cs; |
2584 | 147 |
in |
148 |
(case S of |
|
5690 | 149 |
[] => Lexicon.const "_topsort" |
2584 | 150 |
| [c] => class c |
5690 | 151 |
| cs => Lexicon.const "_sort" $ classes cs) |
2584 | 152 |
end; |
153 |
||
154 |
||
155 |
(* term_of_typ *) |
|
0 | 156 |
|
157 |
fun term_of_typ show_sorts ty = |
|
158 |
let |
|
2584 | 159 |
fun of_sort t S = |
5690 | 160 |
if show_sorts then Lexicon.const "_ofsort" $ t $ term_of_sort S |
2584 | 161 |
else t; |
0 | 162 |
|
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
163 |
fun term_of (Type (a, Ts)) = |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
164 |
Term.list_comb (Lexicon.const (Lexicon.mark_type a), map term_of Ts) |
5690 | 165 |
| term_of (TFree (x, S)) = of_sort (Lexicon.const "_tfree" $ Lexicon.free x) S |
166 |
| term_of (TVar (xi, S)) = of_sort (Lexicon.const "_tvar" $ Lexicon.var xi) S; |
|
8895 | 167 |
in term_of ty end; |
0 | 168 |
|
169 |
||
170 |
||
171 |
(** the type syntax **) |
|
172 |
||
10572 | 173 |
(* print mode *) |
174 |
||
175 |
val bracketsN = "brackets"; |
|
176 |
val no_bracketsN = "no_brackets"; |
|
177 |
||
178 |
fun no_brackets () = |
|
24613 | 179 |
find_first (fn mode => mode = bracketsN orelse mode = no_bracketsN) |
180 |
(print_mode_value ()) = SOME no_bracketsN; |
|
11312 | 181 |
|
182 |
val type_bracketsN = "type_brackets"; |
|
183 |
val no_type_bracketsN = "no_type_brackets"; |
|
184 |
||
185 |
fun no_type_brackets () = |
|
24613 | 186 |
find_first (fn mode => mode = type_bracketsN orelse mode = no_type_bracketsN) |
187 |
(print_mode_value ()) <> SOME type_bracketsN; |
|
10572 | 188 |
|
189 |
||
18 | 190 |
(* parse ast translations *) |
0 | 191 |
|
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
192 |
val class_ast = Ast.Constant o Lexicon.mark_class; |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
193 |
val type_ast = Ast.Constant o Lexicon.mark_type; |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
194 |
|
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
195 |
fun class_name_tr read_class (*"_class_name"*) [Ast.Variable c] = class_ast (read_class c) |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
196 |
| class_name_tr _ (*"_class_name"*) asts = raise Ast.AST ("class_name_tr", asts); |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
197 |
|
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
198 |
fun classes_tr read_class (*"_classes"*) [Ast.Variable c, ast] = |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
199 |
Ast.mk_appl (Ast.Constant "_classes") [class_ast (read_class c), ast] |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
200 |
| classes_tr _ (*"_classes"*) asts = raise Ast.AST ("classes_tr", asts); |
347
cd41a57221d0
changed translation of type applications according to new grammar;
wenzelm
parents:
330
diff
changeset
|
201 |
|
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
202 |
fun type_name_tr read_type (*"_type_name"*) [Ast.Variable c] = type_ast (read_type c) |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
203 |
| type_name_tr _ (*"_type_name"*) asts = raise Ast.AST ("type_name_tr", asts); |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
204 |
|
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
205 |
fun tapp_ast_tr read_type (*"_tapp"*) [ty, Ast.Variable c] = |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
206 |
Ast.Appl [type_ast (read_type c), ty] |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
207 |
| tapp_ast_tr _ (*"_tapp"*) asts = raise Ast.AST ("tapp_ast_tr", asts); |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
208 |
|
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
209 |
fun tappl_ast_tr read_type (*"_tappl"*) [ty, tys, Ast.Variable c] = |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
210 |
Ast.Appl (type_ast (read_type c) :: ty :: Ast.unfold_ast "_types" tys) |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
211 |
| tappl_ast_tr _ (*"_tappl"*) asts = raise Ast.AST ("tappl_ast_tr", asts); |
0 | 212 |
|
213 |
fun bracket_ast_tr (*"_bracket"*) [dom, cod] = |
|
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
214 |
Ast.fold_ast_p "\\<^type>fun" (Ast.unfold_ast "_types" dom, cod) |
5690 | 215 |
| bracket_ast_tr (*"_bracket"*) asts = raise Ast.AST ("bracket_ast_tr", asts); |
0 | 216 |
|
217 |
||
18 | 218 |
(* print ast translations *) |
0 | 219 |
|
5690 | 220 |
fun tappl_ast_tr' (f, []) = raise Ast.AST ("tappl_ast_tr'", [f]) |
221 |
| tappl_ast_tr' (f, [ty]) = Ast.Appl [Ast.Constant "_tapp", ty, f] |
|
347
cd41a57221d0
changed translation of type applications according to new grammar;
wenzelm
parents:
330
diff
changeset
|
222 |
| tappl_ast_tr' (f, ty :: tys) = |
5690 | 223 |
Ast.Appl [Ast.Constant "_tappl", ty, Ast.fold_ast "_types" tys, f]; |
0 | 224 |
|
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
225 |
fun fun_ast_tr' (*"\\<^type>fun"*) asts = |
16614 | 226 |
if no_brackets () orelse no_type_brackets () then raise Match |
10572 | 227 |
else |
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
228 |
(case Ast.unfold_ast_p "\\<^type>fun" (Ast.Appl (Ast.Constant "\\<^type>fun" :: asts)) of |
10572 | 229 |
(dom as _ :: _ :: _, cod) |
230 |
=> Ast.Appl [Ast.Constant "_bracket", Ast.fold_ast "_types" dom, cod] |
|
231 |
| _ => raise Match); |
|
0 | 232 |
|
233 |
||
234 |
(* type_ext *) |
|
235 |
||
236 |
val sortT = Type ("sort", []); |
|
237 |
val classesT = Type ("classes", []); |
|
238 |
val typesT = Type ("types", []); |
|
239 |
||
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
36502
diff
changeset
|
240 |
local open Lexicon Syn_Ext in |
5690 | 241 |
|
35668 | 242 |
val type_ext = syn_ext' false (K false) |
347
cd41a57221d0
changed translation of type applications according to new grammar;
wenzelm
parents:
330
diff
changeset
|
243 |
[Mfix ("_", tidT --> typeT, "", [], max_pri), |
239 | 244 |
Mfix ("_", tvarT --> typeT, "", [], max_pri), |
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
245 |
Mfix ("_", idT --> typeT, "_type_name", [], max_pri), |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
246 |
Mfix ("_", longidT --> typeT, "_type_name", [], max_pri), |
330
2fda15dd1e0f
changed the way a grammar is generated to allow the new parser to work;
clasohm
parents:
258
diff
changeset
|
247 |
Mfix ("_::_", [tidT, sortT] ---> typeT, "_ofsort", [max_pri, 0], max_pri), |
239 | 248 |
Mfix ("_::_", [tvarT, sortT] ---> typeT, "_ofsort", [max_pri, 0], max_pri), |
14838 | 249 |
Mfix ("'_()::_", sortT --> typeT, "_dummy_ofsort", [0], max_pri), |
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
250 |
Mfix ("_", idT --> sortT, "_class_name", [], max_pri), |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
251 |
Mfix ("_", longidT --> sortT, "_class_name", [], max_pri), |
2584 | 252 |
Mfix ("{}", sortT, "_topsort", [], max_pri), |
239 | 253 |
Mfix ("{_}", classesT --> sortT, "_sort", [], max_pri), |
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
254 |
Mfix ("_", idT --> classesT, "_class_name", [], max_pri), |
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
255 |
Mfix ("_", longidT --> classesT, "_class_name", [], max_pri), |
239 | 256 |
Mfix ("_,_", [idT, classesT] ---> classesT, "_classes", [], max_pri), |
3829 | 257 |
Mfix ("_,_", [longidT, classesT] ---> classesT, "_classes", [], max_pri), |
330
2fda15dd1e0f
changed the way a grammar is generated to allow the new parser to work;
clasohm
parents:
258
diff
changeset
|
258 |
Mfix ("_ _", [typeT, idT] ---> typeT, "_tapp", [max_pri, 0], max_pri), |
3829 | 259 |
Mfix ("_ _", [typeT, longidT] ---> typeT, "_tapp", [max_pri, 0], max_pri), |
9067 | 260 |
Mfix ("((1'(_,/ _')) _)", [typeT, typesT, idT] ---> typeT, "_tappl", [], max_pri), |
261 |
Mfix ("((1'(_,/ _')) _)", [typeT, typesT, longidT] ---> typeT, "_tappl", [], max_pri), |
|
239 | 262 |
Mfix ("_", typeT --> typesT, "", [], max_pri), |
263 |
Mfix ("_,/ _", [typeT, typesT] ---> typesT, "_types", [], max_pri), |
|
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
264 |
Mfix ("(_/ => _)", [typeT, typeT] ---> typeT, "\\<^type>fun", [1, 0], 0), |
624 | 265 |
Mfix ("([_]/ => _)", [typesT, typeT] ---> typeT, "_bracket", [0, 0], 0), |
2678 | 266 |
Mfix ("'(_')", typeT --> typeT, "", [0], max_pri), |
35429
afa8cf9e63d8
authentic syntax for classes and type constructors;
wenzelm
parents:
35262
diff
changeset
|
267 |
Mfix ("'_", typeT, "\\<^type>dummy", [], max_pri)] |
35433
73cc288b4f83
"_type_prop" is syntax const -- recovered printing of OFCLASS;
wenzelm
parents:
35429
diff
changeset
|
268 |
["_type_prop"] |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
36502
diff
changeset
|
269 |
([], [], [], map Syn_Ext.mk_trfun [("\\<^type>fun", K fun_ast_tr')]) |
26708
fc2e7d2f763d
moved default token translations to proof_context.ML, if all fails the pretty printer falls back on plain output;
wenzelm
parents:
26039
diff
changeset
|
270 |
[] |
239 | 271 |
([], []); |
0 | 272 |
|
35668 | 273 |
fun type_ast_trs {read_class, read_type} = |
274 |
[("_class_name", class_name_tr o read_class), |
|
275 |
("_classes", classes_tr o read_class), |
|
276 |
("_type_name", type_name_tr o read_type), |
|
277 |
("_tapp", tapp_ast_tr o read_type), |
|
278 |
("_tappl", tappl_ast_tr o read_type), |
|
279 |
("_bracket", K bracket_ast_tr)]; |
|
280 |
||
0 | 281 |
end; |
5690 | 282 |
|
283 |
end; |