author | wenzelm |
Mon, 17 Apr 2000 13:57:55 +0200 | |
changeset 8720 | 840c75ab2a7f |
parent 8660 | e5048a26e1d8 |
child 8807 | 0046be1769f9 |
permissions | -rw-r--r-- |
5829 | 1 |
(* Title: Pure/Isar/outer_syntax.ML |
2 |
ID: $Id$ |
|
3 |
Author: Markus Wenzel, TU Muenchen |
|
4 |
||
5 |
The global Isabelle/Isar outer syntax. |
|
6 |
*) |
|
7 |
||
8 |
signature BASIC_OUTER_SYNTAX = |
|
9 |
sig |
|
10 |
val main: unit -> unit |
|
5883 | 11 |
val loop: unit -> unit |
6860 | 12 |
val sync_main: unit -> unit |
13 |
val sync_loop: unit -> unit |
|
5829 | 14 |
val help: unit -> unit |
15 |
end; |
|
16 |
||
17 |
signature OUTER_SYNTAX = |
|
18 |
sig |
|
19 |
include BASIC_OUTER_SYNTAX |
|
6722 | 20 |
structure Keyword: |
21 |
sig |
|
22 |
val control: string |
|
23 |
val diag: string |
|
24 |
val thy_begin: string |
|
7104 | 25 |
val thy_switch: string |
6722 | 26 |
val thy_end: string |
27 |
val thy_heading: string |
|
28 |
val thy_decl: string |
|
29 |
val thy_goal: string |
|
30 |
val qed: string |
|
6733 | 31 |
val qed_block: string |
8209 | 32 |
val qed_global: string |
6722 | 33 |
val prf_goal: string |
34 |
val prf_block: string |
|
35 |
val prf_chain: string |
|
36 |
val prf_decl: string |
|
6868 | 37 |
val prf_asm: string |
7676 | 38 |
val prf_asm_goal: string |
6722 | 39 |
val prf_script: string |
40 |
val kinds: string list |
|
41 |
end |
|
5829 | 42 |
type token |
43 |
type parser |
|
6722 | 44 |
val command: string -> string -> string -> |
6373 | 45 |
(token list -> (Toplevel.transition -> Toplevel.transition) * token list) -> parser |
7750 | 46 |
val markup_command: string -> string -> string -> |
47 |
(token list -> (Toplevel.transition -> Toplevel.transition) * token list) -> parser |
|
8660 | 48 |
val markup_env_command: string -> string -> string -> |
49 |
(token list -> (Toplevel.transition -> Toplevel.transition) * token list) -> parser |
|
7789 | 50 |
val verbatim_command: string -> string -> string -> |
51 |
(token list -> (Toplevel.transition -> Toplevel.transition) * token list) -> parser |
|
6722 | 52 |
val improper_command: string -> string -> string -> |
6373 | 53 |
(token list -> (Toplevel.transition -> Toplevel.transition) * token list) -> parser |
7026 | 54 |
val dest_keywords: unit -> string list |
55 |
val dest_parsers: unit -> (string * string * string * bool) list |
|
5883 | 56 |
val print_outer_syntax: unit -> unit |
7367 | 57 |
val print_help: Toplevel.transition -> Toplevel.transition |
5829 | 58 |
val add_keywords: string list -> unit |
59 |
val add_parsers: parser list -> unit |
|
6247 | 60 |
val theory_header: token list -> (string * string list * (string * bool) list) * token list |
7940 | 61 |
val deps_thy: string -> bool -> Path.T -> string list * Path.T list |
6199 | 62 |
val load_thy: string -> bool -> bool -> Path.T -> unit |
7333 | 63 |
val isar: bool -> bool -> Toplevel.isar |
5829 | 64 |
end; |
65 |
||
66 |
structure OuterSyntax: OUTER_SYNTAX = |
|
67 |
struct |
|
68 |
||
7750 | 69 |
structure T = OuterLex; |
6860 | 70 |
structure P = OuterParse; |
71 |
||
5829 | 72 |
|
73 |
(** outer syntax **) |
|
74 |
||
6722 | 75 |
(* command keyword classification *) |
76 |
||
77 |
structure Keyword = |
|
78 |
struct |
|
79 |
val control = "control"; |
|
80 |
val diag = "diag"; |
|
81 |
val thy_begin = "theory-begin"; |
|
7104 | 82 |
val thy_switch = "theory-switch"; |
6722 | 83 |
val thy_end = "theory-end"; |
84 |
val thy_heading = "theory-heading"; |
|
85 |
val thy_decl = "theory-decl"; |
|
86 |
val thy_goal = "theory-goal"; |
|
87 |
val qed = "qed"; |
|
6733 | 88 |
val qed_block = "qed-block"; |
8209 | 89 |
val qed_global = "qed-global"; |
6722 | 90 |
val prf_goal = "proof-goal"; |
91 |
val prf_block = "proof-block"; |
|
92 |
val prf_chain = "proof-chain"; |
|
93 |
val prf_decl = "proof-decl"; |
|
6868 | 94 |
val prf_asm = "proof-asm"; |
7676 | 95 |
val prf_asm_goal = "proof-asm-goal"; |
6722 | 96 |
val prf_script = "proof-script"; |
97 |
||
7104 | 98 |
val kinds = [control, diag, thy_begin, thy_switch, thy_end, thy_heading, thy_decl, thy_goal, |
8209 | 99 |
qed, qed_block, qed_global, prf_goal, prf_block, prf_chain, prf_decl, prf_asm, prf_asm_goal, |
100 |
prf_script]; |
|
6722 | 101 |
end; |
102 |
||
103 |
||
5829 | 104 |
(* parsers *) |
105 |
||
7750 | 106 |
type token = T.token; |
5829 | 107 |
type parser_fn = token list -> (Toplevel.transition -> Toplevel.transition) * token list; |
108 |
||
8660 | 109 |
datatype markup_kind = Markup | MarkupEnv | Verbatim; |
110 |
||
5829 | 111 |
datatype parser = |
8660 | 112 |
Parser of string * (string * string * markup_kind option) * bool * parser_fn; |
5829 | 113 |
|
7750 | 114 |
fun parser int_only markup name comment kind parse = |
115 |
Parser (name, (comment, kind, markup), int_only, parse); |
|
5829 | 116 |
|
117 |
||
118 |
(* parse command *) |
|
119 |
||
6860 | 120 |
local |
6199 | 121 |
|
5829 | 122 |
fun command_body cmd (name, _) = |
7026 | 123 |
(case cmd name of |
124 |
Some (int_only, parse) => P.!!! (Scan.prompt (name ^ "# ") (parse >> pair int_only)) |
|
125 |
| None => sys_error ("no parser for outer syntax command " ^ quote name)); |
|
6860 | 126 |
|
127 |
fun terminator false = Scan.succeed () |
|
128 |
| terminator true = P.group "terminator" (Scan.option P.sync -- P.$$$ ";" >> K ()); |
|
129 |
||
130 |
in |
|
5829 | 131 |
|
6860 | 132 |
fun command term cmd = |
133 |
P.$$$ ";" >> K None || |
|
134 |
P.sync >> K None || |
|
7026 | 135 |
(P.position P.command :-- command_body cmd) --| terminator term |
6860 | 136 |
>> (fn ((name, pos), (int_only, f)) => |
137 |
Some (Toplevel.empty |> Toplevel.name name |> Toplevel.position pos |> |
|
138 |
Toplevel.interactive int_only |> f)); |
|
5829 | 139 |
|
6199 | 140 |
end; |
141 |
||
5829 | 142 |
|
143 |
||
144 |
(** global syntax state **) |
|
145 |
||
7026 | 146 |
local |
147 |
||
148 |
val global_lexicons = ref (Scan.empty_lexicon, Scan.empty_lexicon); |
|
7750 | 149 |
val global_parsers = |
8660 | 150 |
ref (Symtab.empty: (((string * string) * (bool * parser_fn)) * markup_kind option) Symtab.table); |
151 |
val global_markups = ref ([]: (string * markup_kind) list); |
|
5952 | 152 |
|
7026 | 153 |
fun change_lexicons f = |
154 |
let val lexs = f (! global_lexicons) in |
|
155 |
(case (op inter_string) (pairself Scan.dest_lexicon lexs) of |
|
156 |
[] => global_lexicons := lexs |
|
157 |
| bads => error ("Clash of outer syntax commands and keywords: " ^ commas_quote bads)) |
|
158 |
end; |
|
5829 | 159 |
|
7789 | 160 |
fun get_markup (ms, (name, (_, Some m))) = (name, m) :: ms |
161 |
| get_markup (ms, _) = ms; |
|
7750 | 162 |
|
163 |
fun make_markups () = global_markups := Symtab.foldl get_markup ([], ! global_parsers); |
|
164 |
fun change_parsers f = (global_parsers := f (! global_parsers); make_markups ()); |
|
6722 | 165 |
|
7026 | 166 |
in |
167 |
||
7750 | 168 |
|
169 |
(* get current syntax *) |
|
7026 | 170 |
|
171 |
(*Note: the syntax for files is statically determined at the very |
|
172 |
beginning; for interactive processing it may change dynamically.*) |
|
173 |
||
174 |
fun get_lexicons () = ! global_lexicons; |
|
175 |
fun get_parsers () = ! global_parsers; |
|
7750 | 176 |
fun get_parser () = apsome (#2 o #1) o curry Symtab.lookup (! global_parsers); |
7789 | 177 |
|
178 |
fun lookup_markup name = assoc (! global_markups, name); |
|
8660 | 179 |
fun is_markup kind name = (case lookup_markup name of Some k => k = kind | None => false); |
5829 | 180 |
|
181 |
||
182 |
(* augment syntax *) |
|
183 |
||
7026 | 184 |
fun add_keywords keywords = change_lexicons (apfst (fn lex => |
185 |
(Scan.extend_lexicon lex (map Symbol.explode keywords)))); |
|
5829 | 186 |
|
7750 | 187 |
fun add_parser (tab, Parser (name, (comment, kind, markup), int_only, parse)) = |
5829 | 188 |
(if is_none (Symtab.lookup (tab, name)) then () |
189 |
else warning ("Redefined outer syntax command " ^ quote name); |
|
7750 | 190 |
Symtab.update ((name, (((comment, kind), (int_only, parse)), markup)), tab)); |
5829 | 191 |
|
192 |
fun add_parsers parsers = |
|
7026 | 193 |
(change_parsers (fn tab => foldl add_parser (tab, parsers)); |
194 |
change_lexicons (apsnd (fn lex => Scan.extend_lexicon lex |
|
195 |
(map (fn Parser (name, _, _, _) => Symbol.explode name) parsers)))); |
|
196 |
||
197 |
end; |
|
5829 | 198 |
|
199 |
||
7026 | 200 |
(* print syntax *) |
201 |
||
202 |
fun dest_keywords () = Scan.dest_lexicon (#1 (get_lexicons ())); |
|
203 |
||
204 |
fun dest_parsers () = |
|
7750 | 205 |
map (fn (name, (((cmt, kind), (int_only, _)), _)) => (name, cmt, kind, int_only)) |
7026 | 206 |
(Symtab.dest (get_parsers ())); |
5829 | 207 |
|
8720 | 208 |
fun help_outer_syntax () = |
7026 | 209 |
let |
210 |
fun pretty_cmd (name, comment, _, _) = |
|
211 |
Pretty.block [Pretty.str (name ^ ":"), Pretty.brk 2, Pretty.str comment]; |
|
212 |
val (int_cmds, cmds) = partition #4 (dest_parsers ()); |
|
213 |
in |
|
8720 | 214 |
[Pretty.strs ("syntax keywords:" :: map quote (dest_keywords ())), |
215 |
Pretty.big_list "proper commands:" (map pretty_cmd cmds), |
|
216 |
Pretty.big_list "improper commands (interactive-only):" (map pretty_cmd int_cmds)] |
|
7026 | 217 |
end; |
5829 | 218 |
|
8720 | 219 |
val print_outer_syntax = Pretty.writeln o Pretty.chunks o help_outer_syntax; |
220 |
||
7367 | 221 |
val print_help = |
222 |
Toplevel.keep (fn state => |
|
7613 | 223 |
let val opt_thy = try Toplevel.theory_of state in |
8720 | 224 |
help_outer_syntax () @ |
225 |
Method.help_methods opt_thy @ |
|
7613 | 226 |
Attrib.help_attributes opt_thy |
8720 | 227 |
|> Pretty.chunks |> Pretty.writeln |
7613 | 228 |
end); |
7367 | 229 |
|
5829 | 230 |
|
231 |
||
232 |
(** read theory **) |
|
233 |
||
7746 | 234 |
(* special keywords *) |
6247 | 235 |
|
7746 | 236 |
val headerN = "header"; |
6247 | 237 |
val theoryN = "theory"; |
7746 | 238 |
|
7750 | 239 |
val theory_keyword = P.$$$ theoryN; |
240 |
val header_keyword = P.$$$ headerN; |
|
7746 | 241 |
val semicolon = P.$$$ ";"; |
6247 | 242 |
|
243 |
||
7683 | 244 |
(* sources *) |
5829 | 245 |
|
6860 | 246 |
local |
5829 | 247 |
|
6860 | 248 |
val no_terminator = |
7750 | 249 |
Scan.unless semicolon (Scan.one (T.not_sync andf T.not_eof)); |
6860 | 250 |
|
251 |
val recover = Scan.prompt "recover# " (Scan.repeat no_terminator); |
|
252 |
||
253 |
in |
|
5829 | 254 |
|
6860 | 255 |
fun source term do_recover cmd src = |
5829 | 256 |
src |
7750 | 257 |
|> Source.source T.stopper |
258 |
(Scan.bulk (fn xs => P.!!! (command term (cmd ())) xs)) |
|
6860 | 259 |
(if do_recover then Some recover else None) |
5829 | 260 |
|> Source.mapfilter I; |
261 |
||
6860 | 262 |
end; |
263 |
||
7683 | 264 |
fun token_source (src, pos) = |
265 |
src |
|
266 |
|> Symbol.source false |
|
7750 | 267 |
|> T.source false (K (get_lexicons ())) pos; |
7683 | 268 |
|
269 |
fun filter_proper src = |
|
270 |
src |
|
7750 | 271 |
|> Source.filter T.is_proper; |
7683 | 272 |
|
5829 | 273 |
|
7746 | 274 |
(* scan header *) |
5829 | 275 |
|
7026 | 276 |
fun scan_header get_lex scan (src, pos) = |
5829 | 277 |
src |
278 |
|> Symbol.source false |
|
7750 | 279 |
|> T.source false (fn () => (get_lex (), Scan.empty_lexicon)) pos |
7683 | 280 |
|> filter_proper |
7750 | 281 |
|> Source.source T.stopper (Scan.single scan) None |
5829 | 282 |
|> (fst o the o Source.get_single); |
283 |
||
7746 | 284 |
|
285 |
(* detect new/old header *) |
|
286 |
||
287 |
local |
|
5829 | 288 |
|
7746 | 289 |
val check_header_lexicon = Scan.make_lexicon [Symbol.explode headerN, Symbol.explode theoryN]; |
290 |
val check_header = Scan.option (header_keyword || theory_keyword); |
|
291 |
||
292 |
in |
|
293 |
||
294 |
fun is_old_theory src = is_none (scan_header (K check_header_lexicon) check_header src); |
|
295 |
||
296 |
end; |
|
6199 | 297 |
|
298 |
||
299 |
(* deps_thy --- inspect theory header *) |
|
300 |
||
7746 | 301 |
local |
302 |
||
6247 | 303 |
val header_lexicon = |
7746 | 304 |
Scan.make_lexicon (map Symbol.explode ["(", ")", "+", ":", ";", "=", "files", headerN, theoryN]); |
6199 | 305 |
|
7026 | 306 |
val file_name = |
307 |
(P.$$$ "(" |-- P.!!! (P.name --| P.$$$ ")")) >> rpair false || P.name >> rpair true; |
|
6247 | 308 |
|
7746 | 309 |
in |
310 |
||
311 |
val theory_header = |
|
6860 | 312 |
(P.name -- (P.$$$ "=" |-- P.enum1 "+" P.name) -- |
7746 | 313 |
Scan.optional (P.$$$ "files" |-- P.!!! (Scan.repeat1 file_name)) [] --| P.$$$ ":") |
6247 | 314 |
>> (fn ((A, Bs), files) => (A, Bs, files)); |
315 |
||
7746 | 316 |
val new_header = |
317 |
header_keyword |-- (P.!!! (P.text -- Scan.option semicolon -- theory_keyword |-- theory_header)) |
|
318 |
|| theory_keyword |-- P.!!! theory_header; |
|
6199 | 319 |
|
320 |
val old_header = |
|
7810 | 321 |
P.!!! (P.group "theory header" |
322 |
(P.name -- (P.$$$ "=" |-- P.name -- Scan.repeat (P.$$$ "+" |-- P.name)))) |
|
6247 | 323 |
>> (fn (A, (B, Bs)) => (A, B :: Bs, []: (string * bool) list)); |
6199 | 324 |
|
7940 | 325 |
fun deps_thy name ml path = |
6199 | 326 |
let |
7735 | 327 |
val src = Source.of_string (File.read path); |
328 |
val pos = Path.position path; |
|
6247 | 329 |
val (name', parents, files) = |
7940 | 330 |
(*unfortunately, old-style headers dynamically depend on the current lexicon*) |
7746 | 331 |
if is_old_theory (src, pos) then |
332 |
scan_header ThySyn.get_lexicon (Scan.error old_header) (src, pos) |
|
7735 | 333 |
else scan_header (K header_lexicon) (Scan.error new_header) (src, pos); |
6199 | 334 |
|
335 |
val ml_path = ThyLoad.ml_path name; |
|
7940 | 336 |
val ml_file = if ml andalso is_some (ThyLoad.check_file ml_path) then [ml_path] else []; |
6199 | 337 |
in |
338 |
if name <> name' then |
|
7940 | 339 |
error ("Filename " ^ quote (Path.pack path) ^ |
8078 | 340 |
" does not agree with theory name " ^ quote name') |
6247 | 341 |
else (parents, map (Path.unpack o #1) files @ ml_file) |
6199 | 342 |
end; |
343 |
||
7746 | 344 |
end; |
345 |
||
6199 | 346 |
|
7750 | 347 |
(* present theory source *) |
348 |
||
349 |
local |
|
350 |
||
8583 | 351 |
val is_improper = not o (T.is_proper orf T.is_begin_ignore orf T.is_end_ignore); |
352 |
val improper = Scan.any is_improper; |
|
7903 | 353 |
|
8583 | 354 |
val improper_keep_indent = Scan.repeat |
355 |
(Scan.unless (Scan.one T.is_indent -- Scan.one T.is_proper) (Scan.one is_improper)); |
|
7903 | 356 |
|
357 |
val improper_end = |
|
358 |
(improper -- semicolon) |-- improper_keep_indent || |
|
359 |
improper_keep_indent; |
|
360 |
||
8583 | 361 |
|
362 |
val ignore = |
|
363 |
Scan.depend (fn d => Scan.one T.is_begin_ignore >> pair (d + 1)) || |
|
364 |
Scan.depend (fn 0 => Scan.fail | d => Scan.one T.is_end_ignore >> pair (d - 1)) || |
|
365 |
Scan.lift (Scan.one (OuterLex.not_eof andf (not o OuterLex.is_end_ignore))); |
|
366 |
||
8652 | 367 |
val opt_newline = Scan.option (Scan.one T.is_newline); |
368 |
||
8583 | 369 |
val ignore_stuff = |
8652 | 370 |
opt_newline -- Scan.one T.is_begin_ignore -- |
371 |
P.!!!! (Scan.pass 0 (Scan.repeat ignore) -- Scan.one T.is_end_ignore -- opt_newline); |
|
8583 | 372 |
|
8660 | 373 |
fun markup_kind k = Scan.one (T.is_kind T.Command andf is_markup k o T.val_of); |
374 |
||
375 |
val markup = markup_kind Markup >> T.val_of; |
|
376 |
val markup_env = markup_kind MarkupEnv >> T.val_of; |
|
377 |
val verbatim = markup_kind Verbatim; |
|
7750 | 378 |
|
7755 | 379 |
val present_token = |
8583 | 380 |
ignore_stuff >> K None || |
381 |
(improper |-- markup -- P.!!!! (improper |-- P.text --| improper_end) >> Present.markup_token || |
|
8660 | 382 |
improper |-- markup_env -- P.!!!! (improper |-- P.text --| improper_end) >> Present.markup_env_token || |
8583 | 383 |
(P.$$$ "--" >> K "cmt") -- P.!!!! (improper |-- P.text) >> Present.markup_token || |
384 |
(improper -- verbatim) |-- P.!!!! (improper |-- P.text --| improper_end) |
|
385 |
>> Present.verbatim_token || |
|
386 |
Scan.one T.not_eof >> Present.basic_token) >> Some; |
|
7750 | 387 |
|
388 |
in |
|
389 |
||
390 |
(*note: lazy evaluation ahead*) |
|
391 |
||
392 |
fun present_toks text pos () = |
|
393 |
token_source (Source.of_list (Library.untabify text), pos) |
|
8583 | 394 |
|> Source.source T.stopper (Scan.bulk (Scan.error present_token)) None |
395 |
|> Source.mapfilter I |
|
7755 | 396 |
|> Source.exhaust; |
7750 | 397 |
|
398 |
fun present_text text () = |
|
399 |
Source.exhaust (Symbol.source false (Source.of_list (Library.untabify text))); |
|
400 |
||
401 |
end; |
|
402 |
||
403 |
||
6199 | 404 |
(* load_thy --- read text (including header) *) |
405 |
||
7746 | 406 |
local |
407 |
||
7940 | 408 |
fun try_ml_file name time = |
6199 | 409 |
let |
410 |
val path = ThyLoad.ml_path name; |
|
7940 | 411 |
val tr = Toplevel.imperative (fn () => ThyInfo.load_file time path); |
6247 | 412 |
val tr_name = if time then "time_use" else "use"; |
6199 | 413 |
in |
7243 | 414 |
if is_none (ThyLoad.check_file path) then () |
7062 | 415 |
else Toplevel.excursion_error [Toplevel.empty |> Toplevel.name tr_name |> tr] |
6199 | 416 |
end; |
417 |
||
7683 | 418 |
fun parse_thy src_pos = |
7746 | 419 |
src_pos |
420 |
|> token_source |
|
421 |
|> filter_proper |
|
422 |
|> source false false (K (get_parser ())) |
|
423 |
|> Source.exhaust; |
|
5829 | 424 |
|
6247 | 425 |
fun run_thy name path = |
7683 | 426 |
let |
7735 | 427 |
val text = explode (File.read path); |
428 |
val src = Source.of_list text; |
|
429 |
val pos = Path.position path; |
|
7683 | 430 |
in |
7735 | 431 |
Present.init_theory name; |
7768 | 432 |
Present.verbatim_source name (present_text text); |
8191 | 433 |
if is_old_theory (src, pos) then (ThySyn.load_thy name text; |
434 |
Present.old_symbol_source name (present_text text)) (*note: text presented twice!*) |
|
7774
6da9b544a12d
Present.token_source after load (better errors!?);
wenzelm
parents:
7768
diff
changeset
|
435 |
else (Toplevel.excursion_error (parse_thy (src, pos)); |
6da9b544a12d
Present.token_source after load (better errors!?);
wenzelm
parents:
7768
diff
changeset
|
436 |
Present.token_source name (present_toks text pos)) |
6247 | 437 |
end; |
6199 | 438 |
|
7746 | 439 |
in |
440 |
||
6199 | 441 |
fun load_thy name ml time path = |
6247 | 442 |
(if time then |
443 |
timeit (fn () => |
|
444 |
(writeln ("\n**** Starting theory " ^ quote name ^ " ****"); |
|
445 |
setmp Goals.proof_timing true (run_thy name) path; |
|
446 |
writeln ("**** Finished theory " ^ quote name ^ " ****\n"))) |
|
447 |
else run_thy name path; |
|
448 |
Context.context (ThyInfo.get_theory name); |
|
7940 | 449 |
if ml then try_ml_file name time else ()); |
5829 | 450 |
|
7746 | 451 |
end; |
452 |
||
5829 | 453 |
|
454 |
(* interactive source of state transformers *) |
|
455 |
||
7333 | 456 |
fun isar term no_pos = |
5829 | 457 |
Source.tty |
458 |
|> Symbol.source true |
|
7750 | 459 |
|> T.source true get_lexicons |
7604 | 460 |
(if no_pos then Position.none else Position.line_name 1 "stdin") |
7683 | 461 |
|> filter_proper |
6860 | 462 |
|> source term true get_parser; |
5829 | 463 |
|
464 |
||
465 |
||
466 |
(** the read-eval-print loop **) |
|
467 |
||
5923 | 468 |
(* main loop *) |
469 |
||
7333 | 470 |
fun gen_loop term no_pos = |
471 |
(Context.reset_context (); |
|
472 |
Toplevel.loop (isar term no_pos)); |
|
5829 | 473 |
|
7333 | 474 |
fun gen_main term no_pos = |
5829 | 475 |
(Toplevel.set_state Toplevel.toplevel; |
6199 | 476 |
writeln (Session.welcome ()); |
7333 | 477 |
gen_loop term no_pos); |
6860 | 478 |
|
7333 | 479 |
fun main () = gen_main false false; |
480 |
fun loop () = gen_loop false false; |
|
481 |
fun sync_main () = gen_main true true; |
|
482 |
fun sync_loop () = gen_loop true true; |
|
5829 | 483 |
|
484 |
||
485 |
(* help *) |
|
486 |
||
487 |
fun help () = |
|
488 |
writeln ("This is Isabelle's underlying ML system (" ^ ml_system ^ ");\n\ |
|
5883 | 489 |
\invoke 'loop();' to enter the Isar loop."); |
5829 | 490 |
|
491 |
||
6373 | 492 |
(*final declarations of this structure!*) |
7789 | 493 |
val command = parser false None; |
8660 | 494 |
val markup_command = parser false (Some Markup); |
495 |
val markup_env_command = parser false (Some MarkupEnv); |
|
496 |
val verbatim_command = parser false (Some Verbatim); |
|
7789 | 497 |
val improper_command = parser true None; |
6685 | 498 |
|
6373 | 499 |
|
5829 | 500 |
end; |
501 |
||
6199 | 502 |
(*setup theory syntax dependent operations*) |
503 |
ThyLoad.deps_thy_fn := OuterSyntax.deps_thy; |
|
504 |
ThyLoad.load_thy_fn := OuterSyntax.load_thy; |
|
505 |
structure ThyLoad: THY_LOAD = ThyLoad; |
|
506 |
||
5829 | 507 |
structure BasicOuterSyntax: BASIC_OUTER_SYNTAX = OuterSyntax; |
508 |
open BasicOuterSyntax; |