src/HOL/Tools/BNF/bnf_fp_util.ML
changeset 71245 e5664a75f4b5
parent 70494 41108e3e9ca5
child 71246 30db0523f9b0
equal deleted inserted replaced
71242:ec5090faf541 71245:e5664a75f4b5
   211       (binding list -> (string * sort) list -> typ list * typ list list -> BNF_Def.bnf list ->
   211       (binding list -> (string * sort) list -> typ list * typ list list -> BNF_Def.bnf list ->
   212       BNF_Comp.absT_info list -> local_theory -> 'a) ->
   212       BNF_Comp.absT_info list -> local_theory -> 'a) ->
   213     binding list -> (string * sort) list -> (string * sort) list -> (string * sort) list ->
   213     binding list -> (string * sort) list -> (string * sort) list -> (string * sort) list ->
   214     typ list -> BNF_Comp.comp_cache -> local_theory ->
   214     typ list -> BNF_Comp.comp_cache -> local_theory ->
   215     ((BNF_Def.bnf list * BNF_Comp.absT_info list) * BNF_Comp.comp_cache) * 'a
   215     ((BNF_Def.bnf list * BNF_Comp.absT_info list) * BNF_Comp.comp_cache) * 'a
   216   val fp_antiquote_setup: binding -> theory -> theory
       
   217 end;
   216 end;
   218 
   217 
   219 structure BNF_FP_Util : BNF_FP_UTIL =
   218 structure BNF_FP_Util : BNF_FP_UTIL =
   220 struct
   219 struct
   221 
   220 
   980     val timer = time (timer "FP construction in total");
   979     val timer = time (timer "FP construction in total");
   981   in
   980   in
   982     (((pre_bnfs, absT_infos), comp_cache'), res)
   981     (((pre_bnfs, absT_infos), comp_cache'), res)
   983   end;
   982   end;
   984 
   983 
   985 fun fp_antiquote_setup binding =
   984 
       
   985 (** document antiquotations **)
       
   986 
       
   987 local
       
   988 
       
   989 fun antiquote_setup binding =
   986   Thy_Output.antiquotation_pretty_source_embedded binding
   990   Thy_Output.antiquotation_pretty_source_embedded binding
   987     (Args.type_name {proper = true, strict = true})
   991     (Args.type_name {proper = true, strict = true})
   988     (fn ctxt => fn fcT_name =>
   992     (fn ctxt => fn fcT_name =>
   989        (case Ctr_Sugar.ctr_sugar_of ctxt fcT_name of
   993        (case Ctr_Sugar.ctr_sugar_of ctxt fcT_name of
   990          NONE => error ("Not a known freely generated type name: " ^ quote fcT_name)
   994          NONE => error ("Not a known freely generated type name: " ^ quote fcT_name)
  1003            Pretty.block (Pretty.keyword1 (Binding.name_of binding) :: Pretty.brk 1 ::
  1007            Pretty.block (Pretty.keyword1 (Binding.name_of binding) :: Pretty.brk 1 ::
  1004              Syntax.pretty_typ ctxt T :: Pretty.str " =" :: Pretty.brk 1 ::
  1008              Syntax.pretty_typ ctxt T :: Pretty.str " =" :: Pretty.brk 1 ::
  1005              flat (separate [Pretty.brk 1, Pretty.str "| "] (map (single o pretty_ctr) ctrs)))
  1009              flat (separate [Pretty.brk 1, Pretty.str "| "] (map (single o pretty_ctr) ctrs)))
  1006          end));
  1010          end));
  1007 
  1011 
       
  1012 in
       
  1013 
       
  1014 val _ =
       
  1015   Theory.setup
       
  1016    (antiquote_setup \<^binding>\<open>datatype\<close> #>
       
  1017     antiquote_setup \<^binding>\<open>codatatype\<close>);
       
  1018 
  1008 end;
  1019 end;
       
  1020 
       
  1021 end;