equal
deleted
inserted
replaced
185 |
185 |
186 fun ast_of_position tok = |
186 fun ast_of_position tok = |
187 Ast.Variable (Term_Position.encode (report_pos tok)); |
187 Ast.Variable (Term_Position.encode (report_pos tok)); |
188 |
188 |
189 fun ast_of_dummy a tok = |
189 fun ast_of_dummy a tok = |
190 Ast.Appl [Ast.Constant "_constrain", Ast.Constant a, ast_of_position tok]; |
190 Ast.constrain (Ast.Constant a) (ast_of_position tok); |
191 |
191 |
192 fun asts_of_position c tok = |
192 fun asts_of_position c tok = |
193 [Ast.Appl [Ast.Constant c, ast_of (Parser.Tip tok), ast_of_position tok]] |
193 [Ast.Appl [Ast.Constant c, ast_of (Parser.Tip tok), ast_of_position tok]] |
194 |
194 |
195 and asts_of (Parser.Markup ({markup, range = (pos, _), ...}, pts)) = |
195 and asts_of (Parser.Markup ({markup, range = (pos, _), ...}, pts)) = |
680 val clean_var_types = show_markup andalso not show_types; |
680 val clean_var_types = show_markup andalso not show_types; |
681 |
681 |
682 fun constrain clean T ast = |
682 fun constrain clean T ast = |
683 let val U = Type_Annotation.print clean T in |
683 let val U = Type_Annotation.print clean T in |
684 if U = dummyT then ast |
684 if U = dummyT then ast |
685 else Ast.Appl [Ast.Constant "_constrain", ast, ast_of_termT ctxt trf (term_of_typ ctxt U)] |
685 else Ast.constrain ast (ast_of_termT ctxt trf (term_of_typ ctxt U)) |
686 end; |
686 end; |
687 |
687 |
688 fun main tm = |
688 fun main tm = |
689 (case strip_comb tm of |
689 (case strip_comb tm of |
690 (t as Abs _, ts) => Ast.mk_appl (main (Syntax_Trans.abs_tr' ctxt t)) (map main ts) |
690 (t as Abs _, ts) => Ast.mk_appl (main (Syntax_Trans.abs_tr' ctxt t)) (map main ts) |
879 [Ast.Appl [Ast.Constant "_constrain", Ast.Variable c, T as Ast.Variable p]] => |
879 [Ast.Appl [Ast.Constant "_constrain", Ast.Variable c, T as Ast.Variable p]] => |
880 let |
880 let |
881 val pos = the_default Position.none (Term_Position.decode p); |
881 val pos = the_default Position.none (Term_Position.decode p); |
882 val (c', _) = decode_const ctxt (c, [pos]); |
882 val (c', _) = decode_const ctxt (c, [pos]); |
883 val d = if intern then Lexicon.mark_const c' else c; |
883 val d = if intern then Lexicon.mark_const c' else c; |
884 in Ast.Appl [Ast.Constant "_constrain", Ast.Constant d, T] end |
884 in Ast.constrain (Ast.Constant d) T end |
885 | _ => raise Ast.AST ("const_ast_tr", asts)); |
885 | _ => raise Ast.AST ("const_ast_tr", asts)); |
886 |
886 |
887 |
887 |
888 (* setup translations *) |
888 (* setup translations *) |
889 |
889 |