doc-src/IsarAdvanced/Codegen/Thy/Setup.thy
changeset 28440 0b9ddfa6458e
parent 28428 fd007794561f
child 28447 df77ed974a78
     1.1 --- a/doc-src/IsarAdvanced/Codegen/Thy/Setup.thy	Wed Oct 01 00:09:51 2008 +0200
     1.2 +++ b/doc-src/IsarAdvanced/Codegen/Thy/Setup.thy	Wed Oct 01 08:42:42 2008 +0200
     1.3 @@ -1,61 +1,10 @@
     1.4  theory Setup
     1.5  imports Complex_Main
     1.6 -uses "../../../antiquote_setup.ML"
     1.7 +uses "../../../antiquote_setup.ML" "../../../more_antiquote.ML"
     1.8  begin
     1.9  
    1.10  ML {* no_document use_thys ["Efficient_Nat", "Code_Char_chr"] *}
    1.11  
    1.12  ML_val {* Code_Target.code_width := 74 *}
    1.13  
    1.14 -ML {*
    1.15 -fun pr_class ctxt = enclose "\\isa{" "}" o Sign.extern_class (ProofContext.theory_of ctxt)
    1.16 -  o Sign.read_class (ProofContext.theory_of ctxt);
    1.17 -*}
    1.18 -
    1.19 -ML {*
    1.20 -val _ = ThyOutput.add_commands
    1.21 -  [("class", ThyOutput.args (Scan.lift Args.name) (K pr_class))]
    1.22 -*}
    1.23 -
    1.24 -ML {*
    1.25 -val verbatim_line = space_implode "\\verb,|," o map (enclose "\\verb|" "|") o space_explode "|";
    1.26 -val verbatim_lines = rev
    1.27 -  #> dropwhile (fn s => s = "")
    1.28 -  #> rev
    1.29 -  #> map verbatim_line #> space_implode "\\newline%\n"
    1.30 -  #> prefix "\\isaverbatim%\n\\noindent%\n"
    1.31 -*}
    1.32 -
    1.33 -ML {*
    1.34 -local
    1.35 -
    1.36 -  val parse_const_terms = Scan.repeat1 Args.term
    1.37 -    >> (fn ts => fn thy => map (Code_Unit.check_const thy) ts);
    1.38 -  val parse_consts = Scan.lift (Args.parens (Args.$$$ "consts")) |-- parse_const_terms
    1.39 -    >> (fn mk_cs => fn thy => map (Code_Name.const thy) (mk_cs thy));
    1.40 -  val parse_types = Scan.lift (Args.parens (Args.$$$ "types") |-- Scan.repeat1 Args.name)
    1.41 -    >> (fn tycos => fn thy => map (Code_Name.tyco thy o Sign.intern_type thy) tycos);
    1.42 -  val parse_classes = Scan.lift (Args.parens (Args.$$$ "classes") |-- Scan.repeat1 Args.name)
    1.43 -    >> (fn classes => fn thy => map (Code_Name.class thy o Sign.intern_class thy) classes);
    1.44 -  val parse_instances = Scan.lift (Args.parens (Args.$$$ "instances") |-- Scan.repeat1 (Args.name --| Args.$$$ "::" -- Args.name))
    1.45 -    >> (fn insts => fn thy => map (Code_Name.instance thy o apsnd (Sign.intern_type thy) o apfst (Sign.intern_class thy) o swap) insts);
    1.46 -  val parse_names = parse_consts || parse_types || parse_classes || parse_instances; 
    1.47 -
    1.48 -  fun code_stmts src ctxt ((mk_cs, mk_stmtss), target) =
    1.49 -    Code_Target.code_of (ProofContext.theory_of ctxt)
    1.50 -      target "Example" (mk_cs (ProofContext.theory_of ctxt))
    1.51 -        (maps (fn f => f (ProofContext.theory_of ctxt)) mk_stmtss)
    1.52 -    |> split_lines
    1.53 -    |> verbatim_lines;
    1.54 -
    1.55 -in
    1.56 -
    1.57 -val _ = ThyOutput.add_commands
    1.58 -  [("code_stmts", ThyOutput.args
    1.59 -      (parse_const_terms -- Scan.repeat parse_names -- Scan.lift (Args.parens Args.name))
    1.60 -        code_stmts)]
    1.61 -
    1.62  end
    1.63 -*}
    1.64 -
    1.65 -end