109 | mark_freevars (t as Var (xi, T)) = |
109 | mark_freevars (t as Var (xi, T)) = |
110 if xi = SynExt.dddot_indexname then Const ("_DDDOT", T) |
110 if xi = SynExt.dddot_indexname then Const ("_DDDOT", T) |
111 else Lexicon.const "_var" $ t |
111 else Lexicon.const "_var" $ t |
112 | mark_freevars a = a; |
112 | mark_freevars a = a; |
113 |
113 |
114 fun ast_of_term trf show_const_types no_freeTs show_types show_sorts tm = |
114 fun ast_of_term trf show_all_types no_freeTs show_types show_sorts tm = |
115 let |
115 let |
116 fun prune_typs (t_seen as (Const _, _)) = t_seen |
116 fun prune_typs (t_seen as (Const _, _)) = t_seen |
117 | prune_typs (t as Free (x, ty), seen) = |
117 | prune_typs (t as Free (x, ty), seen) = |
118 if ty = dummyT then (t, seen) |
118 if ty = dummyT then (t, seen) |
119 else if no_freeTs orelse t mem seen then (Lexicon.free x, seen) |
119 else if no_freeTs orelse t mem seen then (Lexicon.free x, seen) |
140 | ((c as Const ("_bound", _)), Free (x, T) :: ts) => |
140 | ((c as Const ("_bound", _)), Free (x, T) :: ts) => |
141 Ast.mk_appl (constrain (c $ Lexicon.free x) T) (map ast_of ts) |
141 Ast.mk_appl (constrain (c $ Lexicon.free x) T) (map ast_of ts) |
142 | ((c as Const ("_var", _)), Var (xi, T) :: ts) => |
142 | ((c as Const ("_var", _)), Var (xi, T) :: ts) => |
143 Ast.mk_appl (constrain (c $ Lexicon.var xi) T) (map ast_of ts) |
143 Ast.mk_appl (constrain (c $ Lexicon.var xi) T) (map ast_of ts) |
144 | (c' as Const (c, T), ts) => |
144 | (c' as Const (c, T), ts) => |
145 if show_const_types |
145 if show_all_types |
146 then Ast.mk_appl (constrain c' T) (map ast_of ts) |
146 then Ast.mk_appl (constrain c' T) (map ast_of ts) |
147 else trans c T ts |
147 else trans c T ts |
148 | (t, ts) => Ast.mk_appl (simple_ast_of t) (map ast_of ts)) |
148 | (t, ts) => Ast.mk_appl (simple_ast_of t) (map ast_of ts)) |
149 |
149 |
150 and trans a T args = |
150 and trans a T args = |
151 ast_of (apply_trans "print translation" a (apply_typed show_sorts T (trf a)) args) |
151 ast_of (apply_trans "print translation" a (apply_typed show_sorts T (trf a)) args) |
152 handle Match => Ast.mk_appl (Ast.Constant a) (map ast_of args) |
152 handle Match => Ast.mk_appl (Ast.Constant a) (map ast_of args) |
329 astT (appT (splitT n ([c], args)), p) |
329 astT (appT (splitT n ([c], args)), p) |
330 else prnt (prnps, tbs); |
330 else prnt (prnps, tbs); |
331 in |
331 in |
332 (case token_trans a args of (*try token translation function*) |
332 (case token_trans a args of (*try token translation function*) |
333 Some s_len => [Pretty.raw_str s_len] |
333 Some s_len => [Pretty.raw_str s_len] |
334 | None => (*try print translation functions*) |
334 | None => (*try print translation functions*) |
335 astT (trans a (trf a) args, p) handle Match => prnt ([], tabs)) |
335 astT (trans a (trf a) args, p) handle Match => prnt ([], tabs)) |
336 end |
336 end |
337 |
337 |
338 and astT (c as Ast.Constant a, p) = combT (c, a, [], p) |
338 and astT (c as Ast.Constant a, p) = combT (c, a, [], p) |
339 | astT (Ast.Variable x, _) = [Pretty.str x] |
339 | astT (Ast.Variable x, _) = [Pretty.str x] |