author | Norbert Schirmer <norbert.schirmer@web.de> |
Tue, 14 May 2019 11:10:53 +0200 | |
changeset 562 | daf404920ab9 |
parent 557 | 77ea2de0ca62 |
child 564 | 6e2479089226 |
permissions | -rw-r--r-- |
106
bdd82350cf22
renamed in the pdf all instances of cookbook to tutorial (in order to sound more serious)
Christian Urban <urbanc@in.tum.de>
parents:
103
diff
changeset
|
1 |
(* Auxiliary antiquotations for the tutorial. *) |
45
78aeca00bb54
deleted old antiquote_setup and renamed antiquote_setup_plus to antiquuote_setup
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
2 |
|
256
1fb8d62c88a0
added some first index-information
Christian Urban <urbanc@in.tum.de>
parents:
255
diff
changeset
|
3 |
structure AntiquoteSetup = |
45
78aeca00bb54
deleted old antiquote_setup and renamed antiquote_setup_plus to antiquuote_setup
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
4 |
struct |
78aeca00bb54
deleted old antiquote_setup and renamed antiquote_setup_plus to antiquuote_setup
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
5 |
|
256
1fb8d62c88a0
added some first index-information
Christian Urban <urbanc@in.tum.de>
parents:
255
diff
changeset
|
6 |
open OutputTutorial |
1fb8d62c88a0
added some first index-information
Christian Urban <urbanc@in.tum.de>
parents:
255
diff
changeset
|
7 |
|
112 | 8 |
(* functions for generating appropriate expressions *) |
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
9 |
fun translate_string f str = |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
10 |
implode (map f (Symbol.explode str)) |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
11 |
|
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
12 |
fun prefix_lines prfx txt = |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
13 |
map (fn s => prfx ^ s) (split_lines txt) |
45
78aeca00bb54
deleted old antiquote_setup and renamed antiquote_setup_plus to antiquuote_setup
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
14 |
|
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
15 |
fun ml_with_vars ys txt = |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
16 |
implode ["fn ", (case ys of [] => "_" | _ => enclose "(" ")" (commas ys)), " => (", txt, ")"] |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
17 |
|
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
18 |
fun ml_with_struct (NONE) txt = txt |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
19 |
| ml_with_struct (SOME st) txt = implode ["let open ", st, " in ", txt, " end"] |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
20 |
|
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
21 |
fun ml_val vs stru txt = |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
22 |
txt |> ml_with_struct stru |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
23 |
|> ml_with_vars vs |
45
78aeca00bb54
deleted old antiquote_setup and renamed antiquote_setup_plus to antiquuote_setup
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
24 |
|
112 | 25 |
fun ml_pat (lhs, pat) = |
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
26 |
implode ["val ", translate_string (fn "\<dots>" => "_" | s => s) pat, " = ", lhs] |
45
78aeca00bb54
deleted old antiquote_setup and renamed antiquote_setup_plus to antiquuote_setup
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
27 |
|
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
28 |
fun ml_struct txt = |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
29 |
implode ["functor DUMMY_FUNCTOR() = struct structure DUMMY = ", txt, " end"] |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
30 |
|
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
31 |
fun ml_type txt = |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
32 |
implode ["val _ = NONE : (", txt, ") option"]; |
45
78aeca00bb54
deleted old antiquote_setup and renamed antiquote_setup_plus to antiquuote_setup
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
33 |
|
112 | 34 |
(* eval function *) |
171
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
35 |
fun eval_fn ctxt exp = |
555
2c34c69236ce
updated to new isabelle
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
553
diff
changeset
|
36 |
ML_Context.eval_source_in (SOME ctxt) ML_Compiler.flags |
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
37 |
(Input.source false exp Position.no_range) |
57
065f472c09ab
Repaired output of marginal comments in ML antiquotation.
berghofe
parents:
54
diff
changeset
|
38 |
|
315
de49d5780f57
simplified a bit the index generation
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
39 |
(* checks and prints a possibly open expressions, no index *) |
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
40 |
fun output_ml ctxt (txt, (vs, stru)) = |
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
41 |
(eval_fn ctxt (ml_val vs stru txt); |
449 | 42 |
output ctxt (split_lines txt)) |
315
de49d5780f57
simplified a bit the index generation
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
43 |
|
de49d5780f57
simplified a bit the index generation
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
44 |
val parser_ml = Scan.lift (Args.name -- |
426 | 45 |
(Scan.optional (Args.$$$ "for" |-- Parse.!!! (Scan.repeat1 Args.name)) [] -- |
46 |
Scan.option (Args.$$$ "in" |-- Parse.!!! Args.name))) |
|
315
de49d5780f57
simplified a bit the index generation
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
47 |
|
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
48 |
(* checks and prints a single ML-item and produces an index entry *) |
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
49 |
fun output_ml_ind ctxt (txt, stru) = |
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
50 |
(eval_fn ctxt (ml_val [] stru txt); |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
51 |
case (stru, Long_Name.base_name txt, Long_Name.qualifier txt) of |
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
52 |
(NONE, _, "") => output_indexed ctxt {main = Code txt, minor = NoString} (split_lines txt) |
449 | 53 |
| (NONE, bn, qn) => output_indexed ctxt {main = Code bn, minor = Struct qn} (split_lines txt) |
54 |
| (SOME st, _, _) => output_indexed ctxt {main = Code txt, minor = Struct st} (split_lines txt)) |
|
112 | 55 |
|
315
de49d5780f57
simplified a bit the index generation
Christian Urban <urbanc@in.tum.de>
parents:
311
diff
changeset
|
56 |
val parser_ml_ind = Scan.lift (Args.name -- |
426 | 57 |
Scan.option (Args.$$$ "in" |-- Parse.!!! Args.name)) |
45
78aeca00bb54
deleted old antiquote_setup and renamed antiquote_setup_plus to antiquuote_setup
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
58 |
|
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
59 |
(* checks and prints structures *) |
449 | 60 |
fun gen_output_struct outfn ctxt txt = |
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
61 |
(eval_fn ctxt (ml_struct txt); |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
62 |
outfn {main = Code txt, minor = Plain "structure"} (split_lines txt)) |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
63 |
|
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
64 |
fun output_struct ctxt = gen_output_struct (K (output ctxt)) ctxt |
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
65 |
fun output_struct_ind ctxt = gen_output_struct (output_indexed ctxt) ctxt |
256
1fb8d62c88a0
added some first index-information
Christian Urban <urbanc@in.tum.de>
parents:
255
diff
changeset
|
66 |
|
328
c0cae24b9d46
updated to new Isabelle; more work on the data section
Christian Urban <urbanc@in.tum.de>
parents:
317
diff
changeset
|
67 |
(* prints functors; no checks *) |
449 | 68 |
fun gen_output_funct outfn txt = |
328
c0cae24b9d46
updated to new Isabelle; more work on the data section
Christian Urban <urbanc@in.tum.de>
parents:
317
diff
changeset
|
69 |
(outfn {main = Code txt, minor = Plain "functor"} (split_lines txt)) |
c0cae24b9d46
updated to new Isabelle; more work on the data section
Christian Urban <urbanc@in.tum.de>
parents:
317
diff
changeset
|
70 |
|
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
71 |
fun output_funct ctxt = gen_output_funct (K (output ctxt)) |
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
72 |
fun output_funct_ind ctxt = gen_output_funct (output_indexed ctxt) |
328
c0cae24b9d46
updated to new Isabelle; more work on the data section
Christian Urban <urbanc@in.tum.de>
parents:
317
diff
changeset
|
73 |
|
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
74 |
(* checks and prints types *) |
449 | 75 |
fun gen_output_type outfn ctxt txt = |
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
76 |
(eval_fn ctxt (ml_type txt); |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
77 |
outfn {main = Code txt, minor = Plain "type"} (split_lines txt)) |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
78 |
|
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
79 |
fun output_type ctxt = gen_output_type (K (output ctxt)) ctxt |
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
80 |
fun output_type_ind ctxt = gen_output_type (output_indexed ctxt) ctxt |
45
78aeca00bb54
deleted old antiquote_setup and renamed antiquote_setup_plus to antiquuote_setup
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
81 |
|
112 | 82 |
(* checks and expression agains a result pattern *) |
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
83 |
fun output_response ctxt (lhs, pat) = |
171
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
84 |
(eval_fn ctxt (ml_pat (lhs, pat)); |
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
85 |
(*eval_fn ctxt (ml_out lhs);*) (*FIXME remove*) |
449 | 86 |
output ctxt ((prefix_lines "" lhs) @ (prefix_lines "> " pat))) |
171
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
87 |
|
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
88 |
(* checks the expressions, but does not check it against a result pattern *) |
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
89 |
fun output_response_fake ctxt (lhs, pat) = |
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
90 |
(eval_fn ctxt (ml_val [] NONE lhs); |
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
91 |
(*eval_fn ctxt (ml_out lhs);*) (* FIXME remove *) |
449 | 92 |
output ctxt ((split_lines lhs) @ (prefix_lines "> " pat))) |
112 | 93 |
|
94 |
(* checks the expressions, but does not check it against a result pattern *) |
|
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
95 |
fun ouput_response_fake_both ctxt (lhs, pat) = |
557
77ea2de0ca62
updated for Isabelle 2014
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
555
diff
changeset
|
96 |
(output ctxt ((split_lines lhs) @ (prefix_lines "> " pat))) |
171
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
97 |
|
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
98 |
val single_arg = Scan.lift (Args.name) |
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
99 |
val two_args = Scan.lift (Args.name -- Args.name) |
317
d69214e47ef9
added an experimental antiquotation to replace eventually ML_response_fake
Christian Urban <urbanc@in.tum.de>
parents:
316
diff
changeset
|
100 |
val test = Scan.lift (Args.name -- Args.name -- Scan.option (Args.$$$ "with" |-- Args.name)) |
112 | 101 |
|
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
102 |
|
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
103 |
|
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
104 |
|
471 | 105 |
val ml_setup = |
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
106 |
Thy_Output.antiquotation_raw @{binding "ML"} parser_ml output_ml |
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
107 |
#> Thy_Output.antiquotation_raw @{binding "ML_ind"} parser_ml_ind output_ml_ind |
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
108 |
#> Thy_Output.antiquotation_raw @{binding "ML_type"} single_arg output_type |
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
109 |
#> Thy_Output.antiquotation_raw @{binding "ML_type_ind"} single_arg output_type_ind |
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
110 |
#> Thy_Output.antiquotation_raw @{binding "ML_struct"} single_arg output_struct |
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
111 |
#> Thy_Output.antiquotation_raw @{binding "ML_struct_ind"} single_arg output_struct_ind |
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
112 |
#> Thy_Output.antiquotation_raw @{binding "ML_funct"} single_arg output_funct |
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
113 |
#> Thy_Output.antiquotation_raw @{binding "ML_funct_ind"} single_arg output_funct_ind |
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
114 |
#> Thy_Output.antiquotation_raw @{binding "ML_response"} two_args output_response |
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
115 |
#> Thy_Output.antiquotation_raw @{binding "ML_response_fake"} two_args output_response_fake |
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
116 |
#> Thy_Output.antiquotation_raw @{binding "ML_response_fake_both"} two_args ouput_response_fake_both |
54
1783211b3494
tuned; added document antiquotation ML_response_fake_both
Christian Urban <urbanc@in.tum.de>
parents:
53
diff
changeset
|
117 |
|
317
d69214e47ef9
added an experimental antiquotation to replace eventually ML_response_fake
Christian Urban <urbanc@in.tum.de>
parents:
316
diff
changeset
|
118 |
(* FIXME: experimental *) |
d69214e47ef9
added an experimental antiquotation to replace eventually ML_response_fake
Christian Urban <urbanc@in.tum.de>
parents:
316
diff
changeset
|
119 |
fun ml_eq (lhs, pat, eq) = |
d69214e47ef9
added an experimental antiquotation to replace eventually ML_response_fake
Christian Urban <urbanc@in.tum.de>
parents:
316
diff
changeset
|
120 |
implode ["val true = ((", eq, ") (", lhs, ",", pat, "))"] |
d69214e47ef9
added an experimental antiquotation to replace eventually ML_response_fake
Christian Urban <urbanc@in.tum.de>
parents:
316
diff
changeset
|
121 |
|
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
122 |
fun output_response_eq ctxt ((lhs, pat), eq) = |
317
d69214e47ef9
added an experimental antiquotation to replace eventually ML_response_fake
Christian Urban <urbanc@in.tum.de>
parents:
316
diff
changeset
|
123 |
(case eq of |
d69214e47ef9
added an experimental antiquotation to replace eventually ML_response_fake
Christian Urban <urbanc@in.tum.de>
parents:
316
diff
changeset
|
124 |
NONE => eval_fn ctxt (ml_pat (lhs, pat)) |
d69214e47ef9
added an experimental antiquotation to replace eventually ML_response_fake
Christian Urban <urbanc@in.tum.de>
parents:
316
diff
changeset
|
125 |
| SOME e => eval_fn ctxt (ml_eq (lhs, pat, e)); |
449 | 126 |
output ctxt ((prefix_lines "" lhs) @ (prefix_lines "> " pat))) |
317
d69214e47ef9
added an experimental antiquotation to replace eventually ML_response_fake
Christian Urban <urbanc@in.tum.de>
parents:
316
diff
changeset
|
127 |
|
471 | 128 |
val ml_response_setup = |
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
129 |
Thy_Output.antiquotation_raw @{binding "ML_response_eq"} test output_response_eq |
317
d69214e47ef9
added an experimental antiquotation to replace eventually ML_response_fake
Christian Urban <urbanc@in.tum.de>
parents:
316
diff
changeset
|
130 |
|
d69214e47ef9
added an experimental antiquotation to replace eventually ML_response_fake
Christian Urban <urbanc@in.tum.de>
parents:
316
diff
changeset
|
131 |
(* checks whether a file exists in the Isabelle distribution *) |
182
4d0e2edd476d
added hyperlinks for every file pointer
Christian Urban <urbanc@in.tum.de>
parents:
171
diff
changeset
|
132 |
fun href_link txt = |
4d0e2edd476d
added hyperlinks for every file pointer
Christian Urban <urbanc@in.tum.de>
parents:
171
diff
changeset
|
133 |
let |
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
134 |
val raw = I (* FIXME: Symbol.encode_raw *) |
182
4d0e2edd476d
added hyperlinks for every file pointer
Christian Urban <urbanc@in.tum.de>
parents:
171
diff
changeset
|
135 |
val path = "http://isabelle.in.tum.de/repos/isabelle/raw-file/tip/src/" |
4d0e2edd476d
added hyperlinks for every file pointer
Christian Urban <urbanc@in.tum.de>
parents:
171
diff
changeset
|
136 |
in |
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
137 |
implode [raw "\\href{", raw path, raw txt, raw "}{", get_word txt, raw "}"] |
182
4d0e2edd476d
added hyperlinks for every file pointer
Christian Urban <urbanc@in.tum.de>
parents:
171
diff
changeset
|
138 |
end |
4d0e2edd476d
added hyperlinks for every file pointer
Christian Urban <urbanc@in.tum.de>
parents:
171
diff
changeset
|
139 |
|
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
140 |
fun check_file_exists _ txt = |
171
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
141 |
(if File.exists (Path.append (Path.explode ("~~/src")) (Path.explode txt)) |
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
142 |
then Latex.string (href_link txt) |
316
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
143 |
else error (implode ["Source file ", quote txt, " does not exist."])) |
74f0a06f751f
further polishing of index generation
Christian Urban <urbanc@in.tum.de>
parents:
315
diff
changeset
|
144 |
|
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
145 |
val ml_file_setup = Thy_Output.antiquotation_raw @{binding "ML_file"} single_arg check_file_exists |
171
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
146 |
|
45
78aeca00bb54
deleted old antiquote_setup and renamed antiquote_setup_plus to antiquuote_setup
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
147 |
|
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
98
diff
changeset
|
148 |
(* replaces the official subgoal antiquotation with one *) |
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
98
diff
changeset
|
149 |
(* that is closer to the actual output *) |
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
150 |
|
303
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
151 |
fun proof_state state = |
539
12861a362099
updated to new isabelle
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
517
diff
changeset
|
152 |
(case try (Proof.goal o Toplevel.proof_of) state of |
12861a362099
updated to new isabelle
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
517
diff
changeset
|
153 |
SOME {goal, ...} => goal |
12861a362099
updated to new isabelle
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
517
diff
changeset
|
154 |
| _ => error "No proof state"); |
12861a362099
updated to new isabelle
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
517
diff
changeset
|
155 |
|
303
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
156 |
|
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
157 |
fun output_goals ctxt _ = |
171
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
158 |
let |
98
0a5c95f4d70c
calculated the exact number of goals in the subgoal antiquotation
Christian Urban <urbanc@in.tum.de>
parents:
96
diff
changeset
|
159 |
fun subgoals 0 = "" |
96
018bfa718982
(re)defined the document antiquotation @subgoal in order to be closer to what is actually printed
Christian Urban <urbanc@in.tum.de>
parents:
90
diff
changeset
|
160 |
| subgoals 1 = "goal (1 subgoal):" |
171
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
161 |
| subgoals n = "goal (" ^ string_of_int n ^ " subgoals):" |
18f90044c777
simplified antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
165
diff
changeset
|
162 |
|
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
163 |
val state = proof_state (Toplevel.presentation_state ctxt) |
545
4a1539a2c18e
updated to new Isabelle
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
539
diff
changeset
|
164 |
val goals = Goal_Display.pretty_goal ctxt state |
98
0a5c95f4d70c
calculated the exact number of goals in the subgoal antiquotation
Christian Urban <urbanc@in.tum.de>
parents:
96
diff
changeset
|
165 |
|
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
166 |
val prop = Thm.prop_of state; |
303
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
167 |
val (As, _) = Logic.strip_horn prop; |
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
168 |
val out = (case (length As) of |
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
169 |
0 => goals |
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
170 |
| n => Pretty.big_list (subgoals n) [goals]) (* FIXME: improve printing? *) |
96
018bfa718982
(re)defined the document antiquotation @subgoal in order to be closer to what is actually printed
Christian Urban <urbanc@in.tum.de>
parents:
90
diff
changeset
|
171 |
in |
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
172 |
output ctxt [Pretty.string_of out] |
96
018bfa718982
(re)defined the document antiquotation @subgoal in order to be closer to what is actually printed
Christian Urban <urbanc@in.tum.de>
parents:
90
diff
changeset
|
173 |
end |
165
890fbfef6d6b
partially adapted to new antiquotation infrastructure
Christian Urban <urbanc@in.tum.de>
parents:
112
diff
changeset
|
174 |
|
303
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
175 |
|
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
176 |
fun output_raw_goal_state ctxt _ = |
539
12861a362099
updated to new isabelle
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
517
diff
changeset
|
177 |
let |
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
178 |
val goals = proof_state (Toplevel.presentation_state ctxt) |
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
179 |
val out = Syntax.string_of_term ctxt (Thm.prop_of goals) |
539
12861a362099
updated to new isabelle
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
517
diff
changeset
|
180 |
in |
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
181 |
output ctxt [out] |
539
12861a362099
updated to new isabelle
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
517
diff
changeset
|
182 |
end |
303
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
183 |
|
471 | 184 |
val subgoals_setup = |
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
185 |
Thy_Output.antiquotation_raw @{binding "subgoals"} (Scan.succeed ()) output_goals |
471 | 186 |
val raw_goal_state_setup = |
562
daf404920ab9
Accomodate to Isabelle 2018
Norbert Schirmer <norbert.schirmer@web.de>
parents:
557
diff
changeset
|
187 |
Thy_Output.antiquotation_raw @{binding "raw_goal_state"} (Scan.succeed ()) output_raw_goal_state |
471 | 188 |
|
189 |
val setup = |
|
190 |
ml_setup #> |
|
191 |
ml_response_setup #> |
|
192 |
ml_file_setup #> |
|
193 |
subgoals_setup #> |
|
194 |
raw_goal_state_setup |
|
303
05e6a33edef6
added an antiquotation for printing the raw proof state; polished the example about proof state
Christian Urban <urbanc@in.tum.de>
parents:
302
diff
changeset
|
195 |
|
45
78aeca00bb54
deleted old antiquote_setup and renamed antiquote_setup_plus to antiquuote_setup
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
196 |
end; |