src/HOL/Tools/case_translation.ML
changeset 52143 36ffe23b25f8
parent 51751 cf039b3c42a7
child 52154 b707a26d8fe0
equal deleted inserted replaced
52142:348aed032cda 52143:36ffe23b25f8
   146           (dest_case2 u)
   146           (dest_case2 u)
   147           (Syntax.const @{const_syntax case_nil}))
   147           (Syntax.const @{const_syntax case_nil}))
   148       end
   148       end
   149   | case_tr _ _ _ = case_error "case_tr";
   149   | case_tr _ _ _ = case_error "case_tr";
   150 
   150 
   151 val trfun_setup =
   151 val trfun_setup = Sign.parse_translation [(@{syntax_const "_case_syntax"}, case_tr true)];
   152   Sign.add_advanced_trfuns ([],
       
   153     [(@{syntax_const "_case_syntax"}, case_tr true)],
       
   154     [], []);
       
   155 
   152 
   156 
   153 
   157 (* print translation *)
   154 (* print translation *)
   158 
   155 
   159 fun case_tr' (_ :: x :: t :: ts) =
   156 fun case_tr' (_ :: x :: t :: ts) =
   174         list_comb (Syntax.const @{syntax_const "_case_syntax"} $ x $
   171         list_comb (Syntax.const @{syntax_const "_case_syntax"} $ x $
   175           foldr1 (fn (t, u) => Syntax.const @{syntax_const "_case2"} $ t $ u)
   172           foldr1 (fn (t, u) => Syntax.const @{syntax_const "_case2"} $ t $ u)
   176             (mk_clauses t), ts)
   173             (mk_clauses t), ts)
   177       end;
   174       end;
   178 
   175 
   179 val trfun_setup' = Sign.add_trfuns
   176 val trfun_setup' = Sign.print_translation [(@{const_syntax "case_guard"}, K case_tr')];
   180   ([], [], [(@{const_syntax "case_guard"}, case_tr')], []);
       
   181 
   177 
   182 
   178 
   183 (* declarations *)
   179 (* declarations *)
   184 
   180 
   185 fun register raw_case_comb raw_constrs context =
   181 fun register raw_case_comb raw_constrs context =