author | wenzelm |
Tue, 27 Jul 1999 21:55:39 +0200 | |
changeset 7100 | 4f777a0e1c8b |
parent 7027 | ca0fbe679bbb |
child 7193 | cc7a89d233f7 |
permissions | -rw-r--r-- |
6699 | 1 |
(* Title: Pure/Interface/proof_general.ML |
2 |
ID: $Id$ |
|
3 |
Author: Markus Wenzel, TU Muenchen |
|
4 |
||
5 |
Configuration for ProofGeneral of LFCS Edinburgh. |
|
6 |
*) |
|
7 |
||
8 |
signature PROOF_GENERAL = |
|
9 |
sig |
|
6947 | 10 |
val write_keywords: unit -> unit |
6699 | 11 |
val setup: (theory -> theory) list |
12 |
val init: bool -> unit |
|
13 |
end; |
|
14 |
||
15 |
structure ProofGeneral: PROOF_GENERAL = |
|
16 |
struct |
|
17 |
||
18 |
||
6720
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
19 |
(** generate keyword classification file **) |
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
20 |
|
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
21 |
local |
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
22 |
|
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
23 |
val regexp_meta = explode ".*+?[]^$"; |
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
24 |
val regexp_quote = implode o map (fn c => if c mem regexp_meta then "\\\\" ^ c else c) o explode; |
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
25 |
|
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
26 |
fun defconst name strs = |
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
27 |
"\n(defconst isar-keywords-" ^ name ^ |
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
28 |
"\n '(" ^ space_implode "\n " (map (quote o regexp_quote) strs) ^ "))\n"; |
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
29 |
|
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
30 |
fun make_elisp_commands commands kind = |
7027 | 31 |
defconst kind (mapfilter (fn (c, _, k, _) => if k = kind then Some c else None) commands); |
6720
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
32 |
|
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
33 |
fun make_elisp_syntax (keywords, commands) = |
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
34 |
";;\n\ |
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
35 |
\;; Keyword classification tables for Isabelle/Isar.\n\ |
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
36 |
\;; This file generated by Isabelle -- DO NOT EDIT!\n\ |
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
37 |
\;;\n\ |
6724 | 38 |
\;; $" ^ "Id$\n\ |
6720
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
39 |
\;;\n" ^ |
7027 | 40 |
defconst "minor" (filter Syntax.is_identifier keywords) ^ |
6720
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
41 |
implode (map (make_elisp_commands commands) OuterSyntax.Keyword.kinds) ^ |
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
42 |
"\n(provide 'isar-keywords)\n"; |
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
43 |
|
6947 | 44 |
val keywords_file = "isar-keywords.el"; |
45 |
||
6720
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
46 |
in |
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
47 |
|
6947 | 48 |
fun write_keywords () = |
7027 | 49 |
File.write (Path.unpack keywords_file) |
50 |
(make_elisp_syntax (OuterSyntax.dest_keywords (), OuterSyntax.dest_parsers ())); |
|
6720
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
51 |
|
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
52 |
end; |
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
53 |
|
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
54 |
|
353bd9b74b1f
write_keywords generates outer syntax keyword classification in elisp;
wenzelm
parents:
6699
diff
changeset
|
55 |
|
6699 | 56 |
(** compile-time theory setup **) |
57 |
||
58 |
(* token translations *) |
|
59 |
||
60 |
val proof_generalN = "ProofGeneral"; |
|
61 |
||
62 |
local |
|
63 |
||
64 |
val end_tag = oct_char "350"; |
|
65 |
val tclass_tag = oct_char "351"; |
|
66 |
val tfree_tag = oct_char "352"; |
|
67 |
val tvar_tag = oct_char "353"; |
|
68 |
val free_tag = oct_char "354"; |
|
69 |
val bound_tag = oct_char "355"; |
|
70 |
val var_tag = oct_char "356"; |
|
71 |
||
72 |
fun tagit p x = (p ^ x ^ end_tag, real (size x)); |
|
73 |
||
74 |
in |
|
75 |
||
76 |
val proof_general_trans = |
|
77 |
Syntax.tokentrans_mode proof_generalN |
|
78 |
[("class", tagit tclass_tag), |
|
79 |
("tfree", tagit tfree_tag), |
|
80 |
("tvar", tagit tvar_tag), |
|
81 |
("free", tagit free_tag), |
|
82 |
("bound", tagit bound_tag), |
|
83 |
("var", tagit var_tag)]; |
|
84 |
||
85 |
end; |
|
86 |
||
87 |
||
88 |
(* setup *) |
|
89 |
||
90 |
val setup = [Theory.add_tokentrfuns proof_general_trans]; |
|
91 |
||
92 |
||
93 |
||
94 |
(** run-time initialization **) |
|
95 |
||
96 |
(* messages *) |
|
97 |
||
98 |
fun decorate_lines bg en "" = std_output o suffix "\n" o enclose bg en |
|
99 |
| decorate_lines bg en prfx = std_output o suffix "\n" o enclose bg en o prefix_lines prfx; |
|
100 |
||
101 |
fun setup_messages () = |
|
102 |
(writeln_fn := (decorate_lines (oct_char "360") (oct_char "361") ""); |
|
103 |
warning_fn := (decorate_lines (oct_char "362") (oct_char "363") "### "); |
|
104 |
error_fn := (decorate_lines (oct_char "364") (oct_char "365") "*** ")); |
|
105 |
||
106 |
||
107 |
(* theory / proof state *) |
|
108 |
||
109 |
fun setup_state () = |
|
110 |
(current_goals_markers := |
|
111 |
let |
|
112 |
val begin_state = oct_char "366"; |
|
113 |
val end_state= oct_char "367"; |
|
114 |
val begin_goal = oct_char "370"; |
|
115 |
in (begin_state, end_state, begin_goal) end; |
|
116 |
Toplevel.print_state_fn := |
|
117 |
(Library.setmp writeln_fn (std_output o suffix "\n") Toplevel.print_state_default); |
|
118 |
Toplevel.prompt_state_fn := (suffix (oct_char "372") o Toplevel.prompt_state_default)); |
|
119 |
||
120 |
||
7100 | 121 |
(* theory loader actions *) |
122 |
||
123 |
local |
|
124 |
||
125 |
fun tell_pg msg name = writeln ("Proof General, " ^ msg ^ " " ^ quote name); |
|
126 |
||
127 |
fun trace_action ThyInfo.Update name = tell_pg "this theory is loaded:" name |
|
128 |
| trace_action ThyInfo.Outdate name = tell_pg "you can unlock the theory" name |
|
129 |
| trace_action ThyInfo.Remove name = tell_pg "you can unlock the theory" name; |
|
130 |
||
131 |
in |
|
132 |
fun setup_thy_loader () = ThyInfo.add_hook trace_action; |
|
133 |
end; |
|
134 |
||
135 |
||
6699 | 136 |
(* init *) |
137 |
||
138 |
fun init isar = |
|
139 |
(setup_messages (); |
|
140 |
setup_state (); |
|
7100 | 141 |
setup_thy_loader (); |
6699 | 142 |
print_mode := [proof_generalN]; |
143 |
set quick_and_dirty; |
|
6861 | 144 |
if isar then Isar.sync_main () else ()); |
6699 | 145 |
|
146 |
||
147 |
end; |