10 sig |
10 sig |
11 val sort_of_term: term -> sort |
11 val sort_of_term: term -> sort |
12 val raw_term_sorts: term -> (indexname * sort) list |
12 val raw_term_sorts: term -> (indexname * sort) list |
13 val typ_of_term: (indexname -> sort) -> term -> typ |
13 val typ_of_term: (indexname -> sort) -> term -> typ |
14 val term_of_typ: bool -> typ -> term |
14 val term_of_typ: bool -> typ -> term |
|
15 val no_brackets: unit -> bool |
15 end; |
16 end; |
16 |
17 |
17 signature TYPE_EXT = |
18 signature TYPE_EXT = |
18 sig |
19 sig |
19 include TYPE_EXT0 |
20 include TYPE_EXT0 |
120 |
121 |
121 |
122 |
122 |
123 |
123 (** the type syntax **) |
124 (** the type syntax **) |
124 |
125 |
|
126 (* print mode *) |
|
127 |
|
128 val bracketsN = "brackets"; |
|
129 val no_bracketsN = "no_brackets"; |
|
130 |
|
131 fun no_brackets () = |
|
132 Library.find_first (equal bracketsN orf equal no_bracketsN) (! print_mode) = Some no_bracketsN; |
|
133 |
|
134 |
125 (* parse ast translations *) |
135 (* parse ast translations *) |
126 |
136 |
127 fun tapp_ast_tr (*"_tapp"*) [ty, f] = Ast.Appl [f, ty] |
137 fun tapp_ast_tr (*"_tapp"*) [ty, f] = Ast.Appl [f, ty] |
128 | tapp_ast_tr (*"_tapp"*) asts = raise Ast.AST ("tapp_ast_tr", asts); |
138 | tapp_ast_tr (*"_tapp"*) asts = raise Ast.AST ("tapp_ast_tr", asts); |
129 |
139 |
142 | tappl_ast_tr' (f, [ty]) = Ast.Appl [Ast.Constant "_tapp", ty, f] |
152 | tappl_ast_tr' (f, [ty]) = Ast.Appl [Ast.Constant "_tapp", ty, f] |
143 | tappl_ast_tr' (f, ty :: tys) = |
153 | tappl_ast_tr' (f, ty :: tys) = |
144 Ast.Appl [Ast.Constant "_tappl", ty, Ast.fold_ast "_types" tys, f]; |
154 Ast.Appl [Ast.Constant "_tappl", ty, Ast.fold_ast "_types" tys, f]; |
145 |
155 |
146 fun fun_ast_tr' (*"fun"*) asts = |
156 fun fun_ast_tr' (*"fun"*) asts = |
147 (case Ast.unfold_ast_p "fun" (Ast.Appl (Ast.Constant "fun" :: asts)) of |
157 if no_brackets () then raise Match |
148 (dom as _ :: _ :: _, cod) |
158 else |
149 => Ast.Appl [Ast.Constant "_bracket", Ast.fold_ast "_types" dom, cod] |
159 (case Ast.unfold_ast_p "fun" (Ast.Appl (Ast.Constant "fun" :: asts)) of |
150 | _ => raise Match); |
160 (dom as _ :: _ :: _, cod) |
|
161 => Ast.Appl [Ast.Constant "_bracket", Ast.fold_ast "_types" dom, cod] |
|
162 | _ => raise Match); |
151 |
163 |
152 |
164 |
153 (* type_ext *) |
165 (* type_ext *) |
154 |
166 |
155 val sortT = Type ("sort", []); |
167 val sortT = Type ("sort", []); |