54 local |
54 local |
55 |
55 |
56 val parse_const_terms = Scan.repeat1 Args.term |
56 val parse_const_terms = Scan.repeat1 Args.term |
57 >> (fn ts => fn thy => map (Code_Unit.check_const thy) ts); |
57 >> (fn ts => fn thy => map (Code_Unit.check_const thy) ts); |
58 val parse_consts = Scan.lift (Args.parens (Args.$$$ "consts")) |-- parse_const_terms |
58 val parse_consts = Scan.lift (Args.parens (Args.$$$ "consts")) |-- parse_const_terms |
59 >> (fn mk_cs => fn thy => map (Code_Name.const thy) (mk_cs thy)); |
59 >> (fn mk_cs => fn thy => fn naming => map (the o Code_Thingol.lookup_const naming) (mk_cs thy)); |
60 val parse_types = Scan.lift (Args.parens (Args.$$$ "types") |-- Scan.repeat1 Args.name) |
60 val parse_types = Scan.lift (Args.parens (Args.$$$ "types") |-- Scan.repeat1 Args.name) |
61 >> (fn tycos => fn thy => map (Code_Name.tyco thy o Sign.intern_type thy) tycos); |
61 >> (fn tycos => fn thy => fn naming => map (the o Code_Thingol.lookup_tyco naming o Sign.intern_type thy) tycos); |
62 val parse_classes = Scan.lift (Args.parens (Args.$$$ "classes") |-- Scan.repeat1 Args.name) |
62 val parse_classes = Scan.lift (Args.parens (Args.$$$ "classes") |-- Scan.repeat1 Args.name) |
63 >> (fn classes => fn thy => map (Code_Name.class thy o Sign.intern_class thy) classes); |
63 >> (fn classes => fn thy => fn naming => map (the o Code_Thingol.lookup_class naming o Sign.intern_class thy) classes); |
64 val parse_instances = Scan.lift (Args.parens (Args.$$$ "instances") |-- Scan.repeat1 (Args.name --| Args.$$$ "::" -- Args.name)) |
64 val parse_instances = Scan.lift (Args.parens (Args.$$$ "instances") |-- Scan.repeat1 (Args.name --| Args.$$$ "::" -- Args.name)) |
65 >> (fn insts => fn thy => map (Code_Name.instance thy o apsnd (Sign.intern_type thy) o apfst (Sign.intern_class thy) o swap) insts); |
65 >> (fn insts => fn thy => fn naming => map (the o Code_Thingol.lookup_instance naming o apsnd (Sign.intern_type thy) o apfst (Sign.intern_class thy) o swap) insts); |
66 val parse_names = parse_consts || parse_types || parse_classes || parse_instances; |
66 val parse_names = parse_consts || parse_types || parse_classes || parse_instances; |
67 |
67 |
68 fun code_stmts src ctxt ((mk_cs, mk_stmtss), target) = |
68 fun code_stmts src ctxt ((mk_cs, mk_stmtss), target) = |
69 Code_Target.code_of (ProofContext.theory_of ctxt) |
69 Code_Target.code_of (ProofContext.theory_of ctxt) |
70 target "Example" (mk_cs (ProofContext.theory_of ctxt)) |
70 target "Example" (mk_cs (ProofContext.theory_of ctxt)) |
71 (maps (fn f => f (ProofContext.theory_of ctxt)) mk_stmtss) |
71 (fn naming => maps (fn f => f (ProofContext.theory_of ctxt) naming) mk_stmtss) |
72 |> split_lines |
72 |> split_lines |
73 |> verbatim_lines; |
73 |> verbatim_lines; |
74 |
74 |
75 in |
75 in |
76 |
76 |